From 91fdc7c5c7d371411f49fa33362c5c4ee01a68c1 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 11 Aug 2022 14:20:23 -0400 Subject: [PATCH] Load boxed `.req` values as `Order`s in mode loop --- piker/ui/order_mode.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index 4e8d9e66..cecb8787 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -163,7 +163,6 @@ class OrderMode: ) -> LevelLine: level = order.price - print(f'SIZE: {order.size}') line = order_line( self.chart, @@ -859,7 +858,7 @@ async def process_trade_msg( get_index = mode.chart.get_index fmsg = pformat(msg) - log.info(f'Received order msg:\n{fmsg}') + log.debug(f'Received order msg:\n{fmsg}') name = msg['name'] if name in ( @@ -920,6 +919,7 @@ async def process_trade_msg( ): dialog = mode.load_unknown_dialog_from_msg(msg) mode.on_submit(oid) + # return dialog, msg case Status(resp='error'): # delete level line from view @@ -932,16 +932,15 @@ async def process_trade_msg( case Status(resp='canceled'): # delete level line from view mode.on_cancel(oid) - req = msg.req - log.cancel( - f'Canceled order {oid}:\n{pformat(req)}' - ) + req = Order(**msg.req) + log.cancel(f'Canceled {req.action}:{oid}') case Status( resp='triggered', # req=Order(exec_mode='dark') # TODO: req={'exec_mode': 'dark'}, ): + # TODO: UX for a "pending" clear/live order log.info(f'Dark order triggered for {fmsg}') case Status( @@ -951,13 +950,14 @@ async def process_trade_msg( ): # should only be one "fill" for an alert # add a triangle and remove the level line + req = Order(**req) mode.on_fill( oid, price=req.price, arrow_index=get_index(time.time()), ) mode.lines.remove_line(uuid=oid) - msg.req = Order(**req) + msg.req = req await mode.on_exec(oid, msg) # response to completed 'dialog' for order request @@ -966,18 +966,18 @@ async def process_trade_msg( # req=Order() as req, # TODO req=req, ): - # right now this is just triggering a system alert msg.req = Order(**req) await mode.on_exec(oid, msg) mode.lines.remove_line(uuid=oid) # each clearing tick is responded individually case Status(resp='fill'): + + # handle out-of-piker fills reporting? known_order = book._sent_orders.get(oid) if not known_order: log.warning(f'order {oid} is unknown') return - # continue action = known_order.action details = msg.brokerd_msg