Fix SINCE mode requests returning wrong data
When requesting candles with start date but no end date (SINCE mode), EDM was skipping gap processing entirely because gap_end was None. This caused requests to return cached data clipped to the most recent N candles, ignoring the requested start date. Fix: Normalize gaps with end=None to use current time, so SINCE mode requests properly fetch data from the requested start time to now. Bug symptoms: - Request start=2026-03-01, limit=100 - Got 100 candles starting from 2026-03-04 (most recent 100) - Expected 100 candles starting from 2026-03-01 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c4bcc19241
commit
e14a607bfc
|
|
@ -189,6 +189,20 @@ class CacheManager:
|
||||||
source = "exchange" if exchange_candles else "memory"
|
source = "exchange" if exchange_candles else "memory"
|
||||||
return result, source
|
return result, source
|
||||||
|
|
||||||
|
# Step 2b: Handle SINCE mode (start provided, no end)
|
||||||
|
# Gaps with end=None need to be fetched from exchange directly
|
||||||
|
import time as time_module
|
||||||
|
now = int(time_module.time())
|
||||||
|
normalized_gaps = []
|
||||||
|
for gap_start, gap_end in gaps_to_fill:
|
||||||
|
if gap_start is not None and gap_end is None:
|
||||||
|
# SINCE mode: fetch from start to now
|
||||||
|
normalized_gaps.append((gap_start, now))
|
||||||
|
elif gap_start is not None and gap_end is not None:
|
||||||
|
normalized_gaps.append((gap_start, gap_end))
|
||||||
|
# Skip gaps where start is None (shouldn't happen with proper request)
|
||||||
|
gaps_to_fill = normalized_gaps if normalized_gaps else gaps_to_fill
|
||||||
|
|
||||||
db_hit = False
|
db_hit = False
|
||||||
exchange_hit = False
|
exchange_hit = False
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue