From b6df83a0e9ef864cc3d31e8b88f40f7fa363146d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 21 Mar 2023 22:28:26 -0400 Subject: [PATCH] Typecast `OrderMode.staged.symbol: str` before `.copy()`! --- piker/ui/order_mode.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index e6c4ed33..3125fefe 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -349,12 +349,22 @@ class OrderMode: ''' if not order: staged: Order = self._staged_order + # apply order fields for ems oid = str(uuid.uuid4()) - order = staged.copy() - order.oid = oid - order.symbol = order.symbol.fqme + # we have to copy and slap in the `MktPair` first + # since we can't cast to it without being mega explicit + # with `msgspec.Struct`, which we're not yet.. + fqme = staged.symbol + if not isinstance(fqme, str): + mkt = staged.symbol.copy() + fqme = mkt.fqme + staged.symbol = fqme + + order = staged.copy() + order.symbol = fqme + order.oid = oid lines = self.lines_from_order( order,