feat(options-gps): market line shopping — live exchange pricing, z-score edge detection, execution routing#39
Merged
e35ventura merged 6 commits intoentrius:mainfrom Mar 12, 2026
Conversation
Mock JSON responses for BTC, ETH, SOL on both exchanges. Prices intentionally vary ±1-5% from Synth fair values to create testable divergence scenarios for line shopping.
…aware routing Core module for Market Line Shopping: - ExchangeQuote and EdgeMetrics dataclasses - fetch_deribit/fetch_aevo with mock_dir fallback for offline dev - Live API fetchers: Deribit get_book_summary, Aevo parallel orderbook - compute_edge() with population std dev and z-score (STRONG/MODERATE/WEAK/NONE) - best_execution_price() routes BUY→lowest ask, SELL→highest bid - leg_divergences() and strategy_divergence() for per-leg and aggregate scoring
New divergence_by_strategy param accepts {id(candidate): z_score}.
Applies clamped ±0.15 additive bonus (z * 0.06) after confidence
multiplier. No changes to ScoredStrategy dataclass — fully backward
compatible.
…uting - Market Line Shopping table with ★ Execute @ column and Edge (z-score σ) - ◆ markers highlight |z|≥1.0 disagreement at a glance - Per-leg best venue annotation: ★ Buy @ AEVO ask $655 — edge +1.5σ ◆ - Decision log includes exchange_edge_zscore and exchange_edge_label - Non-crypto assets gracefully skip exchange data
- conftest.py: shared fixtures for exchange quotes, strategies, option data - test_exchange.py: 8 fetch/parse, 6 best price, 7 edge detection, 10 divergence, 5 ranking integration tests - test_line_shopping_e2e.py: full pipeline, non-crypto skip, graceful failure
- README.md: Market Line Shopping section with feature overview - screenshots: BTC line shopping output, SPY graceful skip, test results
This was referenced Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Market Line Shopping to Options GPS — compares Synth's theoretical option prices against live exchange data (Deribit, Aevo) to find mispricing edges using statistical z-score analysis, then routes each strategy leg to the best execution venue. Like a sports bettor shopping lines across books.
Closes #32
What's New
exchange.py— new module with:_fetch_deribit_live()(single request viaget_book_summary_by_currency),_fetch_aevo_live()(parallel orderbook fetches viaThreadPoolExecutor, capped at 40 instruments). Falls back to mock data when no API connectivity.compute_edge()computes population std dev across all pricing sources (Synth + exchanges) with a noise floor at 0.1% of market mean. Labels: STRONG (|z|≥2.0), MODERATE (|z|≥1.0), WEAK (|z|≥0.5), NONE.best_execution_price()— BUY legs route to lowest ask, SELL legs route to highest bid across venues.ExchangeQuoteandEdgeMetricsdataclasses,leg_divergences(),strategy_divergence().Pipeline integration —
rank_strategies()acceptsdivergence_by_strategymappingid(candidate) → z_score. Applies clamped ±0.15 additive bonus (z * 0.06) after confidence multiplier. No changes toScoredStrategydataclass — fully backward compatible.High-signal UI — Market Line Shopping table on Screen 1b with call/put side-by-side per strike:
* Exec(best venue + ask price), Edge (z-score σ)★ Buy @ AEVO ask $655 — edge +1.5σexchange_edge_zscoreandexchange_edge_labelper strategyMock data — 6 JSON files (
deribit_BTC/ETH/SOL.json,aevo_BTC/ETH/SOL.json) with intentional ±1-5% price variation from Synth fair values for testable divergence scenarios.Related Issues
Closes #32
Type of Change
Testing
Test command:
python -m pytest tools/options-gps/tests/ -vResult: 119 passed (80 existing + 36 exchange + 3 e2e) in 0.09s
Checklist
Files Changed
mock_data/exchange_options/*.jsontools/options-gps/exchange.pytools/options-gps/pipeline.pydivergence_by_strategyparam torank_strategies()(+10 lines)tools/options-gps/main.pytools/options-gps/tests/conftest.pytools/options-gps/tests/test_exchange.pytools/options-gps/tests/test_line_shopping_e2e.pytools/options-gps/README.mdCLI Output: BTC Bullish (Crypto)
Test Results