Add drift-comparator pushdown for conditional market fetches#51
Add drift-comparator pushdown for conditional market fetches#51IamJasonBian wants to merge 2 commits intomainfrom
Conversation
Implement DriftComparator class to cache per-symbol price/metrics state and conditionally fetch full OHLCV data only when price drifts >0.5% (or 0.2% in high-vol regime) or data exceeds 30-minute staleness. Modifies run_once() to use multi-quote (1 API call) first, only full-fetching symbols that trigger drift thresholds. Adds refresh_open_order_metrics() method for on-demand order pricing. Typical cycle reduces from 8 API calls to 1 when market is flat.
…blobs - AllocationFeedClient reads from market-quotes and options-chain blob stores - normalize_feed_quotes handles both live Alpaca format (bid/ask/mid) and legacy format (bid_price/ask_price/midpoint_price), skips _meta entries - Options chain client handles per-symbol keyed blobs (e.g. IWN/timestamp) - 12 offline tests (mock data) + 4 live tests (real Netlify blobs) all pass
Code Review — PR #51Overall: Strong optimization — reducing API calls from 8+ to 1 in flat markets is a meaningful improvement. The Issues
Strengths
Generated by Claude Code |
|
Comparator might not be the best use case here - reviewing later. Let's implement for another use case |
Summary
Implements a drift-comparator layer that conditionally fetches market data only when needed, reducing API calls from 8+ per cycle to 1 in flat markets.
Verification