[Mod] add filter for wrong data format in on_depth

This commit is contained in:
vn.py 2019-06-28 16:11:38 +08:00
parent 07ed1c44ac
commit fcaec7d838

View File

@ -1022,13 +1022,18 @@ class HbdmDataWebsocketApi(HbdmWebsocketApiBase):
tick = self.ticks[ws_symbol]
tick.datetime = datetime.fromtimestamp(data["ts"] / 1000)
bids = data["tick"]["bids"]
tick_data = data["tick"]
if "bids" not in tick_data or "asks" not in tick_data:
print(data)
return
bids = tick_data["bids"]
for n in range(5):
price, volume = bids[n]
tick.__setattr__("bid_price_" + str(n + 1), float(price))
tick.__setattr__("bid_volume_" + str(n + 1), float(volume))
asks = data["tick"]["asks"]
asks = tick_data["asks"]
for n in range(5):
price, volume = asks[n]
tick.__setattr__("ask_price_" + str(n + 1), float(price))