From 4c0f2099aa197e43d23524f8eb4a4d32fab27d1e Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 3 Jul 2022 11:19:33 -0400 Subject: [PATCH] Send fill msg first --- piker/brokers/kraken/broker.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/piker/brokers/kraken/broker.py b/piker/brokers/kraken/broker.py index 63ab7fa0..1cf4e9fe 100644 --- a/piker/brokers/kraken/broker.py +++ b/piker/brokers/kraken/broker.py @@ -385,6 +385,21 @@ async def trades_dialogue( size = float(msg['vol']) broker_time = float(msg['time']) + # send a fill msg for gui update + fill_msg = BrokerdFill( + reqid=reqid, + time_ns=time.time_ns(), + + action=action, + size=size, + price=price, + # TODO: maybe capture more msg data + # i.e fees? + broker_details={'name': 'kraken'}, + broker_time=broker_time + ) + + await ems_stream.send(fill_msg.dict()) filled_msg = BrokerdStatus( reqid=reqid, time_ns=time.time_ns(), @@ -409,22 +424,6 @@ async def trades_dialogue( ) await ems_stream.send(filled_msg.dict()) - # send a fill msg for gui update - fill_msg = BrokerdFill( - reqid=reqid, - time_ns=time.time_ns(), - - action=action, - size=size, - price=price, - # TODO: maybe capture more msg data - # i.e fees? - broker_details={'name': 'kraken'}, - broker_time=broker_time - ) - - await ems_stream.send(fill_msg.dict()) - case _: log.warning(f'Unhandled trades msg: {msg}') await tractor.breakpoint()