`kraken`: use `Client.mkt_info()` in quotes feed init msg

pre_overruns_ctxcancelled
Tyler Goodlet 2023-03-20 20:04:42 -04:00
parent d6634e9b02
commit 28f52dae93
1 changed files with 18 additions and 18 deletions

View File

@ -35,6 +35,9 @@ from trio_util import trio_async_generator
import tractor import tractor
import trio import trio
from piker.accounting._mktinfo import (
MktPair,
)
from piker._cacheables import open_cached_client from piker._cacheables import open_cached_client
from piker.brokers._util import ( from piker.brokers._util import (
BrokerError, BrokerError,
@ -287,29 +290,26 @@ 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 = {}
sym_infos = {} mkt_infos = {}
async with open_cached_client('kraken') as client, send_chan as send_chan:
async with (
open_cached_client('kraken') as client,
send_chan as send_chan,
):
# 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 # transform to upper since piker style is always lower
sym = sym.upper() sym = sym.upper()
si: Pair = await client.symbol_info(sym) pair: Pair = await client.pair_info(sym)
# try: mkt: MktPair = await client.mkt_info(sym)
# si = Pair(**sym_info) # validation mktinfo = mkt.to_dict()
# except TypeError: mkt_infos[sym] = mktinfo
# fields_diff = set(sym_info) - set(Pair.__struct_fields__)
# raise TypeError( # TODO: remove this once we drop ``Symbol``!!
# f'Missing msg fields {fields_diff}' mktinfo['asset_type'] = mkt.dst.atype
# )
syminfo = si.to_dict() ws_pairs[sym] = pair.wsname
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
symbol = symbols[0].lower() symbol = symbols[0].lower()
@ -317,7 +317,7 @@ async def stream_quotes(
# pass back token, and bool, signalling if we're the writer # pass back token, and bool, signalling if we're the writer
# and that history has been written # and that history has been written
symbol: { symbol: {
'symbol_info': sym_infos[sym], 'symbol_info': mkt_infos[sym],
'shm_write_opts': {'sum_tick_vml': False}, 'shm_write_opts': {'sum_tick_vml': False},
'fqsn': sym, 'fqsn': sym,
}, },