diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index 28054da4..69450f82 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -69,9 +69,9 @@ from .api import ( Contract, RequestError, ) +from .venues import is_venue_open from ._util import ( data_reset_hack, - is_current_time_in_range, ) from .symbols import get_mkt_info @@ -203,7 +203,8 @@ async def open_history_client( latency = time.time() - query_start if ( not timedout - # and latency <= max_timeout + # and + # latency <= max_timeout ): count += 1 mean += latency / count @@ -219,8 +220,10 @@ async def open_history_client( ) if ( end_dt - and head_dt - and end_dt <= head_dt + and + head_dt + and + end_dt <= head_dt ): raise DataUnavailable( f'First timestamp is {head_dt}\n' @@ -278,7 +281,7 @@ async def open_history_client( start_dt ): # TODO! rm this once we're more confident it never hits! - breakpoint() + # breakpoint() raise RuntimeError( f'OHLC-bars array start is gt `start_dt` limit !!\n' f'start_dt: {start_dt}\n' @@ -298,7 +301,7 @@ async def open_history_client( # TODO: it seems like we can do async queries for ohlc # but getting the order right still isn't working and I'm not # quite sure why.. needs some tinkering and probably - # a lookthrough of the ``ib_insync`` machinery, for eg. maybe + # a lookthrough of the `ib_insync` machinery, for eg. maybe # we have to do the batch queries on the `asyncio` side? yield ( get_hist, @@ -421,14 +424,13 @@ _failed_resets: int = 0 async def get_bars( - proxy: MethodProxy, fqme: str, timeframe: int, # blank to start which tells ib to look up the latest datum - end_dt: str = '', - start_dt: str|None = '', + end_dt: datetime|None = None, + start_dt: datetime|None = None, # TODO: make this more dynamic based on measured frame rx latency? # how long before we trigger a feed reset (seconds) @@ -482,7 +484,8 @@ async def get_bars( dt_duration, ) = await proxy.bars( fqme=fqme, - # XXX TODO! lol we're not using this.. + # XXX TODO! LOL we're not using this and IB dun + # support it anyway.. # start_dt=start_dt, end_dt=end_dt, sample_period_s=timeframe, @@ -734,7 +737,7 @@ async def _setup_quote_stream( # '294', # Trade rate / minute # '295', # Vlm rate / minute ), - contract: Contract | None = None, + contract: Contract|None = None, ) -> trio.abc.ReceiveChannel: ''' @@ -756,7 +759,12 @@ async def _setup_quote_stream( # XXX since this is an `asyncio.Task`, we must use # tractor.pause_from_sync() - caccount_name, client = get_preferred_data_client(accts2clients) + ( + _account_name, + client, + ) = get_preferred_data_client( + accts2clients, + ) contract = ( contract or @@ -1091,14 +1099,9 @@ async def stream_quotes( ) # is venue active rn? - venue_is_open: bool = any( - is_current_time_in_range( - start_dt=sesh.start, - end_dt=sesh.end, - ) - for sesh in details.tradingSessions() + venue_is_open: bool = is_venue_open( + con_deats=details, ) - init_msg = FeedInit(mkt_info=mkt) # NOTE, tell sampler (via config) to skip vlm summing for dst