'`kraken`: finally, use new `MktPair` in `'mkt_info'` init msg field!'

pre_overruns_ctxcancelled
Tyler Goodlet 2023-03-21 22:32:24 -04:00
parent 08b4d69a91
commit 8594a39c61
1 changed files with 14 additions and 18 deletions

View File

@ -290,7 +290,7 @@ async def stream_quotes(
get_console_log(loglevel or tractor.current_actor().loglevel) get_console_log(loglevel or tractor.current_actor().loglevel)
ws_pairs = {} ws_pairs = {}
mkt_infos = {} mkt_infos: dict[str, MktPair] = {}
async with ( async with (
open_cached_client('kraken') as client, open_cached_client('kraken') as client,
@ -299,29 +299,25 @@ async def stream_quotes(
# keep client cached for real-time section # keep client cached for real-time section
for sym in symbols: for sym in symbols:
# transform to upper since piker style is always lower # uppercase since piker style is always lowercase.
sym = sym.upper() sym_str = sym.upper()
pair: Pair = await client.pair_info(sym) pair: Pair = await client.pair_info(sym_str)
mkt: MktPair = await client.mkt_info(sym) mkt: MktPair = await client.mkt_info(sym_str)
mktinfo = mkt.to_dict() mkt_infos[sym_str] = mkt
mkt_infos[sym] = mktinfo
# TODO: remove this once we drop ``Symbol``!! ws_pairs[sym_str] = pair.wsname
mktinfo['asset_type'] = mkt.dst.atype
mktinfo['price_tick_size'] = mkt.price_tick
mktinfo['lot_tick_size'] = mkt.size_tick
ws_pairs[sym] = pair.wsname
symbol = symbols[0].lower() symbol = symbols[0].lower()
# sync with `.data.feed` caller
# TODO: should we make this init msg a `Struct`?
init_msgs = { init_msgs = {
# pass back token, and bool, signalling if we're the writer
# and that history has been written
symbol: { symbol: {
'symbol_info': mkt_infos[sym], 'fqsn': sym_str,
'shm_write_opts': {'sum_tick_vml': False}, 'mkt_info': mkt_infos[sym_str],
'fqsn': sym, 'shm_write_opts': {
'sum_tick_vml': False,
},
}, },
} }