From 581cef3a7dccccd8af5b2fd036925faa3b781eee Mon Sep 17 00:00:00 2001 From: msincenselee Date: Wed, 14 Jun 2017 19:26:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96symbol?= =?UTF-8?q?=E7=BC=A9=E5=86=99=E6=97=B6=EF=BC=8C=E5=AF=B9=E5=A5=97=E5=88=A9?= =?UTF-8?q?=E5=90=88=E7=BA=A6=E7=9A=84=E6=94=AF=E6=8C=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/ctaStrategy/ctaEngine.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index 78caaf60..48e552a3 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -891,10 +891,25 @@ 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) - if shortSymbol is None : + if shortSymbol is None: self.writeCtaLog(u'{0}不能正则分解'.format(symbol)) return symbol