Catch too-early ib hist frames

For now by REPLing them and raising an RTE inside `.ib.feed` as well as
tracing any such cases that make it (from other providers) up to the
`.tsp._history` layer during null-segment backfilling.
multiaddrs
Gud Boi 2026-01-27 13:17:28 -05:00
parent ff502b62bf
commit 4081336bd3
2 changed files with 35 additions and 4 deletions

View File

@ -178,8 +178,8 @@ async def open_history_client(
async def get_hist( async def get_hist(
timeframe: float, timeframe: float,
end_dt: datetime | None = None, end_dt: datetime|None = None,
start_dt: datetime | None = None, start_dt: datetime|None = None,
) -> tuple[np.ndarray, str]: ) -> tuple[np.ndarray, str]:
@ -262,7 +262,29 @@ async def open_history_client(
vlm = bars_array['volume'] vlm = bars_array['volume']
vlm[vlm < 0] = 0 vlm[vlm < 0] = 0
return bars_array, first_dt, last_dt # XXX, if a start-limit was passed ensure we only
# return history that far back!
if (
start_dt
and
last_dt < start_dt
):
bars_array = bars_array[
bars_array['time'] >= start_dt.timestamp()
]
# TODO! rm this once we're more confident it never hits!
breakpoint()
raise RuntimeError(
f'OHLC-bars array start is gt `start_dt` limit !!\n'
f'start_dt: {start_dt}\n'
f'last_dt: {last_dt}\n'
)
return (
bars_array,
first_dt,
last_dt,
)
# TODO: it seems like we can do async queries for ohlc # TODO: it seems like we can do async queries for ohlc
# but getting the order right still isn't working and I'm not # but getting the order right still isn't working and I'm not
@ -397,7 +419,7 @@ async def get_bars(
# blank to start which tells ib to look up the latest datum # blank to start which tells ib to look up the latest datum
end_dt: str = '', end_dt: str = '',
start_dt: str | None = '', start_dt: str|None = '',
# TODO: make this more dynamic based on measured frame rx latency? # TODO: make this more dynamic based on measured frame rx latency?
# how long before we trigger a feed reset (seconds) # how long before we trigger a feed reset (seconds)
@ -451,6 +473,8 @@ async def get_bars(
dt_duration, dt_duration,
) = await proxy.bars( ) = await proxy.bars(
fqme=fqme, fqme=fqme,
# XXX TODO! lol we're not using this..
# start_dt=start_dt,
end_dt=end_dt, end_dt=end_dt,
sample_period_s=timeframe, sample_period_s=timeframe,

View File

@ -242,6 +242,13 @@ async def maybe_fill_null_segments(
end_dt=end_dt, end_dt=end_dt,
) )
if (
from_timestamp(
array['time'][0]
) < backfill_until_dt
):
await tractor.pause()
# XXX TODO: pretty sure if i plot tsla, btcusdt.binance # XXX TODO: pretty sure if i plot tsla, btcusdt.binance
# and mnq.cme.ib this causes a Qt crash XXDDD # and mnq.cme.ib this causes a Qt crash XXDDD