From be3dc69290c8363155994656040cb58b5abc116c Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 14 Nov 2022 17:06:48 -0500 Subject: [PATCH] Only update pnl label on quotes with an fqsn match --- piker/ui/_position.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/piker/ui/_position.py b/piker/ui/_position.py index 98584161..6eb1d962 100644 --- a/piker/ui/_position.py +++ b/piker/ui/_position.py @@ -80,9 +80,9 @@ async def update_pnl_from_feed( ''' global _pnl_tasks - pp = order_mode.current_pp - live = pp.live_pp - key = live.symbol.front_fqsn() + pp: PositionTracker = order_mode.current_pp + live: Position = pp.live_pp + key: str = live.symbol.front_fqsn() log.info(f'Starting pnl display for {pp.alloc.account}') @@ -101,12 +101,18 @@ async def update_pnl_from_feed( async with flume.stream.subscribe() as bstream: # last_tick = time.time() async for quotes in bstream: - # now = time.time() # period = now - last_tick for sym, quote in quotes.items(): + # TODO: uggggh we probably want a better state + # management then this sincce we want to enable + # updating whatever the current symbol is in + # real-time right? + if sym != key: + continue + for tick in iterticks(quote, types): # print(f'{1/period} Hz') @@ -119,6 +125,7 @@ async def update_pnl_from_feed( else: # compute and display pnl status + # print(f'formatting PNL {sym}: {quote}') order_mode.pane.pnl_label.format( pnl=copysign(1, size) * pnl( # live.ppu,