diff --git a/piker/brokers/ib/broker.py b/piker/brokers/ib/broker.py index 11f43a6f..3638d6d6 100644 --- a/piker/brokers/ib/broker.py +++ b/piker/brokers/ib/broker.py @@ -64,7 +64,8 @@ from piker.clearing._messages import ( from piker.data._source import Symbol from .api import ( _accounts2clients, - _adhoc_futes_set, + # _adhoc_futes_set, + _adhoc_symbol_map, log, get_config, open_client_proxies, @@ -87,15 +88,23 @@ def pack_position( # TODO: lookup fqsn even for derivs. symbol = con.symbol.lower() + # try our best to figure out the exchange / venue exch = (con.primaryExchange or con.exchange).lower() - fqsn = '.'.join((symbol, exch)) if not exch: - # attempt to lookup the symbol from our - # hacked set.. - for sym in _adhoc_futes_set: - if symbol in sym: - fqsn = sym - break + # for wtv cucked reason some futes don't show their + # exchange (like CL.NYMEX) ... + entry = _adhoc_symbol_map.get( + con.symbol or con.localSymbol + ) + if entry: + meta, kwargs = entry + cid = meta.get('conId') + if cid: + assert con.conId == meta['conId'] + exch = meta['exchange'] + + assert exch, f'No clue:\n {con}' + fqsn = '.'.join((symbol, exch)) expiry = con.lastTradeDateOrContractMonth if expiry: