feat(options-gps): autonomous execution — CLI trades options on Deribit/Aevo (closes #26)#42
Conversation
…ibit/Aevo (closes entrius#26) - executor.py: Deribit via POST+JSON-RPC, Aevo HMAC, DryRun, auto-route per leg - main.py: --execute best|safer|upside, --dry-run, --force, --exchange; Screen 5; guardrail refusal - README: exchange integration architecture, Execution section, env vars - 37 tests: instrument names, plan build/validate, dry-run, factory, guardrail, E2E
d87e1b3 to
b1eafb4
Compare
|
Hi @MkDev11 please leave gps part to me, please do not copy my approach from previous commit, this can be penalized... |
|
@eureka928 I implemented the issue using my own approach, not yours. Also, this is a public issue, not a private one, so anyone is free to work on it and open their own PRs. |
|
don’t make my PR messy. my approach is my own, and it doesn’t mean I used yours. I already spent enough time working on this issue. |
- Deribit: use contracts not amount for options order size - Retry transient errors (timeout, 5xx) in _deribit_rpc and AevoExecutor - Add execution.testnet to decision log from env - DeribitExecutor: cache token, skip re-auth for multi-leg same exchange - Remove unreachable code in _deribit_rpc
Okay, but just don't copy others... just use your own judgement |
…ride, bug fixes - Add get_order_status/cancel_order to all executors (DryRun, Deribit, Aevo) - Add execution timestamps, slippage %, latency ms to OrderResult - Add slippage protection (--max-slippage): reject fills exceeding threshold - Add quantity override (--quantity): override contract count for all legs - Add order monitoring (--timeout): poll until filled or cancel on timeout - Add auto-cancel of filled legs on partial multi-leg failure - Fix Aevo HMAC signing to include HTTP method + path in signature - Fix quantity_override not applied during plan build (was set post-build) - Fix _monitor_order negative sleep ValueError on deadline overrun - Enhanced Screen 5 output with slippage/latency/timestamps - Enhanced decision log JSON with per-fill metrics and cancelled orders - Add 21 new tests: lifecycle, slippage, timestamps, quantity override, multi-leg E2E, non-crypto skip, slippage E2E (177 total, all passing) - Update README with new CLI flags and test coverage
… valid expiry - DeribitExecutor.place_order: use 'amount' param (not 'contracts') for options - Add _get_index_price: fetch/cache underlying price for USD→BTC conversion - Add _get_book_price: fetch live order book ask/bid with mark_price fallback - Snap prices to tick size (0.0005) to avoid Deribit tick conformance rejection - Convert BTC fill prices back to USD for pipeline consistency - Update mock data expiry from 2026-02-26 to 2026-03-27 (valid on testnet) - Update deribit_BTC.json instrument names to match (27MAR26) - Verified: live testnet order placement, monitoring, timeout+cancel all working - 177 tests passing
|
https://screenrec.com/share/xM8Ibk2COs |
… demo fills - Update option_pricing/BTC.json: strikes 68000-74000 centered on $71,181 - Update exchange mock data with full strike coverage (old 65000-68500 + new 69000-74000) - Scale prediction_percentiles BTC_24h/BTC_1h to center on new price - Ensures: live testnet orders fill (near-ATM liquidity), guardrail triggers (fusion='unclear'), and all 177 tests pass - Demo shows real 2-leg bull put credit spread filled on Deribit testnet
Addresses owner feedback: demo should focus on trade execution, not unchanged analysis screens. Usage: --screen none --execute best
13.03.2026_13.23.08_REC.mp4 |
|
@e35ventura I just updated the demo video |
Summary
Options GPS can now autonomously trade options on Deribit and Aevo directly from the CLI. This adds a full execution engine with order placement, order lifecycle management (place → monitor → cancel), slippage protection, position sizing, and safety guardrails — transforming the tool from analysis-only to end-to-end autonomous execution.
Before: CLI showed recommended venue/price per leg but could not place orders. No
--executeor Screen 5.After:
--dry-runsimulates execution (no credentials needed);--execute best(orsafer/upside) submits live orders to Deribit/Aevo. Each leg is auto-routed to its best venue. Orders are monitored with configurable timeout, protected by slippage limits, and partially-filled multi-leg strategies are automatically unwound on failure.Related Issues
Closes #26
Type of Change
What Changed
executor.py— New execution engine (719 lines)Data model:
OrderRequest/OrderResult/ExecutionPlan/ExecutionReportdataclassesOrderResulttrackstimestamp(ISO 8601),slippage_pct, andlatency_msper fillExecutionPlansupportsmax_slippage_pct,timeout_seconds,quantity_overrideExecutionReportincludesstarted_at,finished_at,cancelled_ordersExecutors (abstract
BaseExecutorwith full order lifecycle):DryRunExecutor— simulates fills from quote data; tracks orders for status/cancelDeribitExecutor— POST + JSON-RPC 2.0 with OAuth token caching, USD↔BTC price conversion, live order book pricing, tick-size alignmentAevoExecutor— REST with HMAC-SHA256 signing (method + path + timestamp + body)Order lifecycle:
place_order()→get_order_status()→cancel_order()on all executorsExecution engine:
build_execution_plan()— auto-routes per leg vialeg_divergences, builds exchange-specific instrument names (Deribit:BTC-27MAR26-71000-C, Aevo:BTC-71000-C), applies quantity overridevalidate_plan()— pre-flight checks (instruments, prices, quantities, actions)execute_plan()— sequential execution with:get_order_status()until filled or timeout, then cancels--max-slippagethresholdget_executor()factory — reads credentials from env vars, supports testnetmain.py— CLI integrationNew flags:
--execute best|safer|upside--dry-run--force--exchange deribit|aevo--max-slippage N--quantity N--timeout N--screen noneScreen 5 (Execution): order plan display, live confirmation prompt, per-leg results with slippage/latency metrics, auto-cancelled orders, execution timestamps.
Decision log:
executionblock now includesstarted_at,finished_at, per-fillslippage_pct/latency_ms/timestamp,cancelled_orders,max_slippage_pct,timeout_seconds,quantity_override.README.md— Updated documentationTesting
Test breakdown
test_executor.py— 54 tests:TestInstrumentNames(7) — Deribit/Aevo name builders, roundtrip parsing, edge casesTestBuildPlan(6) — single/multi-leg, exchange override, aevo names, auto-route, estimated costTestValidatePlan(5) — valid plan, empty orders, zero price, zero quantity, empty instrumentTestDryRunExecutor(12) — authenticate, buy/sell fills, missing strike, no-match fallback, get_order_status, status not found, cancel_order, cancel not found, timestamp on result, slippage trackedTestExecuteFlow(7) — single/multi-leg, net cost, auto-routing factory, summary message, report timestampsTestGetExecutor(5) — dry-run, dry-run ignores exchange, missing creds (Deribit/Aevo), unknown exchangeTestSlippage(8) — buy worse/better, sell worse/better, zero expected, slippage protection rejects, slippage protection allowsTestQuantityOverride(3) — default quantity, override applied (single-leg), override applied (multi-leg)test_executor_e2e.py— 8 tests:Verify:
python3 -m pytest tools/options-gps/tests/ -v→ 177 passed (119 existing + 58 new).Edge Cases Handled
get_executorraises with clear env var messageBTC-27MAR26-71000-C; Aevo:BTC-71000-C--force; dry-run always allowedValueErrorcrashEnvironment Variables (live execution)
DERIBIT_CLIENT_ID/DERIBIT_CLIENT_SECRETDERIBIT_TESTNET=1AEVO_API_KEY/AEVO_API_SECRETAEVO_TESTNET=1Checklist
Demo Video
https://screenrec.com/share/KnbYFEMVvT