From 069466218e867bf750715dcb8370a31eda6ce7c4 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 22 Mar 2023 10:40:48 -0400 Subject: [PATCH] Use `str(cmd.symbol)` for fqme on cancels, add `_nowait()` method names --- piker/clearing/_client.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/piker/clearing/_client.py b/piker/clearing/_client.py index 01196f41..cbf5add9 100644 --- a/piker/clearing/_client.py +++ b/piker/clearing/_client.py @@ -64,7 +64,7 @@ class OrderBook(Struct): _from_order_book: trio.abc.ReceiveChannel _sent_orders: dict[str, Order] = {} - def send( + def send_nowait( self, msg: Order | dict, @@ -73,6 +73,15 @@ class OrderBook(Struct): self._to_ems.send_nowait(msg) return msg + # TODO: make this an async version.. + def send( + self, + msg: Order | dict, + + ) -> dict: + log.warning('USE `.send_nowait()` instead!') + return self.send_nowait(msg) + def send_update( self, @@ -86,10 +95,14 @@ class OrderBook(Struct): self._to_ems.send_nowait(msg) return cmd - def cancel(self, uuid: str) -> bool: - """Cancel an order (or alert) in the EMS. + def cancel_nowait( + self, + uuid: str, + ) -> bool: + ''' + Cancel an order (or alert) in the EMS. - """ + ''' cmd = self._sent_orders.get(uuid) if not cmd: log.error( @@ -97,12 +110,21 @@ class OrderBook(Struct): f'Maybe there is a stale entry or line?\n' f'You should report this as a bug!' ) + fqme = str(cmd.symbol) msg = Cancel( oid=uuid, - symbol=cmd.symbol, + symbol=fqme, ) self._to_ems.send_nowait(msg) + # TODO: make this an async version.. + def cancel( + self, + uuid: str, + ) -> bool: + log.warning('USE `.cancel_nowait()` instead!') + return self.cancel_nowait(uuid) + _orders: OrderBook = None