From 0aef762d9ab2b6ab31d85bf39f3ef77c5dbd3888 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 12 Sep 2022 13:24:23 -0400 Subject: [PATCH 1/3] Bleh `kraken`, fix another ref error in fill block Clearly, the linter didn't help us here.. but, just pass the `brokerd` time for now in the `.broker_time` field; we can't get it from the fill-case incremental updates in the `openOrders` sub. Add some notes about this and how we might approach for backends with this limitation. --- piker/brokers/kraken/broker.py | 2 +- piker/ui/order_mode.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/piker/brokers/kraken/broker.py b/piker/brokers/kraken/broker.py index ca32da7e..503833db 100644 --- a/piker/brokers/kraken/broker.py +++ b/piker/brokers/kraken/broker.py @@ -1024,7 +1024,7 @@ async def handle_order_updates( # TODO: maybe capture more msg data # i.e fees? broker_details={'name': 'kraken'} | order_msg, - broker_time=broker_time + broker_time=time.time(), ) await ems_stream.send(fill_msg) diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index ee484bf3..f83787ec 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -985,7 +985,19 @@ async def process_trade_msg( pointing='up' if action == 'buy' else 'down', # TODO: put the actual exchange timestamp - arrow_index=get_index(details['broker_time']), + arrow_index=get_index( + # TODO: note currently the ``kraken`` openOrders sub + # doesn't deliver their engine timestamp as part of + # it's schema, so this value is **not** from them + # (see our backend code). We should probably either + # include all provider-engine timestamps in the + # summary 'closed' status msg and/or figure out + # a way to indicate what is a `brokerd` stamp versus + # a true backend one? This will require finagling + # with how each backend tracks/summarizes time + # stamps for the downstream API. + details['broker_time'] + ), ) # TODO: how should we look this up? From b9d5b904f448861eff0db94d28e69faa10c6bf7c Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 12 Sep 2022 15:42:27 -0400 Subject: [PATCH 2/3] Drop order entry removals on modify --- piker/clearing/_paper_engine.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/piker/clearing/_paper_engine.py b/piker/clearing/_paper_engine.py index dadbbdfd..772defa8 100644 --- a/piker/clearing/_paper_engine.py +++ b/piker/clearing/_paper_engine.py @@ -98,8 +98,6 @@ class PaperBoi(Struct): Place an order and return integer request id provided by client. ''' - is_modify: bool = False - if action == 'alert': # bypass all fill simulation return reqid @@ -108,7 +106,6 @@ class PaperBoi(Struct): if entry: # order is already existing, this is a modify (oid, symbol, action, old_price) = entry - is_modify = True else: # register order internally self._reqids[reqid] = (oid, symbol, action, price) @@ -152,25 +149,18 @@ class PaperBoi(Struct): oid, ) + # register this submissions as a paper live order else: - # register this submissions as a paper live order - - # submit order to book simulation fill loop + # set the simulated order in the respective table for lookup + # and trigger by the simulated clearing task normally + # running ``simulate_fills()``. if action == 'buy': orders = self._buys elif action == 'sell': orders = self._sells - # set the simulated order in the respective table for lookup - # and trigger by the simulated clearing task normally - # running ``simulate_fills()``. - - if is_modify: - # remove any existing order for the old price - orders[symbol].pop(oid) - - # buys/sells: {symbol -> bidict[oid, ()]} + # {symbol -> bidict[oid, ()]} orders[symbol][oid] = (price, size, reqid, action) return reqid From 4a9c16d298fe9c2bb714b23bf791dc9591201f73 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 12 Sep 2022 13:43:42 -0400 Subject: [PATCH 3/3] Fix stream type annot --- piker/clearing/_paper_engine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piker/clearing/_paper_engine.py b/piker/clearing/_paper_engine.py index 772defa8..b74780f5 100644 --- a/piker/clearing/_paper_engine.py +++ b/piker/clearing/_paper_engine.py @@ -287,7 +287,7 @@ class PaperBoi(Struct): async def simulate_fills( - quote_stream: 'tractor.ReceiveStream', # noqa + quote_stream: tractor.MsgStream, # noqa client: PaperBoi, ) -> None: