From 28f52dae931331d80137e06f548b260452592655 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 20 Mar 2023 20:04:42 -0400 Subject: [PATCH] `kraken`: use `Client.mkt_info()` in quotes feed init msg --- piker/brokers/kraken/feed.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/piker/brokers/kraken/feed.py b/piker/brokers/kraken/feed.py index b8228a55..ae42485e 100644 --- a/piker/brokers/kraken/feed.py +++ b/piker/brokers/kraken/feed.py @@ -35,6 +35,9 @@ from trio_util import trio_async_generator import tractor import trio +from piker.accounting._mktinfo import ( + MktPair, +) from piker._cacheables import open_cached_client from piker.brokers._util import ( BrokerError, @@ -287,29 +290,26 @@ async def stream_quotes( get_console_log(loglevel or tractor.current_actor().loglevel) ws_pairs = {} - sym_infos = {} - - async with open_cached_client('kraken') as client, send_chan as send_chan: + mkt_infos = {} + async with ( + open_cached_client('kraken') as client, + send_chan as send_chan, + ): # keep client cached for real-time section for sym in symbols: # transform to upper since piker style is always lower sym = sym.upper() - si: Pair = await client.symbol_info(sym) - # try: - # si = Pair(**sym_info) # validation - # except TypeError: - # fields_diff = set(sym_info) - set(Pair.__struct_fields__) - # raise TypeError( - # f'Missing msg fields {fields_diff}' - # ) - syminfo = si.to_dict() - syminfo['price_tick_size'] = 1. / 10**si.pair_decimals - syminfo['lot_tick_size'] = 1. / 10**si.lot_decimals - syminfo['asset_type'] = 'crypto' - sym_infos[sym] = syminfo - ws_pairs[sym] = si.wsname + pair: Pair = await client.pair_info(sym) + mkt: MktPair = await client.mkt_info(sym) + mktinfo = mkt.to_dict() + mkt_infos[sym] = mktinfo + + # TODO: remove this once we drop ``Symbol``!! + mktinfo['asset_type'] = mkt.dst.atype + + ws_pairs[sym] = pair.wsname symbol = symbols[0].lower() @@ -317,7 +317,7 @@ async def stream_quotes( # pass back token, and bool, signalling if we're the writer # and that history has been written symbol: { - 'symbol_info': sym_infos[sym], + 'symbol_info': mkt_infos[sym], 'shm_write_opts': {'sum_tick_vml': False}, 'fqsn': sym, },