修复获取symbol缩写时,对套利合约的支持。

This commit is contained in:
msincenselee 2017-06-14 19:26:36 +08:00
parent 65b649c8da
commit 581cef3a7d

View File

@ -891,6 +891,21 @@ class CtaEngine(object):
def getShortSymbol(self, symbol):
"""取得合约的短号"""
# 套利合约
if symbol.find(' ') != -1:
# 排除SP SPC SPD
s = symbol.split(' ')
if len(s) < 2:
return symbol
symbol = s[1]
# 只提取leg1合约
if symbol.find('&') != -1:
s = symbol.split('&')
if len(s) < 2:
return symbol
symbol = s[0]
p = re.compile(r"([A-Z]+)[0-9]+", re.I)
shortSymbol = p.match(symbol)