def get_market_status(self, market=Market.ALL, lang=None): """ 获取市场状态 :param market: US 美股,HK 港股, CN A股,ALL 所有 :param lang: 语言支持: zh_CN,zh_TW,en_US :return: MarketStatus 对象构成的列表. MarketStatus 对象有如下属性: market: 字符串,市场名称 status: 字符串,当前市场所处的状态 open_time: 带 tzinfo 的 datetime 对象,表示最近的开盘、交易时间 """ params = MarketParams() params.market = get_enum_value(market) params.lang = get_enum_value(lang) if lang else get_enum_value( self._lang) request = OpenApiRequest(MARKET_STATE, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = MarketStatusResponse() response.parse_response_content(response_content) if response.is_success(): return response.markets else: raise ApiException(response.code, response.message) return None
def get_future_exchanges(self, sec_type=SecurityType.FUT, lang=None): """ 获取期货交易所列表 :param sec_type: FUT: 期货; FOP: 期货期权 :param lang: :return: pandas.DataFrame , 各 column 的含义如下: code: 交易所代码 name: 交易所名称 zone: 交易所所在时区 """ params = MarketParams() params.sec_type = get_enum_value(sec_type) params.lang = get_enum_value(lang) if lang else get_enum_value( self._lang) request = OpenApiRequest(FUTURE_EXCHANGE, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = FutureExchangeResponse() response.parse_response_content(response_content) if response.is_success(): return response.exchanges else: raise ApiException(response.code, response.message) return None
def get_market_status(self, market=Market.ALL, lang=None): """ 获取市场状态 :param market: US 美股,HK 港股, CN A股,ALL 所有 :param lang: 语言支持: zh_CN,zh_TW,en_US :return: """ params = MarketParams() params.market = market.value params.lang = lang.value if lang else self._lang.value request = OpenApiRequest(MARKET_STATE, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = MarketStatusResponse() response.parse_response_content(response_content) if response.is_success(): return response.markets else: raise ApiException(response.code, response.message) return None
def get_future_exchanges(self, sec_type=SecurityType.FUT, lang=None): """ 获取期货交易所列表 :param sec_type: FUT/FOP :param lang: :return: """ params = MarketParams() params.sec_type = sec_type.value params.lang = lang.value if lang else self._lang.value request = OpenApiRequest(FUTURE_EXCHANGE, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = FutureExchangeResponse() response.parse_response_content(response_content) if response.is_success(): return response.exchanges else: raise ApiException(response.code, response.message) return None
def get_symbol_names(self, market=Market.ALL, lang=None): """ 获取股票代号列表和名称 :param market: US 美股,HK 港股, CN A股,ALL 所有 :param lang: 语言支持: zh_CN,zh_TW,en_US :return: list, list 中的每个对象是一个 tuple. tuple 的第一个元素是 symbol,第二个是 name """ params = MarketParams() params.market = market.value params.lang = lang.value if lang else self._lang.value request = OpenApiRequest(ALL_SYMBOL_NAMES, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = SymbolNamesResponse() response.parse_response_content(response_content) if response.is_success(): return response.symbol_names else: raise ApiException(response.code, response.message) return None