|
14 | 14 | from tigeropen.common.consts import Market, Language, QuoteRight, BarPeriod, OPEN_API_SERVICE_VERSION_V3 |
15 | 15 | from tigeropen.common.consts import THREAD_LOCAL, SecurityType, CorporateActionType, IndustryLevel |
16 | 16 | from tigeropen.common.consts.service_types import GRAB_QUOTE_PERMISSION, QUOTE_DELAY, GET_QUOTE_PERMISSION, \ |
17 | | - HISTORY_TIMELINE, FUTURE_CONTRACT_BY_CONTRACT_CODE |
| 17 | + HISTORY_TIMELINE, FUTURE_CONTRACT_BY_CONTRACT_CODE, TRADING_CALENDAR |
18 | 18 | from tigeropen.common.consts.service_types import MARKET_STATE, ALL_SYMBOLS, ALL_SYMBOL_NAMES, BRIEF, \ |
19 | 19 | TIMELINE, KLINE, TRADE_TICK, OPTION_EXPIRATION, OPTION_CHAIN, FUTURE_EXCHANGE, OPTION_BRIEF, \ |
20 | 20 | OPTION_KLINE, OPTION_TRADE_TICK, FUTURE_KLINE, FUTURE_TICK, FUTURE_CONTRACT_BY_EXCHANGE_CODE, \ |
|
37 | 37 | from tigeropen.quote.domain.filter import OptionFilter |
38 | 38 | from tigeropen.quote.request.model import MarketParams, MultipleQuoteParams, MultipleContractParams, \ |
39 | 39 | FutureQuoteParams, FutureExchangeParams, FutureContractParams, FutureTradingTimeParams, SingleContractParams, \ |
40 | | - SingleOptionQuoteParams, DepthQuoteParams, OptionChainParams |
| 40 | + SingleOptionQuoteParams, DepthQuoteParams, OptionChainParams, TradingCalendarParams |
41 | 41 | from tigeropen.quote.response.future_briefs_response import FutureBriefsResponse |
42 | 42 | from tigeropen.quote.response.future_contract_response import FutureContractResponse |
43 | 43 | from tigeropen.quote.response.future_exchange_response import FutureExchangeResponse |
|
64 | 64 | from tigeropen.quote.response.stock_trade_meta_response import TradeMetaResponse |
65 | 65 | from tigeropen.quote.response.symbol_names_response import SymbolNamesResponse |
66 | 66 | from tigeropen.quote.response.symbols_response import SymbolsResponse |
| 67 | +from tigeropen.quote.response.trading_calendar_response import TradingCalendarResponse |
67 | 68 | from tigeropen.tiger_open_client import TigerOpenClient |
68 | 69 |
|
69 | 70 |
|
@@ -1342,3 +1343,26 @@ def get_quote_permission(self): |
1342 | 1343 | else: |
1343 | 1344 | raise ApiException(response.code, response.message) |
1344 | 1345 | return False |
| 1346 | + |
| 1347 | + def get_trading_calendar(self, market, begin_date=None, end_date=None): |
| 1348 | + """ |
| 1349 | + get trading calendar |
| 1350 | + :param market: common.consts.Market, like Market.US |
| 1351 | + :param begin_date: |
| 1352 | + :param end_date: |
| 1353 | + :return: |
| 1354 | + """ |
| 1355 | + params = TradingCalendarParams() |
| 1356 | + params.market = get_enum_value(market) |
| 1357 | + params.begin_date = begin_date |
| 1358 | + params.end_date = end_date |
| 1359 | + request = OpenApiRequest(TRADING_CALENDAR, biz_model=params) |
| 1360 | + response_content = self.__fetch_data(request) |
| 1361 | + if response_content: |
| 1362 | + response = TradingCalendarResponse() |
| 1363 | + response.parse_response_content(response_content) |
| 1364 | + if response.is_success(): |
| 1365 | + return response.calendar |
| 1366 | + else: |
| 1367 | + raise ApiException(response.code, response.message) |
| 1368 | + return False |
0 commit comments