From 9a063ccb11620226bc7b8b237fe143675a5bb52a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 24 May 2023 09:11:24 -0400 Subject: [PATCH] ib: Solve lingering bugs for non-vlm contracts Contract matching in live setup was borked; switch to `MktPair.dst.atype` matching, don't override the `cmdty` "venue" (a weird special case) in `get_mkt_info()` otherwise lookup will fail.. --- piker/brokers/ib/feed.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index fb896624..b4edae17 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -803,7 +803,11 @@ async def get_mkt_info( init_info: dict = {} atype = _asset_type_map[con.secType] - venue = con.primaryExchange or con.exchange + if atype == 'commodity': + venue: str = 'cmdty' + else: + venue = con.primaryExchange or con.exchange + price_tick: Decimal = Decimal(str(details.minTick)) if atype == 'stock': @@ -918,12 +922,12 @@ async def stream_quotes( # it might be outside regular trading hours so see if we can at # least grab history. if ( - isnan(first_ticker.last) - and type(first_ticker.contract) not in ( - ibis.Commodity, - ibis.Forex, - ibis.Crypto, - ) + isnan(first_ticker.last) # last quote price value is nan + and mkt.dst.atype not in { + 'commodity', + 'forex', + 'crypto', + } ): task_status.started((init_msgs, first_quote))