Compare commits
2 Commits
c4bcc19241
...
ab217e247f
| Author | SHA1 | Date |
|---|---|---|
|
|
ab217e247f | |
|
|
e14a607bfc |
|
|
@ -283,7 +283,7 @@ async def get_candles(
|
||||||
timeframe: str = Query(..., description="Candle timeframe (e.g., 5m, 1h)"),
|
timeframe: str = Query(..., description="Candle timeframe (e.g., 5m, 1h)"),
|
||||||
start: Optional[int] = Query(None, description="Start timestamp (Unix seconds)"),
|
start: Optional[int] = Query(None, description="Start timestamp (Unix seconds)"),
|
||||||
end: Optional[int] = Query(None, description="End timestamp (Unix seconds)"),
|
end: Optional[int] = Query(None, description="End timestamp (Unix seconds)"),
|
||||||
limit: Optional[int] = Query(100, description="Maximum candles to return", le=1000),
|
limit: Optional[int] = Query(None, description="Maximum candles to return (omit for all)", le=10000),
|
||||||
session_id: Optional[str] = Query(
|
session_id: Optional[str] = Query(
|
||||||
None,
|
None,
|
||||||
description="Optional session ID for per-session exchange credentials",
|
description="Optional session ID for per-session exchange credentials",
|
||||||
|
|
|
||||||
|
|
@ -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