CTA引擎处理行情tick时,增加对异常数据的捕捉和过滤
This commit is contained in:
parent
a26cb7e09d
commit
08fc156595
@ -2,6 +2,6 @@
|
|||||||
"brokerID": "9999",
|
"brokerID": "9999",
|
||||||
"mdAddress": "tcp://180.168.146.187:10011",
|
"mdAddress": "tcp://180.168.146.187:10011",
|
||||||
"tdAddress": "tcp://180.168.146.187:10001",
|
"tdAddress": "tcp://180.168.146.187:10001",
|
||||||
"userID": "000300",
|
"userID": "simnow申请",
|
||||||
"password": "19890624"
|
"password": "simnow申请"
|
||||||
}
|
}
|
@ -254,10 +254,15 @@ class CtaEngine(object):
|
|||||||
|
|
||||||
# 推送tick到对应的策略实例进行处理
|
# 推送tick到对应的策略实例进行处理
|
||||||
if tick.vtSymbol in self.tickStrategyDict:
|
if tick.vtSymbol in self.tickStrategyDict:
|
||||||
# 添加datetime字段
|
# tick时间可能出现异常数据,使用try...except实现捕捉和过滤
|
||||||
if not tick.datetime:
|
try:
|
||||||
tick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S.%f')
|
# 添加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]
|
l = self.tickStrategyDict[tick.vtSymbol]
|
||||||
for strategy in l:
|
for strategy in l:
|
||||||
|
Loading…
Reference in New Issue
Block a user