Unpack existing live order params in case statement

open_order_loading
Tyler Goodlet 2022-08-11 23:02:33 -04:00
parent f6ba95a6c7
commit 665bb183f7
1 changed files with 35 additions and 31 deletions

View File

@ -739,12 +739,44 @@ async def handle_order_updates(
f'{pformat(order_msg)}' f'{pformat(order_msg)}'
) )
txid, update_msg = list(order_msg.items())[0] txid, update_msg = list(order_msg.items())[0]
# XXX: eg. of full msg schema:
# {'avg_price': _,
# 'cost': _,
# 'descr': {
# 'close': None,
# 'leverage': None,
# 'order': descr,
# 'ordertype': 'limit',
# 'pair': 'XMR/EUR',
# 'price': '74.94000000',
# 'price2': '0.00000000',
# 'type': 'buy'
# },
# 'expiretm': None,
# 'fee': '0.00000000',
# 'limitprice': '0.00000000',
# 'misc': '',
# 'oflags': 'fciq',
# 'opentm': '1656966131.337344',
# 'refid': None,
# 'starttm': None,
# 'stopprice': '0.00000000',
# 'timeinforce': 'GTC',
# 'vol': submit_vlm, # '13.34400854',
# 'vol_exec': exec_vlm} # 0.0000
match update_msg: match update_msg:
# EMS-unknown live order that needs to be # EMS-unknown live order that needs to be
# delivered and loaded on the client-side. # delivered and loaded on the client-side.
case { case {
'userref': reqid, 'userref': reqid,
'descr': {
'pair': pair,
'price': price,
'type': action,
},
'vol': vol,
# during a fill this field is **not** # during a fill this field is **not**
# provided! but, it is always avail on # provided! but, it is always avail on
@ -755,12 +787,9 @@ async def handle_order_updates(
ids.inverse.get(reqid) is None ids.inverse.get(reqid) is None
): ):
# parse out existing live order # parse out existing live order
descr = rest['descr'] fqsn = pair.replace('/', '').lower()
fqsn = descr['pair'].replace( price = float(price)
'/', '').lower() size = float(vol)
price = float(descr['price'])
size = float(rest['vol'])
action = descr['type']
# register the userref value from # register the userref value from
# kraken (usually an `int` staring # kraken (usually an `int` staring
@ -792,31 +821,6 @@ async def handle_order_updates(
await ems_stream.send(status_msg) await ems_stream.send(status_msg)
continue continue
# XXX: eg. of full msg schema:
# {'avg_price': _,
# 'cost': _,
# 'descr': {
# 'close': None,
# 'leverage': None,
# 'order': descr,
# 'ordertype': 'limit',
# 'pair': 'XMR/EUR',
# 'price': '74.94000000',
# 'price2': '0.00000000',
# 'type': 'buy'
# },
# 'expiretm': None,
# 'fee': '0.00000000',
# 'limitprice': '0.00000000',
# 'misc': '',
# 'oflags': 'fciq',
# 'opentm': '1656966131.337344',
# 'refid': None,
# 'starttm': None,
# 'stopprice': '0.00000000',
# 'timeinforce': 'GTC',
# 'vol': submit_vlm, # '13.34400854',
# 'vol_exec': exec_vlm} # 0.0000
case { case {
'userref': reqid, 'userref': reqid,