fix: preserve OHLCV stale detection
This commit is contained in:
@@ -130,9 +130,34 @@ async def test_empty_fetch_with_stale_history_reports_stale(session):
|
||||
]
|
||||
await svc.fetch_and_ingest(session, MockMarketDataProvider(ohlcv_data=old), "SATS")
|
||||
|
||||
result = await svc.fetch_and_ingest(session, MockMarketDataProvider(ohlcv_data=[]), "SATS")
|
||||
# Incremental overlap means Alpaca can keep returning the final historical
|
||||
# bar. That is still stale: the latest session did not advance.
|
||||
result = await svc.fetch_and_ingest(
|
||||
session,
|
||||
MockMarketDataProvider(ohlcv_data=[old[-1]]),
|
||||
"SATS",
|
||||
)
|
||||
|
||||
assert result.status == "stale"
|
||||
assert result.records_ingested == 0
|
||||
assert result.records_ingested == 1
|
||||
assert result.last_date is not None
|
||||
assert "renamed" in (result.message or "").lower() or "halted" in (result.message or "").lower()
|
||||
|
||||
|
||||
async def test_ingest_can_skip_sr_refresh_when_scanner_follows(session, monkeypatch):
|
||||
await _add_ticker(session, "SCAN")
|
||||
calls: list[str] = []
|
||||
|
||||
async def fake_refresh(db, symbol):
|
||||
calls.append(symbol)
|
||||
|
||||
monkeypatch.setattr(svc, "_refresh_structural_sr", fake_refresh)
|
||||
result = await svc.fetch_and_ingest(
|
||||
session,
|
||||
MockMarketDataProvider(ohlcv_data=_bars("SCAN", 3)),
|
||||
"SCAN",
|
||||
refresh_sr=False,
|
||||
)
|
||||
|
||||
assert result.status == "complete"
|
||||
assert calls == []
|
||||
|
||||
Reference in New Issue
Block a user