From af9c30c3f5dfb5db22051c276c6cdff79d071184 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 13 Nov 2022 18:18:33 -0500 Subject: [PATCH 1/3] Handle futes venue remaps as per oct-nov 2022 rollout --- piker/brokers/ib/api.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/piker/brokers/ib/api.py b/piker/brokers/ib/api.py index 9448d1f6..2e1409fb 100644 --- a/piker/brokers/ib/api.py +++ b/piker/brokers/ib/api.py @@ -167,35 +167,35 @@ _futes_venues = ( _adhoc_futes_set = { # equities - 'nq.globex', - 'mnq.globex', # micro + 'nq.cme', + 'mnq.cme', # micro - 'es.globex', - 'mes.globex', # micro + 'es.cme', + 'mes.cme', # micro # cypto$ - 'brr.cmecrypto', - 'ethusdrr.cmecrypto', + 'brr.cme', + 'ethusdrr.cme', # agriculture - 'he.nymex', # lean hogs - 'le.nymex', # live cattle (geezers) - 'gf.nymex', # feeder cattle (younguns) + 'he.comex', # lean hogs + 'le.comex', # live cattle (geezers) + 'gf.comex', # feeder cattle (younguns) # raw - 'lb.nymex', # random len lumber + 'lb.comex', # random len lumber # metals # https://misc.interactivebrokers.com/cstools/contract_info/v3.10/index.php?action=Conid%20Info&wlId=IB&conid=69067924 'xauusd.cmdty', # london gold spot ^ - 'gc.nymex', - 'mgc.nymex', # micro + 'gc.comex', + 'mgc.comex', # micro # oil & gas - 'cl.nymex', + 'cl.comex', 'xagusd.cmdty', # silver spot - 'ni.nymex', # silver futes + 'ni.comex', # silver futes 'qi.comex', # mini-silver futes } From a0ce9ecc0d651d155388ad3acfefb1e390dd41a5 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 17 Nov 2022 13:32:25 -0500 Subject: [PATCH 2/3] Only append con suffix if not empty --- piker/brokers/ib/api.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/piker/brokers/ib/api.py b/piker/brokers/ib/api.py index 2e1409fb..16fbe5e1 100644 --- a/piker/brokers/ib/api.py +++ b/piker/brokers/ib/api.py @@ -1031,7 +1031,7 @@ def con2fqsn( case ibis.Forex() | ibis.Contract(secType='CASH'): dst, src = con.localSymbol.split('.') symbol = ''.join([dst, src]) - suffix = con.exchange + suffix = con.exchange or 'idealpro' # no real volume on forex feeds.. calc_price = True @@ -1053,7 +1053,10 @@ def con2fqsn( if expiry: suffix += f'.{expiry}' - fqsn_key = '.'.join((symbol, suffix)).lower() + fqsn_key = symbol.lower() + if suffix: + fqsn_key = '.'.join((fqsn_key, suffix)).lower() + _cache[con.conId] = fqsn_key, calc_price return fqsn_key, calc_price From 243d0329f604606188997b6ddb241813b0d7ecf7 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 17 Nov 2022 13:34:21 -0500 Subject: [PATCH 3/3] Client.get_head_time()` seems unsupported for forex? --- piker/brokers/ib/feed.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index 53910f38..e15e8462 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -130,7 +130,12 @@ async def open_history_client( mean: float = 0 count: int = 0 - head_dt = await proxy.get_head_time(fqsn=fqsn) + head_dt: None | datetime = None + if ( + # fx cons seem to not provide this endpoint? + 'idealpro' not in fqsn + ): + head_dt = await proxy.get_head_time(fqsn=fqsn) async def get_hist( timeframe: float, @@ -170,7 +175,9 @@ async def open_history_client( ) if ( - end_dt and end_dt <= head_dt + end_dt + and head_dt + and end_dt <= head_dt ): raise DataUnavailable(f'First timestamp is {head_dt}') @@ -895,7 +902,9 @@ async def stream_quotes( # last = time.time() async for ticker in stream: quote = normalize(ticker) - await send_chan.send({quote['fqsn']: quote}) + fqsn = quote['fqsn'] + # print(f'sending {fqsn}:\n{quote}') + await send_chan.send({fqsn: quote}) # ugh, clear ticks since we've consumed them ticker.ticks = []