From defec19912800ee5297c08081cd79ca6b1d027fa Mon Sep 17 00:00:00 2001 From: chenxy123 Date: Tue, 7 Mar 2017 22:34:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DTargetPosTemplate=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/ctaAlgo/ctaTemplate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vn.trader/ctaAlgo/ctaTemplate.py b/vn.trader/ctaAlgo/ctaTemplate.py index fe60370b..f113108d 100644 --- a/vn.trader/ctaAlgo/ctaTemplate.py +++ b/vn.trader/ctaAlgo/ctaTemplate.py @@ -219,8 +219,9 @@ class TargetPosTemplate(CtaTemplate): """收到行情推送""" self.lastTick = tick - # 实盘模式下,需要根据tick的实时推送执行自动开平仓操作 - self.trade() + # 实盘模式下,启动交易后,需要根据tick的实时推送执行自动开平仓操作 + if self.trading: + self.trade() #---------------------------------------------------------------------- def onBar(self, bar): @@ -246,6 +247,7 @@ class TargetPosTemplate(CtaTemplate): # 先撤销之前的委托 for vtOrderID in self.orderList: self.cancelOrder(vtOrderID) + self.orderList = [] # 如果目标仓位和实际仓位一致,则不进行任何操作 posChange = self.targetPos - self.pos