From 08fc1565956d6155f10f44eadae9ddc6c5137e50 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sun, 9 Jul 2017 21:11:00 +0800 Subject: [PATCH] =?UTF-8?q?CTA=E5=BC=95=E6=93=8E=E5=A4=84=E7=90=86?= =?UTF-8?q?=E8=A1=8C=E6=83=85tick=E6=97=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9=E5=BC=82=E5=B8=B8=E6=95=B0=E6=8D=AE=E7=9A=84=E6=8D=95?= =?UTF-8?q?=E6=8D=89=E5=92=8C=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/VnTrader/CTP_connect.json | 4 ++-- vnpy/trader/app/ctaStrategy/ctaEngine.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/VnTrader/CTP_connect.json b/examples/VnTrader/CTP_connect.json index 1b4d5a42..e4bfa6b8 100644 --- a/examples/VnTrader/CTP_connect.json +++ b/examples/VnTrader/CTP_connect.json @@ -2,6 +2,6 @@ "brokerID": "9999", "mdAddress": "tcp://180.168.146.187:10011", "tdAddress": "tcp://180.168.146.187:10001", - "userID": "000300", - "password": "19890624" + "userID": "simnow申请", + "password": "simnow申请" } \ No newline at end of file diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index cca62f6e..edc34197 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -254,10 +254,15 @@ class CtaEngine(object): # 推送tick到对应的策略实例进行处理 if tick.vtSymbol in self.tickStrategyDict: - # 添加datetime字段 - if not tick.datetime: - tick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S.%f') - + # tick时间可能出现异常数据,使用try...except实现捕捉和过滤 + try: + # 添加datetime字段 + if not tick.datetime: + tick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S.%f') + except ValueError: + self.writeCtaLog(traceback.format_exc()) + return + # 逐个推送到策略实例中 l = self.tickStrategyDict[tick.vtSymbol] for strategy in l: