Merge pull request #399 from pikers/kraken_fill_bugs

Kraken fill bugs
tractor_core_port
goodboy 2022-09-12 20:12:04 -04:00 committed by GitHub
commit f2c488c1e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 18 deletions

View File

@ -1024,7 +1024,7 @@ async def handle_order_updates(
# TODO: maybe capture more msg data # TODO: maybe capture more msg data
# i.e fees? # i.e fees?
broker_details={'name': 'kraken'} | order_msg, broker_details={'name': 'kraken'} | order_msg,
broker_time=broker_time broker_time=time.time(),
) )
await ems_stream.send(fill_msg) await ems_stream.send(fill_msg)

View File

@ -98,8 +98,6 @@ class PaperBoi(Struct):
Place an order and return integer request id provided by client. Place an order and return integer request id provided by client.
''' '''
is_modify: bool = False
if action == 'alert': if action == 'alert':
# bypass all fill simulation # bypass all fill simulation
return reqid return reqid
@ -108,7 +106,6 @@ class PaperBoi(Struct):
if entry: if entry:
# order is already existing, this is a modify # order is already existing, this is a modify
(oid, symbol, action, old_price) = entry (oid, symbol, action, old_price) = entry
is_modify = True
else: else:
# register order internally # register order internally
self._reqids[reqid] = (oid, symbol, action, price) self._reqids[reqid] = (oid, symbol, action, price)
@ -152,25 +149,18 @@ class PaperBoi(Struct):
oid, oid,
) )
# register this submissions as a paper live order
else: else:
# register this submissions as a paper live order # set the simulated order in the respective table for lookup
# and trigger by the simulated clearing task normally
# submit order to book simulation fill loop # running ``simulate_fills()``.
if action == 'buy': if action == 'buy':
orders = self._buys orders = self._buys
elif action == 'sell': elif action == 'sell':
orders = self._sells orders = self._sells
# set the simulated order in the respective table for lookup # {symbol -> bidict[oid, (<price data>)]}
# 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, (<price data>)]}
orders[symbol][oid] = (price, size, reqid, action) orders[symbol][oid] = (price, size, reqid, action)
return reqid return reqid
@ -297,7 +287,7 @@ class PaperBoi(Struct):
async def simulate_fills( async def simulate_fills(
quote_stream: 'tractor.ReceiveStream', # noqa quote_stream: tractor.MsgStream, # noqa
client: PaperBoi, client: PaperBoi,
) -> None: ) -> None:

View File

@ -985,7 +985,19 @@ async def process_trade_msg(
pointing='up' if action == 'buy' else 'down', pointing='up' if action == 'buy' else 'down',
# TODO: put the actual exchange timestamp # 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? # TODO: how should we look this up?