Send init message with kraken

basic_orders
Tyler Goodlet 2021-01-22 22:55:49 -05:00
parent 10e47e349c
commit b4a4f12aa4
1 changed files with 15 additions and 2 deletions

View File

@ -312,11 +312,13 @@ async def stream_quotes(
get_console_log(loglevel or tractor.current_actor().loglevel)
ws_pairs = {}
sym_infos = {}
async with get_client() as client:
# keep client cached for real-time section
for sym in symbols:
ws_pairs[sym] = (await client.symbol_info(sym))['wsname']
si = sym_infos[sym] = await client.symbol_info(sym)
ws_pairs[sym] = si['wsname']
# maybe load historical ohlcv in to shared mem
# check if shm has already been created by previous
@ -340,7 +342,18 @@ async def stream_quotes(
delay_s = times[-1] - times[times != times[-1]][-1]
subscribe_ohlc_for_increment(shm, delay_s)
yield shm_token, not writer_exists
# yield shm_token, not writer_exists
init_msgs = {
# pass back token, and bool, signalling if we're the writer
# and that history has been written
symbol: {
'is_shm_writer': not writer_exists,
'shm_token': shm_token,
'symbol_info': sym_infos[symbol],
}
for sym in symbols
}
yield init_msgs
while True:
try: