Extract min tick info from symbol data

binance_syminfo_and_mintick
Tyler Goodlet 2021-05-24 22:02:08 -04:00
parent 165d6257fa
commit 9cad59366f
1 changed files with 19 additions and 2 deletions

View File

@ -288,11 +288,21 @@ class AggTrade(BaseModel):
async def stream_messages(ws):
timeouts = 0
while True:
with trio.move_on_after(5):
with trio.move_on_after(5) as cs:
msg = await ws.recv_msg()
if cs.cancelled_caught:
timeouts += 1
if timeouts > 2:
raise trio.TooSlowError("binance feed seems down?")
continue
# for l1 streams binance doesn't add an event type field so
# identify those messages by matching keys
# https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-book-ticker-streams
@ -475,10 +485,17 @@ async def stream_quotes(
# keep client cached for real-time section
cache = await client.cache_symbols()
for sym in symbols:
d = cache[sym.upper()]
syminfo = Pair(**d) # validation
sym_infos[sym] = syminfo.dict()
si = sym_infos[sym] = syminfo.dict()
# XXX: after manually inspecting the response format we
# just directly pick out the info we need
si['price_tick_size'] = syminfo.filters[0]['tickSize']
si['lot_tick_size'] = syminfo.filters[2]['stepSize']
symbol = symbols[0]