CTA引擎处理行情tick时,增加对异常数据的捕捉和过滤

This commit is contained in:
vn.py 2017-07-09 21:11:00 +08:00
parent a26cb7e09d
commit 08fc156595
2 changed files with 11 additions and 6 deletions

View File

@ -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申请"
}

View File

@ -254,9 +254,14 @@ 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]