From 076fc5ed473bc0b0a57bbf5316761434cf0845c7 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 3 Feb 2018 23:29:48 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=E5=A2=9E=E5=8A=A0WebTrader=E7=9A=84?= =?UTF-8?q?=E5=85=A8=E6=92=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/WebTrader/run.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/examples/WebTrader/run.py b/examples/WebTrader/run.py index c43f08ac..37ca9859 100644 --- a/examples/WebTrader/run.py +++ b/examples/WebTrader/run.py @@ -140,6 +140,7 @@ class Order(Resource): self.deleteParser = reqparse.RequestParser() self.deleteParser.add_argument('vtOrderID') self.deleteParser.add_argument('token') + self.deleteParser.add_argument('cancelAll') super(Order, self).__init__() @@ -193,18 +194,32 @@ class Order(Resource): if token != TOKEN: return None - vtOrderID = args['vtOrderID'] + cancelAll = args['cancelAll'] - order = me.getOrder(vtOrderID) - if not order: - return False + # 单一撤单 + if not cancelAll: + vtOrderID = args['vtOrderID'] + + order = me.getOrder(vtOrderID) + if not order: + return False + + req = VtCancelOrderReq() + req.orderID = order.orderID + req.exchange = order.exchange + req.symbol = order.symbol + me.cancelOrder(req, order.gatewayName) + # 全撤 + else: + l = me.getAllWorkingOrders() + + for order in l: + req = VtCancelOrderReq() + req.orderID = order.orderID + req.exchange = order.exchange + req.symbol = order.symbol + me.cancelOrder(req, order.gatewayName) - req = VtCancelOrderReq() - req.orderID = order.orderID - req.exchange = order.exchange - req.symbol = order.symbol - me.cancelOrder(req, order.gatewayName) - ######################################################################## class Trade(Resource):