2424 OPTION_KLINE , OPTION_TRADE_TICK , FUTURE_KLINE , FUTURE_TICK , FUTURE_CONTRACT_BY_EXCHANGE_CODE , \
2525 FUTURE_TRADING_DATE , QUOTE_SHORTABLE_STOCKS , FUTURE_REAL_TIME_QUOTE , \
2626 FUTURE_CURRENT_CONTRACT , QUOTE_REAL_TIME , QUOTE_STOCK_TRADE , FINANCIAL_DAILY , FINANCIAL_REPORT , CORPORATE_ACTION , \
27- QUOTE_DEPTH , INDUSTRY_LIST , INDUSTRY_STOCKS , STOCK_INDUSTRY , STOCK_DETAIL
27+ QUOTE_DEPTH , INDUSTRY_LIST , INDUSTRY_STOCKS , STOCK_INDUSTRY , STOCK_DETAIL , FUTURE_CONTINUOUS_CONTRACTS
2828from tigeropen .common .exceptions import ApiException
2929from tigeropen .common .request import OpenApiRequest
3030from tigeropen .common .util .common_utils import eastern , get_enum_value , date_str_to_timestamp
@@ -370,7 +370,7 @@ def get_stock_details(self, symbols, lang=None):
370370 raise ApiException (response .code , response .message )
371371 return None
372372
373- def get_timeline (self , symbols , include_hour_trading = False , begin_time = - 1 , lang = None , ** kwargs ):
373+ def get_timeline (self , symbols , include_hour_trading = False , begin_time = - 1 , lang = None , trade_session = None , ** kwargs ):
374374 """
375375 获取当日分时数据
376376 :param symbols: 股票代号列表
@@ -392,6 +392,7 @@ def get_timeline(self, symbols, include_hour_trading=False, begin_time=-1, lang=
392392 params .include_hour_trading = include_hour_trading
393393 params .begin_time = begin_time
394394 params .lang = get_enum_value (lang ) if lang else get_enum_value (self ._lang )
395+ params .trade_session = get_enum_value (trade_session )
395396 if 'version' in kwargs :
396397 params .version = kwargs .get ('version' )
397398 else :
@@ -435,7 +436,7 @@ def get_timeline_history(self, symbols, date, right=QuoteRight.BR):
435436 raise ApiException (response .code , response .message )
436437
437438 def get_bars (self , symbols , period = BarPeriod .DAY , begin_time = - 1 , end_time = - 1 , right = QuoteRight .BR , limit = 251 ,
438- lang = None , page_token = None ):
439+ lang = None , page_token = None , trade_session = None ):
439440 """
440441 获取K线数据
441442 :param symbols: 股票代号列表
@@ -465,7 +466,7 @@ def get_bars(self, symbols, period=BarPeriod.DAY, begin_time=-1, end_time=-1, ri
465466 params .limit = limit
466467 params .lang = get_enum_value (lang ) if lang else get_enum_value (self ._lang )
467468 params .page_token = page_token if len (params .symbols ) == 1 else None
468-
469+ params . trade_session = get_enum_value ( trade_session )
469470 request = OpenApiRequest (KLINE , biz_model = params )
470471 response_content = self .__fetch_data (request )
471472 if response_content :
@@ -477,7 +478,7 @@ def get_bars(self, symbols, period=BarPeriod.DAY, begin_time=-1, end_time=-1, ri
477478 raise ApiException (response .code , response .message )
478479
479480 def get_bars_by_page (self , symbol , period = BarPeriod .DAY , begin_time = - 1 , end_time = - 1 , total = 10000 , page_size = 1000 ,
480- right = QuoteRight .BR , time_interval = 2 , lang = None ):
481+ right = QuoteRight .BR , time_interval = 2 , lang = None , trade_session = None ):
481482 """
482483 request bats by page
483484 :param symbol: symbol of stock.
@@ -504,7 +505,7 @@ def get_bars_by_page(self, symbol, period=BarPeriod.DAY, begin_time=-1, end_time
504505 page_size = total - current
505506 current += page_size
506507 bars = self .get_bars (symbols = symbol , period = period , begin_time = begin_time , end_time = end_time , right = right ,
507- limit = page_size , lang = lang , page_token = next_page_token )
508+ limit = page_size , lang = lang , trade_session = trade_session , page_token = next_page_token )
508509 if bars .empty :
509510 result_df = bars
510511 break
@@ -1046,6 +1047,31 @@ def get_future_contract(self, contract_code, lang=None):
10461047 raise ApiException (response .code , response .message )
10471048 return None
10481049
1050+ def get_future_continuous_contracts (self , type_ = None , lang = None ):
1051+ """
1052+ Get Future Continuous Contracts
1053+ :param type_: 'CL'
1054+ :param lang: zh_CN,zh_TW,en_US
1055+ :return: pandas.DataFrame
1056+ contract_code continuous contract_month currency display_multiplier exchange exchange_code first_notice_date last_bidding_close_time last_trading_date min_tick multiplier name symbol trade type
1057+ 0 CLmain False USD 1 NYMEX NYMEX 0 0.01 1000.0 WTI原油主连 CL True CL
1058+
1059+ """
1060+ params = FutureContractParams ()
1061+ params .type = type_
1062+ params .lang = get_enum_value (lang ) if lang else get_enum_value (self ._lang )
1063+
1064+ request = OpenApiRequest (FUTURE_CONTINUOUS_CONTRACTS , biz_model = params )
1065+ response_content = self .__fetch_data (request )
1066+ if response_content :
1067+ response = FutureContractResponse ()
1068+ response .parse_response_content (response_content , skip_main = False )
1069+ if response .is_success ():
1070+ return response .contracts
1071+ else :
1072+ raise ApiException (response .code , response .message )
1073+ return None
1074+
10491075 def get_future_trading_times (self , identifier , trading_date = None ):
10501076 """
10511077 查询指定期货合约的交易时间
@@ -1859,4 +1885,6 @@ def get_stock_fundamental(self, symbols, market):
18591885 if response .is_success ():
18601886 return response .result
18611887 else :
1862- raise ApiException (response .code , response .message )
1888+ raise ApiException (response .code , response .message )
1889+
1890+
0 commit comments