From bc7fe6114d61c850d9c48980daa1e223b504aa85 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 24 Nov 2022 15:04:16 -0500 Subject: [PATCH] Adjust order mode to use `Flume.get_index()` --- piker/ui/order_mode.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index 7e4ae066..c7b3cc59 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -930,7 +930,6 @@ async def process_trade_msg( ) -> tuple[Dialog, Status]: - get_index = mode.chart.get_index fmsg = pformat(msg) log.debug(f'Received order msg:\n{fmsg}') name = msg['name'] @@ -965,6 +964,9 @@ async def process_trade_msg( oid = msg.oid dialog: Dialog = mode.dialogs.get(oid) + fqsn = dialog.symbol.front_fqsn() + flume = mode.feed.flumes[fqsn] + match msg: case Status( resp='dark_open' | 'open', @@ -1034,10 +1036,11 @@ async def process_trade_msg( # should only be one "fill" for an alert # add a triangle and remove the level line req = Order(**req) + index = flume.get_index(time.time()) mode.on_fill( oid, price=req.price, - arrow_index=get_index(time.time()), + arrow_index=index, ) mode.lines.remove_line(uuid=oid) msg.req = req @@ -1065,26 +1068,27 @@ async def process_trade_msg( action = order.action details = msg.brokerd_msg + # TODO: put the actual exchange timestamp? + # NOTE: currently the ``kraken`` openOrders sub + # doesn't deliver their engine timestamp as part of + # it's schema, so this value is **not** from them + # (see our backend code). We should probably either + # include all provider-engine timestamps in the + # summary 'closed' status msg and/or figure out + # a way to indicate what is a `brokerd` stamp versus + # a true backend one? This will require finagling + # with how each backend tracks/summarizes time + # stamps for the downstream API. + index = flume.get_index( + details['broker_time'] + ) + # TODO: some kinda progress system mode.on_fill( oid, price=details['price'], + arrow_index=index, pointing='up' if action == 'buy' else 'down', - - # TODO: put the actual exchange timestamp - arrow_index=get_index( - # TODO: note currently the ``kraken`` openOrders sub - # doesn't deliver their engine timestamp as part of - # it's schema, so this value is **not** from them - # (see our backend code). We should probably either - # include all provider-engine timestamps in the - # summary 'closed' status msg and/or figure out - # a way to indicate what is a `brokerd` stamp versus - # a true backend one? This will require finagling - # with how each backend tracks/summarizes time - # stamps for the downstream API. - details['broker_time'] - ), ) # TODO: append these fill events to the position's clear