From 6a6d6ab19db0582d1d8c43096d7b730f388b2a91 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Fri, 7 Jan 2022 18:54:47 +0800 Subject: [PATCH] =?UTF-8?q?[bug=20fix]=20=E8=8E=B7=E5=8F=96=E6=99=AE?= =?UTF-8?q?=E9=80=9A=E5=90=88=E7=BA=A6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/data/tdx/tdx_future_data.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vnpy/data/tdx/tdx_future_data.py b/vnpy/data/tdx/tdx_future_data.py index e692d10e..2610c790 100644 --- a/vnpy/data/tdx/tdx_future_data.py +++ b/vnpy/data/tdx/tdx_future_data.py @@ -81,11 +81,14 @@ ALL_MARKET_END_HOUR = 16 @lru_cache() def get_tdx_marketid(symbol): """普通合约/指数合约=》tdx合约所在市场id""" - underlying_symbol = get_underlying_symbol(symbol) - tdx_index_symbol = underlying_symbol.upper() + 'L9' + if symbol.endswith('L9'): + tdx_index_symbol = symbol + else: + underlying_symbol = get_underlying_symbol(symbol).upper() + tdx_index_symbol = underlying_symbol.upper() + 'L9' market_id = INIT_TDX_MARKET_MAP.get(tdx_index_symbol, None) if market_id is None: - raise KeyError(f'{tdx_index_symbol}不存在INIT_TDX_MARKET_MAP中') + raise KeyError(f'{symbol} => {tdx_index_symbol} 不存在INIT_TDX_MARKET_MAP中') return market_id @@ -446,7 +449,7 @@ class TdxFutureData(object): # 利用api查询历史数据 _res = self.api.get_instrument_bars( category=tdx_period, - market=self.symbol_market_dict.get(tdx_index_symbol, 0), + market=get_tdx_marketid(tdx_symbol), code=tdx_symbol, start=_pos, count=QSIZE)