From 998045b7c86d5349581d24e5535b6b2a8bb91771 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 7 Nov 2019 14:27:33 +0800 Subject: [PATCH] [Mod] filter close position order data from web ui --- vnpy/gateway/bitmex/bitmex_gateway.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vnpy/gateway/bitmex/bitmex_gateway.py b/vnpy/gateway/bitmex/bitmex_gateway.py index d57b6ac6..b089e380 100644 --- a/vnpy/gateway/bitmex/bitmex_gateway.py +++ b/vnpy/gateway/bitmex/bitmex_gateway.py @@ -703,9 +703,15 @@ class BitmexWebsocketApi(WebsocketClient): def on_order(self, d): """""" + # Filter order data which cannot be processed properly if "ordStatus" not in d: return + side = d.get("side", "") + if not side: + return + + # Update local order data sysid = d["orderID"] order = self.orders.get(sysid, None) if not order: @@ -714,14 +720,12 @@ class BitmexWebsocketApi(WebsocketClient): else: orderid = sysid - # time = d["timestamp"][11:19] - order = OrderData( symbol=d["symbol"], exchange=Exchange.BITMEX, type=ORDERTYPE_BITMEX2VT[d["ordType"]], orderid=orderid, - direction=DIRECTION_BITMEX2VT[d["side"]], + direction=DIRECTION_BITMEX2VT[side], price=d["price"], volume=d["orderQty"], time=d["timestamp"][11:19],