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,