From adb62dc7b49c45812c8c36b0649e65b3bf987405 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 18 Apr 2023 19:12:14 -0400 Subject: [PATCH] Port oustanding parts of codebase to `unpack_fqme()` --- piker/brokers/ib/api.py | 15 ++++++++++++--- piker/ui/_app.py | 4 ++-- piker/ui/_position.py | 6 +++--- piker/ui/order_mode.py | 5 ++++- tests/test_ems.py | 2 +- tests/test_feeds.py | 4 ++-- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/piker/brokers/ib/api.py b/piker/brokers/ib/api.py index 3d77ee6d..0914dea4 100644 --- a/piker/brokers/ib/api.py +++ b/piker/brokers/ib/api.py @@ -676,8 +676,8 @@ class Client: # fqsn parsing stage # ------------------ if '.ib' in pattern: - from ..accounting._mktinfo import unpack_fqsn - _, symbol, expiry = unpack_fqsn(pattern) + from ..accounting._mktinfo import unpack_fqme + _, symbol, venue, expiry = unpack_fqme(pattern) else: symbol = pattern @@ -857,8 +857,17 @@ class Client: self, symbol: str, - ) -> tuple[Contract, Ticker, ContractDetails]: + ) -> tuple[ + Contract, + Ticker, + ContractDetails, + ]: + ''' + Get summary (meta) data for a given symbol str including + ``Contract`` and its details and a (first snapshot of the) + ``Ticker``. + ''' contract = (await self.find_contracts(symbol))[0] ticker: Ticker = self.ib.reqMktData( contract, diff --git a/piker/ui/_app.py b/piker/ui/_app.py index 0e7dad47..a1e31a6e 100644 --- a/piker/ui/_app.py +++ b/piker/ui/_app.py @@ -28,7 +28,7 @@ from ..service import maybe_spawn_brokerd from . import _event from ._exec import run_qtractor from ..data.feed import install_brokerd_search -from ..accounting._mktinfo import unpack_fqsn +from ..accounting._mktinfo import unpack_fqme from . import _search from ._chart import GodWidget from ..log import get_logger @@ -101,7 +101,7 @@ async def _async_main( needed_brokermods: dict[str, ModuleType] = {} for fqsn in syms: - brokername, *_ = unpack_fqsn(fqsn) + brokername, *_ = unpack_fqme(fqsn) needed_brokermods[brokername] = brokers[brokername] async with ( diff --git a/piker/ui/_position.py b/piker/ui/_position.py index 56659056..f08e234a 100644 --- a/piker/ui/_position.py +++ b/piker/ui/_position.py @@ -14,10 +14,10 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -""" -Position info and display +''' +Position (pos) info and display to track ur PnLz B) -""" +''' from __future__ import annotations from copy import copy from dataclasses import dataclass diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index 578babc2..1a54aa5c 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -1002,7 +1002,10 @@ async def process_trade_msg( ) tracker = mode.trackers[msg['account']] tracker.live_pp.update_from_msg(msg) - tracker.update_from_pp(set_as_startup=True) # status/pane UI + tracker.update_from_pp( + set_as_startup=True, + ) + # status/pane UI mode.pane.update_status_ui(tracker) if tracker.live_pp.size: diff --git a/tests/test_ems.py b/tests/test_ems.py index 378c2690..8b8d3600 100644 --- a/tests/test_ems.py +++ b/tests/test_ems.py @@ -79,7 +79,7 @@ async def order_and_and_wait_for_ppmsg( ''' sent: list[Order] = [] - broker, key, suffix = unpack_fqme(fqme) + broker, mktep, venue, suffix = unpack_fqme(fqme) order = Order( exec_mode=exec_mode, diff --git a/tests/test_feeds.py b/tests/test_feeds.py index 0f88ce5f..df854a79 100644 --- a/tests/test_feeds.py +++ b/tests/test_feeds.py @@ -15,7 +15,7 @@ from piker.data import ( ) from piker.data.flows import Flume from piker.accounting._mktinfo import ( - unpack_fqsn, + unpack_fqme, ) @@ -54,7 +54,7 @@ def test_multi_fqsn_feed( brokers = set() for fqme in fqmes: - brokername, key, suffix = unpack_fqsn(fqme) + brokername, *_ = unpack_fqme(fqme) brokers.add(brokername) async def main():