def get_bars(self, symbols, period=BarPeriod.DAY, begin_time=-1, end_time=-1, right=QuoteRight.BR, limit=251, lang=None): """ 获取K线数据 :param symbols: 股票代码 :param period: day: 日K,week: 周K,month:月K ,year:年K,1min:1分钟,5min:5分钟,15min:15分钟,30min:30分钟,60min:60分钟 :param begin_time: 开始时间 :param end_time: 结束时间 :param right: 复权选项 ,br: 前复权,nr: 不复权 :param limit: 数量限制 :param lang: 语言支持: zh_CN,zh_TW,en_US :return: """ params = MultipleQuoteParams() params.symbols = symbols if period: params.period = period.value params.begin_time = begin_time params.end_time = end_time params.right = right.value params.limit = limit params.lang = lang.value if lang else self._lang.value request = OpenApiRequest(KLINE, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = QuoteBarResponse() response.parse_response_content(response_content) if response.is_success(): return response.bars else: raise ApiException(response.code, response.message)
def get_trade_ticks(self, symbols, begin_index=0, end_index=30, limit=30, lang=None): """ 获取逐笔成交 :param symbols: 股票代码 :param begin_index: 开始索引 :param end_index: 结束索引 :param limit: 数量限制 :param lang: 语言支持: zh_CN,zh_TW,en_US :return: """ params = MultipleQuoteParams() params.symbols = symbols params.begin_index = begin_index params.end_index = end_index params.limit = limit params.lang = lang.value if lang else self._lang.value request = OpenApiRequest(TRADE_TICK, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = TradeTickResponse() response.parse_response_content(response_content) if response.is_success(): return response.trade_ticks else: raise ApiException(response.code, response.message) return None
def get_bars(self, symbols, period=BarPeriod.DAY, begin_time=-1, end_time=-1, right=QuoteRight.BR, limit=251, lang=None): """ 获取K线数据 :param symbols: 股票代号列表 :param period: day: 日K,week: 周K,month:月K ,year:年K,1min:1分钟,5min:5分钟,15min:15分钟,30min:30分钟,60min:60分钟 :param begin_time: 开始时间. 若是时间戳需要精确到毫秒, 为13位整数; 或是日期时间格式的字符串, 如 "2019-01-01" 或 "2019-01-01 12:00:00" :param end_time: 结束时间. 格式同 begin_time :param right: 复权选项 ,QuoteRight.BR: 前复权,nQuoteRight.NR: 不复权 :param limit: 数量限制 :param lang: 语言支持: zh_CN,zh_TW,en_US :return: pandas.DataFrame 对象,各 column 的含义如下; time: 毫秒时间戳 open: Bar 的开盘价 close: Bar 的收盘价 high: Bar 的最高价 low: Bar 的最低价 volume: Bar 的成交量 """ params = MultipleQuoteParams() params.symbols = symbols if period: params.period = period.value params.begin_time = begin_time params.end_time = end_time params.right = right.value params.limit = limit params.lang = lang.value if lang else self._lang.value request = OpenApiRequest(KLINE, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = QuoteBarResponse() response.parse_response_content(response_content) if response.is_success(): return response.bars else: raise ApiException(response.code, response.message)
def get_trade_ticks(self, symbols, begin_index=None, end_index=None, limit=None, lang=None): """ 获取逐笔成交 :param symbols: 股票代号列表 :param begin_index: 开始索引 :param end_index: 结束索引 :param limit: 数量限制 :param lang: 语言支持: zh_CN,zh_TW,en_US :return: pandas.DataFrame 对象, column 有如下属性: index: 索引值 time: 毫秒时间戳 price: 成交价 volume: 成交量 direction: 价格变动方向,"-"表示向下变动, "+" 表示向上变动 """ params = MultipleQuoteParams() params.symbols = symbols params.begin_index = begin_index params.end_index = end_index params.limit = limit params.lang = get_enum_value(lang) if lang else get_enum_value( self._lang) request = OpenApiRequest(TRADE_TICK, biz_model=params) response_content = self.__fetch_data(request) if response_content: response = TradeTickResponse() response.parse_response_content(response_content) if response.is_success(): return response.trade_ticks else: raise ApiException(response.code, response.message) return None