From 1776242413c2c7cba44208330de963ffbc8ad39b Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 27 Jan 2026 17:37:25 -0500 Subject: [PATCH] .ib.feed: trim bars frame to `start_dt` --- piker/brokers/ib/feed.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index 4bb3c44d..14803144 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -269,16 +269,25 @@ async def open_history_client( and first_dt < start_dt ): - bars_array = bars_array[ + trimmed_bars = 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' - ) + if ( + trimmed_first_dt := from_timestamp(trimmed_bars['time'][0]) + != + start_dt + ): + # 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'first_dt: {first_dt}\n' + f'trimmed_first_dt: {trimmed_first_dt}\n' + ) + + # XXX, overwrite with start_dt-limited frame + bars_array = trimmed_bars return ( bars_array,