From d5e5cfc1c90eb6d425729c12324981783361ef5a Mon Sep 17 00:00:00 2001 From: chenxy123 Date: Sat, 8 Apr 2017 10:42:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0tick=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E5=9B=9E=E6=B5=8B=E6=92=AE=E5=90=88=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=AF=B9=E4=BA=8E=E6=B6=A8=E8=B7=8C=E5=81=9C=E7=9A=84?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/ctaStrategy/ctaBacktesting.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vn.trader/ctaStrategy/ctaBacktesting.py b/vn.trader/ctaStrategy/ctaBacktesting.py index f4601de5..a480e094 100644 --- a/vn.trader/ctaStrategy/ctaBacktesting.py +++ b/vn.trader/ctaStrategy/ctaBacktesting.py @@ -322,8 +322,13 @@ class BacktestingEngine(object): # 遍历限价单字典中的所有限价单 for orderID, order in self.workingLimitOrderDict.items(): # 判断是否会成交 - buyCross = order.direction==DIRECTION_LONG and order.price>=buyCrossPrice - sellCross = order.direction==DIRECTION_SHORT and order.price<=sellCrossPrice + buyCross = (order.direction==DIRECTION_LONG and + order.price>=buyCrossPrice and + buyCrossPrice > 0) # 国内的tick行情在涨停时askPrice1为0,此时买无法成交 + + sellCross = (order.direction==DIRECTION_SHORT and + order.price<=sellCrossPrice and + sellCrossPrice > 0) # 国内的tick行情在跌停时bidPrice1为0,此时卖无法成交 # 如果发生了成交 if buyCross or sellCross: