From 5dc9a61ec4e25a55bb6f6ac6d16cedb76f393b26 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 10 Jul 2022 15:44:52 -0400 Subject: [PATCH] Use cancel level logging for cancelled orders --- piker/clearing/_ems.py | 3 +++ piker/clearing/_messages.py | 1 + piker/ui/order_mode.py | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/piker/clearing/_ems.py b/piker/clearing/_ems.py index 57b044ad..5f08cfa5 100644 --- a/piker/clearing/_ems.py +++ b/piker/clearing/_ems.py @@ -702,6 +702,9 @@ async def translate_and_relay_brokerd_events( # a live flow now exists oid = entry.oid + # TODO: instead this should be our status set. + # ack, open, fill, closed, cancelled' + resp = None broker_details = {} diff --git a/piker/clearing/_messages.py b/piker/clearing/_messages.py index e5813c78..c30ada54 100644 --- a/piker/clearing/_messages.py +++ b/piker/clearing/_messages.py @@ -186,6 +186,7 @@ class BrokerdStatus(Struct): # XXX: should be best effort set for every update account: str = '' + # TODO: instead (ack, pending, open, fill, clos(ed), cancelled) # { # 'submitted', # 'cancelled', diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index ce08a64c..d7db1bee 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -843,16 +843,25 @@ async def process_trades_and_update_ui( # resp to 'cancel' request or error condition # for action request elif resp in ( - 'broker_cancelled', 'broker_inactive', 'broker_errored', + ): + # delete level line from view + mode.on_cancel(oid) + broker_msg = msg['brokerd_msg'] + log.error( + f'Order {oid}->{resp} with:\n{pformat(broker_msg)}' + ) + + elif resp in ( + 'broker_cancelled', 'dark_cancelled' ): # delete level line from view mode.on_cancel(oid) broker_msg = msg['brokerd_msg'] - log.warning( - f'Order {oid} failed with:\n{pformat(broker_msg)}' + log.cancel( + f'Order {oid}->{resp} with:\n{pformat(broker_msg)}' ) elif resp in (