From 51856108386d081c51592fc72b107669eae5b4ba Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 12 Oct 2019 12:22:43 +0800 Subject: [PATCH] [Mod] tap gateway only support futures for now --- vnpy/gateway/tap/tap_gateway.py | 47 +++++++++++++++++---------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/vnpy/gateway/tap/tap_gateway.py b/vnpy/gateway/tap/tap_gateway.py index b0ee5f3d..c4236e74 100644 --- a/vnpy/gateway/tap/tap_gateway.py +++ b/vnpy/gateway/tap/tap_gateway.py @@ -449,32 +449,33 @@ class TradeApi(ITapTradeAPINotify): if not info or not exchange or not commodity_info: return - symbol = info.CommodityNo + info.ContractNo1 + if info.CommodityType == "F": + symbol = info.CommodityNo + info.ContractNo1 - if commodity_info.name: - name = f"{commodity_info.name} {info.ContractNo1}" - else: - name = symbol + if commodity_info.name: + name = f"{commodity_info.name} {info.ContractNo1}" + else: + name = symbol - contract = ContractData( - symbol=symbol, - exchange=exchange, - name=name, - product=Product.FUTURES, - size=commodity_info.size, - pricetick=commodity_info.pricetick, - gateway_name=self.gateway.gateway_name - ) - self.gateway.on_contract(contract) + contract = ContractData( + symbol=symbol, + exchange=exchange, + name=name, + product=Product.FUTURES, + size=commodity_info.size, + pricetick=commodity_info.pricetick, + gateway_name=self.gateway.gateway_name + ) + self.gateway.on_contract(contract) - contract_info = ContractInfo( - name=contract.name, - exchange_no=info.ExchangeNo, - contract_no=info.ContractNo1, - commodity_type=info.CommodityType, - commodity_no=info.CommodityNo, - ) - contract_infos[(contract.symbol, contract.exchange)] = contract_info + contract_info = ContractInfo( + name=contract.name, + exchange_no=info.ExchangeNo, + contract_no=info.ContractNo1, + commodity_type=info.CommodityType, + commodity_no=info.CommodityNo, + ) + contract_infos[(contract.symbol, contract.exchange)] = contract_info if isLast == "Y": self.gateway.write_log("查询交易合约信息成功")