1616from tigeropen .common .consts .filter_fields import FieldBelongType
1717from tigeropen .common .consts .service_types import GRAB_QUOTE_PERMISSION , QUOTE_DELAY , GET_QUOTE_PERMISSION , \
1818 HISTORY_TIMELINE , FUTURE_CONTRACT_BY_CONTRACT_CODE , TRADING_CALENDAR , FUTURE_CONTRACTS , MARKET_SCANNER , \
19- STOCK_BROKER , CAPITAL_FLOW , CAPITAL_DISTRIBUTION
19+ STOCK_BROKER , CAPITAL_FLOW , CAPITAL_DISTRIBUTION , WARRANT_REAL_TIME_QUOTE , WARRANT_FILTER
2020from tigeropen .common .consts .service_types import MARKET_STATE , ALL_SYMBOLS , ALL_SYMBOL_NAMES , BRIEF , \
2121 TIMELINE , KLINE , TRADE_TICK , OPTION_EXPIRATION , OPTION_CHAIN , FUTURE_EXCHANGE , OPTION_BRIEF , \
2222 OPTION_KLINE , OPTION_TRADE_TICK , FUTURE_KLINE , FUTURE_TICK , FUTURE_CONTRACT_BY_EXCHANGE_CODE , \
4040from tigeropen .quote .request .model import MarketParams , MultipleQuoteParams , MultipleContractParams , \
4141 FutureQuoteParams , FutureExchangeParams , FutureContractParams , FutureTradingTimeParams , SingleContractParams , \
4242 SingleOptionQuoteParams , DepthQuoteParams , OptionChainParams , TradingCalendarParams , MarketScannerParams , \
43- StockBrokerParams , CapitalParams
43+ StockBrokerParams , CapitalParams , WarrantFilterParams
4444from tigeropen .quote .response .capital_distribution_response import CapitalDistributionResponse
4545from tigeropen .quote .response .capital_flow_response import CapitalFlowResponse
4646from tigeropen .quote .response .future_briefs_response import FutureBriefsResponse
7272from tigeropen .quote .response .symbol_names_response import SymbolNamesResponse
7373from tigeropen .quote .response .symbols_response import SymbolsResponse
7474from tigeropen .quote .response .trading_calendar_response import TradingCalendarResponse
75+ from tigeropen .quote .response .warrant_briefs_response import WarrantBriefsResponse
76+ from tigeropen .quote .response .warrant_filter_response import WarrantFilterResponse
7577from tigeropen .tiger_open_client import TigerOpenClient
7678from tigeropen .tiger_open_config import LANGUAGE
7779
@@ -733,7 +735,7 @@ def get_option_briefs(self, identifiers):
733735
734736 return None
735737
736- def get_option_bars (self , identifiers , begin_time = - 1 , end_time = 4070880000000 , period = BarPeriod .DAY ):
738+ def get_option_bars (self , identifiers , begin_time = - 1 , end_time = 4070880000000 , period = BarPeriod .DAY , limit = None ):
737739 """
738740 获取期权日K数据
739741 :param identifiers: 期权代码列表
@@ -742,6 +744,7 @@ def get_option_bars(self, identifiers, begin_time=-1, end_time=4070880000000, pe
742744 :param end_time: 结束时间. 格式同 begin_time
743745 :param period: 时间间隔. 可选值: DAY("day"), ONE_MINUTE("1min"), FIVE_MINUTES("5min"), HALF_HOUR("30min"),
744746 ONE_HOUR("60min");
747+ :param limit: 每个期权的返回k线数量
745748 :return: pandas.DataFrame, 各 column 含义如下:
746749 time: 毫秒级时间戳
747750 open: 开盘价
@@ -768,6 +771,7 @@ def get_option_bars(self, identifiers, begin_time=-1, end_time=4070880000000, pe
768771 param .period = get_enum_value (period )
769772 param .begin_time = date_str_to_timestamp (begin_time , self ._timezone )
770773 param .end_time = date_str_to_timestamp (end_time , self ._timezone )
774+ param .limit = limit
771775 contracts .append (param )
772776 params .contracts = contracts
773777 request = OpenApiRequest (OPTION_KLINE , biz_model = params )
@@ -1542,6 +1546,42 @@ def get_capital_distribution(self, symbol, market, lang=None):
15421546 if response_content :
15431547 response = CapitalDistributionResponse ()
15441548 response .parse_response_content (response_content )
1549+ if response .is_success ():
1550+ return response .result
1551+ else :
1552+ raise ApiException (response .code , response .message )
1553+
1554+ def get_warrant_briefs (self , symbols ):
1555+ """
1556+ get warrant/iopt quote
1557+ :param symbols:
1558+ :return:
1559+ """
1560+ params = MultipleQuoteParams ()
1561+ params .symbols = symbols if isinstance (symbols , list ) else [symbols ]
1562+ params .lang = get_enum_value (self ._lang )
1563+ request = OpenApiRequest (WARRANT_REAL_TIME_QUOTE , biz_model = params )
1564+ response_content = self .__fetch_data (request )
1565+ if response_content :
1566+ response = WarrantBriefsResponse ()
1567+ response .parse_response_content (response_content )
1568+ if response .is_success ():
1569+ return response .result
1570+ else :
1571+ raise ApiException (response .code , response .message )
1572+
1573+ def get_warrant_filter (self , symbol , ):
1574+ """
1575+ :return:
1576+ """
1577+ params = WarrantFilterParams ()
1578+ params .lang = get_enum_value (self ._lang )
1579+ params .symbol = symbol
1580+ request = OpenApiRequest (WARRANT_FILTER , biz_model = params )
1581+ response_content = self .__fetch_data (request )
1582+ if response_content :
1583+ response = WarrantFilterResponse ()
1584+ response .parse_response_content (response_content )
15451585 if response .is_success ():
15461586 return response .result
15471587 else :
0 commit comments