From fcaec7d8385ef5bbc9c4ef4140e40613f2c322a1 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 28 Jun 2019 16:11:38 +0800 Subject: [PATCH] [Mod] add filter for wrong data format in on_depth --- vnpy/gateway/hbdm/hbdm_gateway.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vnpy/gateway/hbdm/hbdm_gateway.py b/vnpy/gateway/hbdm/hbdm_gateway.py index 9c786ec8..743ae2a0 100644 --- a/vnpy/gateway/hbdm/hbdm_gateway.py +++ b/vnpy/gateway/hbdm/hbdm_gateway.py @@ -1021,14 +1021,19 @@ class HbdmDataWebsocketApi(HbdmWebsocketApiBase): ws_symbol = data["ch"].split(".")[1] tick = self.ticks[ws_symbol] tick.datetime = datetime.fromtimestamp(data["ts"] / 1000) + + tick_data = data["tick"] + if "bids" not in tick_data or "asks" not in tick_data: + print(data) + return - bids = data["tick"]["bids"] + 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))