def getKRecordList(self, market, code, query): """ 【重载接口】(必须)按指定的位置[start_ix, end_ix)读取K线数据至out_buffer :param str market: 市场标识 :param str code: 证券代码 :param Query query: 查询条件 :rtype: KRecordList """ if query.query_type == Query.DATE: print("未实现按日期查询") return KRecordList() start_ix = query.start end_ix = query.end if start_ix >= end_ix or start_ix < 0 or end_ix < 0: return KRecordList() data = self._get_bars(market, code, query.ktype) if len(data) < start_ix: return KRecordList() total = end_ix if end_ix < len(data) else len(data) result = KRecordList() for i in range(start_ix, total): record = KRecord() record.datetime = Datetime(data[i].get('datetime')) record.open = data[i].get('open') record.high = data[i].get('high') record.low = data[i].get('low') record.close = data[i].get('close') record.amount = data[i].get('amount') record.volume = data[i].get('vol') result.append(record) return result
def getKRecordList(self, market, code, query): # ktype, start_ix, end_ix, out_buffer): """ 【重载接口】(必须)按指定的位置[start_ix, end_ix)读取K线数据至out_buffer :param str market: 市场标识 :param str code: 证券代码 :param Query.KType ktype: K线类型 :param int start_ix: 起始位置 :param int end_ix: 结束位置 :param KRecordListPtr out_buffer: 传入的数据缓存,读取数据后使用 out_buffer.append(krecord) 加入数据 """ if query.query_type == Query.DATE: print("未实现按日期查询") return KRecordList() start_ix = query.start end_ix = query.end if start_ix >= end_ix or start_ix < 0 or end_ix < 0: return KRecordList() data = self._get_bars(market, code, query.ktype) if len(data) < start_ix: return KRecordList() result = KRecordList() total = end_ix if end_ix < len(data) else len(data) for i in range(start_ix, total): record = KRecord() record.datetime = Datetime(data.index[i]) record.open = data['open'][i] record.high = data['high'][i] record.low = data['low'][i] record.close = data['close'][i] record.amount = data['money'][i] record.volume = data['volume'][i] result.append(record) return result