From 588770d0346baad93d4e4fda634639ae8af9363a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 22 May 2023 12:00:13 -0400 Subject: [PATCH] ib: rename lingering fqsn -> fqme --- piker/brokers/ib/api.py | 16 ++++++++-------- piker/brokers/ib/broker.py | 14 +++++++------- piker/brokers/ib/feed.py | 7 ++++--- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/piker/brokers/ib/api.py b/piker/brokers/ib/api.py index e64f085f..8636ddd2 100644 --- a/piker/brokers/ib/api.py +++ b/piker/brokers/ib/api.py @@ -500,7 +500,7 @@ class Client: # nested dataclass we probably don't need and that won't # IPC serialize.. d.secIdList = '' - key, calc_price = con2fqsn(d.contract) + key, calc_price = con2fqme(d.contract) details[key] = d return details @@ -656,7 +656,7 @@ class Client: self._cons[conid] = con return con - def parse_patt2fqsn( + def parse_patt2fqme( self, pattern: str, @@ -721,7 +721,7 @@ class Client: ) -> Contract: if pattern is not None: - symbol, currency, exch, expiry = self.parse_patt2fqsn( + symbol, currency, exch, expiry = self.parse_patt2fqme( pattern, ) sectype = '' @@ -1074,7 +1074,7 @@ class Client: return self.ib.positions(account=account) -def con2fqsn( +def con2fqme( con: Contract, _cache: dict[int, (str, bool)] = {} @@ -1140,12 +1140,12 @@ def con2fqsn( if expiry: suffix += f'.{expiry}' - fqsn_key = symbol.lower() + fqme_key = symbol.lower() if suffix: - fqsn_key = '.'.join((fqsn_key, suffix)).lower() + fqme_key = '.'.join((fqme_key, suffix)).lower() - _cache[con.conId] = fqsn_key, calc_price - return fqsn_key, calc_price + _cache[con.conId] = fqme_key, calc_price + return fqme_key, calc_price # per-actor API ep caching diff --git a/piker/brokers/ib/broker.py b/piker/brokers/ib/broker.py index 25a82ef3..800baed7 100644 --- a/piker/brokers/ib/broker.py +++ b/piker/brokers/ib/broker.py @@ -81,7 +81,7 @@ from piker.accounting import ( ) from .api import ( _accounts2clients, - con2fqsn, + con2fqme, log, get_config, open_client_proxies, @@ -100,7 +100,7 @@ def pack_position( ]: con = pos.contract - fqsn, calc_price = con2fqsn(con) + fqme, calc_price = con2fqme(con) # TODO: options contracts into a sane format.. return ( @@ -108,7 +108,7 @@ def pack_position( BrokerdPosition( broker='ib', account=pos.account, - symbol=fqsn, + symbol=fqme, currency=con.currency, size=float(pos.position), 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 # 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 # to be a bit tricky though? deats = await proxy.con_deats(contracts=[con]) - fqsn = list(deats)[0] + fqme = list(deats)[0] reqid = order.orderId @@ -490,7 +490,7 @@ async def aggr_open_orders( action=action, exec_mode='live', oid=str(reqid), - symbol=fqsn, + symbol=fqme, account=accounts_def.inverse[order.account], price=order.lmtPrice, size=size, @@ -1224,7 +1224,7 @@ def norm_trade_records( elif asset_type == 'STK': asset_type: str = 'stock' - # try to build out piker fqsn from record. + # try to build out piker fqme from record. expiry = ( record.get('lastTradeDateOrContractMonth') or record.get('expiry') diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index 28db4eee..b13e963a 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -50,7 +50,7 @@ from .._util import ( ) from .api import ( # _adhoc_futes_set, - con2fqsn, + con2fqme, log, load_aio_clients, ibis, @@ -708,7 +708,7 @@ def normalize( # check for special contract types con = ticker.contract - fqme, calc_price = con2fqsn(con) + fqme, calc_price = con2fqme(con) # convert named tuples to dicts so we send usable keys new_ticks = [] @@ -823,7 +823,8 @@ async def get_mkt_info( # then we'll get a `MNQUSD` request for history data.. # we need to figure out how we're going to handle this (later?) # but likely we want all backends to eventually handle - # ``dst/src.venue.`` style? + # ``dst/src.venue.`` style !? + # src=Asset( # name=str(con.currency), # atype='fiat',