From 55ee5ea9b15ddbc03ba5761dbc19ba0f21725a05 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 24 Dec 2018 09:39:49 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]TradeCopy=E6=A8=A1=E5=9D=97=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8B=92=E5=8D=95=E7=9B=91=E6=8E=A7=EF=BC=8CClose=20#?= =?UTF-8?q?1274?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/tradeCopy/tcEngine.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/app/tradeCopy/tcEngine.py b/vnpy/trader/app/tradeCopy/tcEngine.py index c82abf98..a123b3de 100644 --- a/vnpy/trader/app/tradeCopy/tcEngine.py +++ b/vnpy/trader/app/tradeCopy/tcEngine.py @@ -4,10 +4,12 @@ from collections import defaultdict from vnpy.event import Event from vnpy.rpc import RpcClient, RpcServer -from vnpy.trader.vtEvent import EVENT_POSITION, EVENT_TRADE, EVENT_TIMER +from vnpy.trader.vtEvent import (EVENT_POSITION, EVENT_TRADE, + EVENT_TIMER, EVENT_ORDER) from vnpy.trader.vtConstant import (DIRECTION_LONG, DIRECTION_SHORT, OFFSET_OPEN, OFFSET_CLOSE, PRICETYPE_LIMITPRICE, - OFFSET_CLOSEYESTERDAY, OFFSET_CLOSETODAY) + OFFSET_CLOSEYESTERDAY, OFFSET_CLOSETODAY, + STATUS_REJECTED) from vnpy.trader.vtObject import VtOrderReq, VtCancelOrderReq, VtLogData, VtSubscribeReq @@ -86,6 +88,7 @@ class TcEngine(object): self.eventEngine.register(EVENT_POSITION, self.processPositionEvent) self.eventEngine.register(EVENT_TRADE, self.processTradeEvent) self.eventEngine.register(EVENT_TIMER, self.processTimerEvent) + self.eventEngine.register(EVENT_ORDER, self.processOrderEvent) #---------------------------------------------------------------------- def checkAndTrade(self, vtSymbol): @@ -130,6 +133,14 @@ class TcEngine(object): position = event.dict_['data'] self.posDict[position.vtPositionName] = position.position + #---------------------------------------------------------------------- + def processOrderEvent(self, event): + """""" + order = event.dict_['data'] + if order.status == STATUS_REJECTED: + self.writeLog(u'监控到委托拒单,停止运行') + self.stop() + #---------------------------------------------------------------------- def publishPos(self, vtPositionName): """"""