Use new adhoc sym map for symbols without exchange tags (usually futes)

lifo_pps_ib
Tyler Goodlet 2022-06-23 20:19:43 -04:00
parent fa89207583
commit d6c32bba86
1 changed files with 17 additions and 8 deletions

View File

@ -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: