From f17793ed17061f2bd4dbdeefcf56eaa46eb1d93c Mon Sep 17 00:00:00 2001 From: nanoric Date: Sun, 21 Oct 2018 22:32:48 -0400 Subject: [PATCH] [Add] VtContractData.createFromGateway --- vnpy/trader/vtObject.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/vnpy/trader/vtObject.py b/vnpy/trader/vtObject.py index e5ac075f..c8a79ed0 100644 --- a/vnpy/trader/vtObject.py +++ b/vnpy/trader/vtObject.py @@ -389,6 +389,37 @@ class VtContractData(VtBaseData): self.underlyingSymbol = EMPTY_STRING # 标的物合约代码 self.optionType = EMPTY_UNICODE # 期权类型 self.expiryDate = EMPTY_STRING # 到期日 + + #---------------------------------------------------------------------- + @staticmethod + def createFromGateway(gateway, + exchange, + symbol, + productClass, + size, + priceTick, + name=None, + strikePrice=EMPTY_FLOAT, + underlyingSymbol=EMPTY_STRING, + optionType=EMPTY_UNICODE, + expiryDate=EMPTY_STRING + ): + d = VtContractData() + d.gatewayName = gateway.gatewayName + d.symbol = symbol + d.exchange = exchange + d.vtSymbol = symbol + '.' + exchange + d.productClass = productClass + d.size = size + d.priceTick = priceTick + if name is None: + d.name = d.symbol + d.strikePrice = strikePrice + d.underlyingSymbol = underlyingSymbol + d.optionType = optionType + d.expiryDate = expiryDate + return d + ########################################################################