Extract min tick info from symbol data
parent
165d6257fa
commit
9cad59366f
|
@ -288,11 +288,21 @@ class AggTrade(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
async def stream_messages(ws):
|
async def stream_messages(ws):
|
||||||
|
|
||||||
|
timeouts = 0
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
with trio.move_on_after(5):
|
with trio.move_on_after(5) as cs:
|
||||||
msg = await ws.recv_msg()
|
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
|
# for l1 streams binance doesn't add an event type field so
|
||||||
# identify those messages by matching keys
|
# identify those messages by matching keys
|
||||||
# https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-book-ticker-streams
|
# 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
|
# keep client cached for real-time section
|
||||||
cache = await client.cache_symbols()
|
cache = await client.cache_symbols()
|
||||||
|
|
||||||
for sym in symbols:
|
for sym in symbols:
|
||||||
d = cache[sym.upper()]
|
d = cache[sym.upper()]
|
||||||
syminfo = Pair(**d) # validation
|
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]
|
symbol = symbols[0]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue