[Fix]Close #716,SpreadTrading模块当价差某条腿行情未初始化时,禁止交易
This commit is contained in:
parent
5b7c190882
commit
c6bd7a6d1a
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user