From 35e8e518627e1f8209218ed637705a11093a3395 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Thu, 27 Oct 2016 16:16:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9C=E5=B8=82=E7=9A=84=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E6=97=A5=E6=9C=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/ctaAlgo/ctaEngine.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/vn.trader/ctaAlgo/ctaEngine.py b/vn.trader/ctaAlgo/ctaEngine.py index 2672fab4..00e35b5d 100644 --- a/vn.trader/ctaAlgo/ctaEngine.py +++ b/vn.trader/ctaAlgo/ctaEngine.py @@ -314,23 +314,15 @@ class CtaEngine(object): if key != 'datetime': d[key] = tick.__getattribute__(key) - # 5.添加datetime字段 ctaTick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S.%f') - # 修正,交易日期不一定是OpenDate - dt = datetime.now() - if ctaTick.datetime > dt and (ctaTick.datetime - dt).seconds > 100: + # 5.添加datetime字段 + if ctaTick.datetime.hour >= 20: + dt = datetime.now() today = dt.strftime('%Y%m%d') - if today != ctaTick.date: - # 当前日期不等于交易日,ctaTick.date修正为当日,保留ctaTick.tradingDay - self.writeCtaLog(u'fix tick{0},{1}'.format(ctaTick.datetime.strftime(' %Y%m%d %H:%M:%S.%f'), dt.strftime('%Y%m%d %H:%M:%S.%f'))) - ctaTick.date = today - # 重新计算时间 - ctaTick.datetime = datetime.strptime(' '.join([ctaTick.date, ctaTick.time]), '%Y%m%d %H:%M:%S.%f') - else: - # 修正出现偏差的时间 - ctaTick.datetime = dt - self.writeCtaLog(u'fix 修正出现偏差的时间') + ctaTick.datetime = datetime.strptime(' '.join([today, tick.time]), '%Y%m%d %H:%M:%S.%f') + ctaTick.date = today + # 逐个推送到策略实例中 l = self.tickStrategyDict[tick.vtSymbol]