[Fix]Close #716,SpreadTrading模块当价差某条腿行情未初始化时,禁止交易

This commit is contained in:
vn.py 2018-01-26 10:46:27 +08:00
parent 5b7c190882
commit c6bd7a6d1a
2 changed files with 12 additions and 1 deletions

View File

@ -98,6 +98,14 @@ class StSpread(object):
# 遍历价差腿列表
for n, leg in enumerate(self.allLegs):
# 过滤有某条腿尚未初始化的情况(无挂单量)
if not leg.bidVolume or not leg.askVolume:
self.bidPrice = EMPTY_FLOAT
self.askPrice = EMPTY_FLOAT
self.askVolume = EMPTY_INT
self.bidVolume = EMPTY_INT
return
# 计算价格
if leg.multiplier > 0:
self.bidPrice += leg.bidPrice * leg.multiplier

View File

@ -239,7 +239,6 @@ class StDataEngine(object):
event2.dict_['data'] = spread
self.eventEngine.put(event2)
#----------------------------------------------------------------------
def registerEvent(self):
""""""
@ -309,6 +308,10 @@ class StAlgoEngine(object):
"""处理价差行情事件"""
spread = event.dict_['data']
# 若价差的买卖价均为0则意味着尚未初始化直接返回
if not spread.bidPrice and not spread.askPrice:
return
algo = self.algoDict.get(spread.name, None)
if algo:
algo.updateSpreadTick(spread)