From ecd93cb05a6d7d3dff21f4476a3ab39aebd636c8 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 21 Aug 2022 22:22:38 -0400 Subject: [PATCH] Pass symbol with broker suffix to `.submit_limit()`; fix clearing --- piker/clearing/_paper_engine.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/piker/clearing/_paper_engine.py b/piker/clearing/_paper_engine.py index 2936ff59..54b05dfd 100644 --- a/piker/clearing/_paper_engine.py +++ b/piker/clearing/_paper_engine.py @@ -325,10 +325,10 @@ async def simulate_fills( # dark order price filter(s) types=('ask', 'bid', 'trade', 'last') ): - # print(tick) match tick: case { 'price': tick_price, + # 'type': ('ask' | 'trade' | 'last'), 'type': 'ask', }: client.last_ask = ( @@ -345,6 +345,7 @@ async def simulate_fills( case { 'price': tick_price, + # 'type': ('bid' | 'trade' | 'last'), 'type': 'bid', }: client.last_bid = ( @@ -364,14 +365,17 @@ async def simulate_fills( 'price': tick_price, 'type': ('trade' | 'last'), }: - # TODO: simulate actual book queues and our orders - # place in it, might require full L2 data? + # TODO: simulate actual book queues and our + # orders place in it, might require full L2 + # data? continue # iterate book prices descending for oid, our_price in book_sequence: - if pred(our_price): - + # print(tick) + # print((sym, list(book_sequence), client._buys, client._sells)) + clearable = pred(our_price) + if clearable: # retreive order info (size, reqid, action) = orders.pop((oid, our_price)) @@ -428,7 +432,7 @@ async def handle_order_requests( # call our client api to submit the order reqid = await client.submit_limit( oid=order.oid, - symbol=order.symbol, + symbol=f'{order.symbol}.{client.broker}', price=order.price, action=order.action, size=order.size,