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 piker.data._source import Symbol
from .api import ( from .api import (
_accounts2clients, _accounts2clients,
_adhoc_futes_set, # _adhoc_futes_set,
_adhoc_symbol_map,
log, log,
get_config, get_config,
open_client_proxies, open_client_proxies,
@ -87,15 +88,23 @@ def pack_position(
# TODO: lookup fqsn even for derivs. # TODO: lookup fqsn even for derivs.
symbol = con.symbol.lower() symbol = con.symbol.lower()
# try our best to figure out the exchange / venue
exch = (con.primaryExchange or con.exchange).lower() exch = (con.primaryExchange or con.exchange).lower()
fqsn = '.'.join((symbol, exch))
if not exch: if not exch:
# attempt to lookup the symbol from our # for wtv cucked reason some futes don't show their
# hacked set.. # exchange (like CL.NYMEX) ...
for sym in _adhoc_futes_set: entry = _adhoc_symbol_map.get(
if symbol in sym: con.symbol or con.localSymbol
fqsn = sym )
break 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 expiry = con.lastTradeDateOrContractMonth
if expiry: if expiry: