kraken: handle `.spot.kraken` new-style FQMEs

After #520 we've moved to better supporting explicit venues for cex
backends which is important where a provider offers both spot and
derivatives markets (kraken, binance, kucoin) and we need to distinguish
which is being traded given a common asset pair (eg. BTC/USDT). So, make
this work for `kraken`'s brokerd such that requests and pre-existing
live order are (un)packed to/from EMS messaging form.
basic_buy_bot
Tyler Goodlet 2023-06-22 15:28:20 -04:00
parent 3fcf44aa52
commit f7f76137ca
1 changed files with 4 additions and 6 deletions

View File

@ -136,10 +136,8 @@ async def handle_order_requests(
and deliver acks or errors.
'''
# XXX: UGH, let's unify this.. with ``msgspec``.
msg: dict[str, Any]
order: BrokerdOrder
# XXX: UGH, let's unify this.. with ``msgspec``!!!
msg: dict | Order
async for msg in ems_order_stream:
log.info(f'Rx order msg:\n{pformat(msg)}')
match msg:
@ -227,7 +225,7 @@ async def handle_order_requests(
# XXX strip any .<venue> token which should
# ONLY ever be '.spot' rn, until we support
# futes.
bs_fqme: str = order.symbol.rstrip('.spot')
bs_fqme: str = order.symbol.replace('.spot', '')
psym: str = bs_fqme.upper()
pair: str = f'{psym[:3]}/{psym[3:]}'
@ -891,7 +889,7 @@ async def handle_order_updates(
ids.inverse.get(reqid) is None
):
# parse out existing live order
fqme = pair.replace('/', '').lower()
fqme = pair.replace('/', '').lower() + '.spot'
price = float(price)
size = float(vol)