ib: rename lingering fqsn -> fqme

master
Tyler Goodlet 2023-05-22 12:00:13 -04:00
parent 2f2d612b5f
commit 588770d034
3 changed files with 19 additions and 18 deletions

View File

@ -500,7 +500,7 @@ class Client:
# nested dataclass we probably don't need and that won't # nested dataclass we probably don't need and that won't
# IPC serialize.. # IPC serialize..
d.secIdList = '' d.secIdList = ''
key, calc_price = con2fqsn(d.contract) key, calc_price = con2fqme(d.contract)
details[key] = d details[key] = d
return details return details
@ -656,7 +656,7 @@ class Client:
self._cons[conid] = con self._cons[conid] = con
return con return con
def parse_patt2fqsn( def parse_patt2fqme(
self, self,
pattern: str, pattern: str,
@ -721,7 +721,7 @@ class Client:
) -> Contract: ) -> Contract:
if pattern is not None: if pattern is not None:
symbol, currency, exch, expiry = self.parse_patt2fqsn( symbol, currency, exch, expiry = self.parse_patt2fqme(
pattern, pattern,
) )
sectype = '' sectype = ''
@ -1074,7 +1074,7 @@ class Client:
return self.ib.positions(account=account) return self.ib.positions(account=account)
def con2fqsn( def con2fqme(
con: Contract, con: Contract,
_cache: dict[int, (str, bool)] = {} _cache: dict[int, (str, bool)] = {}
@ -1140,12 +1140,12 @@ def con2fqsn(
if expiry: if expiry:
suffix += f'.{expiry}' suffix += f'.{expiry}'
fqsn_key = symbol.lower() fqme_key = symbol.lower()
if suffix: if suffix:
fqsn_key = '.'.join((fqsn_key, suffix)).lower() fqme_key = '.'.join((fqme_key, suffix)).lower()
_cache[con.conId] = fqsn_key, calc_price _cache[con.conId] = fqme_key, calc_price
return fqsn_key, calc_price return fqme_key, calc_price
# per-actor API ep caching # per-actor API ep caching

View File

@ -81,7 +81,7 @@ from piker.accounting import (
) )
from .api import ( from .api import (
_accounts2clients, _accounts2clients,
con2fqsn, con2fqme,
log, log,
get_config, get_config,
open_client_proxies, open_client_proxies,
@ -100,7 +100,7 @@ def pack_position(
]: ]:
con = pos.contract con = pos.contract
fqsn, calc_price = con2fqsn(con) fqme, calc_price = con2fqme(con)
# TODO: options contracts into a sane format.. # TODO: options contracts into a sane format..
return ( return (
@ -108,7 +108,7 @@ def pack_position(
BrokerdPosition( BrokerdPosition(
broker='ib', broker='ib',
account=pos.account, account=pos.account,
symbol=fqsn, symbol=fqme,
currency=con.currency, currency=con.currency,
size=float(pos.position), size=float(pos.position),
avg_price=float(pos.avgCost) / float(con.multiplier or 1.0), avg_price=float(pos.avgCost) / float(con.multiplier or 1.0),
@ -468,11 +468,11 @@ async def aggr_open_orders(
# TODO: in the case of the SMART venue (aka ib's # TODO: in the case of the SMART venue (aka ib's
# router-clearing sys) we probably should handle # router-clearing sys) we probably should handle
# showing such orders overtop of the fqsn for the # showing such orders overtop of the fqme for the
# primary exchange, how to map this easily is going # primary exchange, how to map this easily is going
# to be a bit tricky though? # to be a bit tricky though?
deats = await proxy.con_deats(contracts=[con]) deats = await proxy.con_deats(contracts=[con])
fqsn = list(deats)[0] fqme = list(deats)[0]
reqid = order.orderId reqid = order.orderId
@ -490,7 +490,7 @@ async def aggr_open_orders(
action=action, action=action,
exec_mode='live', exec_mode='live',
oid=str(reqid), oid=str(reqid),
symbol=fqsn, symbol=fqme,
account=accounts_def.inverse[order.account], account=accounts_def.inverse[order.account],
price=order.lmtPrice, price=order.lmtPrice,
size=size, size=size,
@ -1224,7 +1224,7 @@ def norm_trade_records(
elif asset_type == 'STK': elif asset_type == 'STK':
asset_type: str = 'stock' asset_type: str = 'stock'
# try to build out piker fqsn from record. # try to build out piker fqme from record.
expiry = ( expiry = (
record.get('lastTradeDateOrContractMonth') record.get('lastTradeDateOrContractMonth')
or record.get('expiry') or record.get('expiry')

View File

@ -50,7 +50,7 @@ from .._util import (
) )
from .api import ( from .api import (
# _adhoc_futes_set, # _adhoc_futes_set,
con2fqsn, con2fqme,
log, log,
load_aio_clients, load_aio_clients,
ibis, ibis,
@ -708,7 +708,7 @@ def normalize(
# check for special contract types # check for special contract types
con = ticker.contract con = ticker.contract
fqme, calc_price = con2fqsn(con) fqme, calc_price = con2fqme(con)
# convert named tuples to dicts so we send usable keys # convert named tuples to dicts so we send usable keys
new_ticks = [] new_ticks = []
@ -823,7 +823,8 @@ async def get_mkt_info(
# then we'll get a `MNQUSD` request for history data.. # then we'll get a `MNQUSD` request for history data..
# we need to figure out how we're going to handle this (later?) # we need to figure out how we're going to handle this (later?)
# but likely we want all backends to eventually handle # but likely we want all backends to eventually handle
# ``dst/src.venue.`` style? # ``dst/src.venue.`` style !?
# src=Asset( # src=Asset(
# name=str(con.currency), # name=str(con.currency),
# atype='fiat', # atype='fiat',