1212from tigeropen .common .consts import Market , Language , QuoteRight , BarPeriod , OPEN_API_SERVICE_VERSION_V3
1313from tigeropen .common .consts import THREAD_LOCAL , SecurityType , CorporateActionType , IndustryLevel
1414from tigeropen .common .consts .service_types import GRAB_QUOTE_PERMISSION , QUOTE_DELAY , GET_QUOTE_PERMISSION , \
15- HISTORY_TIMELINE
15+ HISTORY_TIMELINE , FUTURE_CONTRACT_BY_CONTRACT_CODE
1616from tigeropen .common .consts .service_types import MARKET_STATE , ALL_SYMBOLS , ALL_SYMBOL_NAMES , BRIEF , \
1717 TIMELINE , KLINE , TRADE_TICK , OPTION_EXPIRATION , OPTION_CHAIN , FUTURE_EXCHANGE , OPTION_BRIEF , \
1818 OPTION_KLINE , OPTION_TRADE_TICK , FUTURE_KLINE , FUTURE_TICK , FUTURE_CONTRACT_BY_EXCHANGE_CODE , \
3434 StockIndustryResponse
3535from tigeropen .quote .domain .filter import OptionFilter
3636from tigeropen .quote .request .model import MarketParams , MultipleQuoteParams , MultipleContractParams , \
37- FutureQuoteParams , FutureExchangeParams , FutureTypeParams , FutureTradingTimeParams , SingleContractParams , \
37+ FutureQuoteParams , FutureExchangeParams , FutureContractParams , FutureTradingTimeParams , SingleContractParams , \
3838 SingleOptionQuoteParams , DepthQuoteParams , OptionChainParams
3939from tigeropen .quote .response .future_briefs_response import FutureBriefsResponse
4040from tigeropen .quote .response .future_contract_response import FutureContractResponse
@@ -831,7 +831,7 @@ def get_current_future_contract(self, future_type, lang=None):
831831 trade: 是否可交易
832832 continuous: 是否为连续合约
833833 """
834- params = FutureTypeParams ()
834+ params = FutureContractParams ()
835835 params .type = future_type
836836 params .lang = get_enum_value (lang ) if lang else get_enum_value (self ._lang )
837837
@@ -846,6 +846,28 @@ def get_current_future_contract(self, future_type, lang=None):
846846 raise ApiException (response .code , response .message )
847847 return None
848848
849+ def get_future_contract (self , contract_code , lang = None ):
850+ """
851+ get future contract by contract_code
852+ :param contract_code: code of future contract, like VIX2206, CL2203
853+ :param lang:
854+ :return: pandas.DataFrame
855+ """
856+ params = FutureContractParams ()
857+ params .contract_code = contract_code
858+ params .lang = get_enum_value (lang ) if lang else get_enum_value (self ._lang )
859+
860+ request = OpenApiRequest (FUTURE_CONTRACT_BY_CONTRACT_CODE , biz_model = params )
861+ response_content = self .__fetch_data (request )
862+ if response_content :
863+ response = FutureContractResponse ()
864+ response .parse_response_content (response_content )
865+ if response .is_success ():
866+ return response .contracts
867+ else :
868+ raise ApiException (response .code , response .message )
869+ return None
870+
849871 def get_future_trading_times (self , identifier , trading_date = None ):
850872 """
851873 查询指定期货合约的交易时间
0 commit comments