Skip to content

Commit

Permalink
kraken: handle .spot.kraken new-style FQMEs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
goodboy committed Jun 22, 2023
1 parent 398cba0 commit 4710e10
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions piker/brokers/kraken/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:]}'

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 4710e10

Please sign in to comment.