Skip to content

扩展数据

ext_data_batch-批量查询多个证券在某一时点的扩展数据

python
ext_data_batch(name, output_indicators, frequency, securities, date)

参数

  • name: string, 扩展数据名
  • output_indicators: string 或 list, 输出指标名
  • frequency: string, k 线频率
  • securities: list, 标的代码列表
  • date: 查询日期,datetime.date/datetime.datetime/'yyyy-mm-dd'/'yyyy-mm-dd hh: mm: ss'/时间戳,如果只传入日期, 则日内时间是当日的 00: 00: 00,默认回测时间

返回

  • 单指标: pandas.DataFrame 或 多指标: dict[output_indicators : pandas.DataFrame]

示例

python
data = ext_data_batch("2222", ["aa","bb"], "1d", ["sz300001","sz300002"], "2025-04-11"))
print(data['aa'])
'''
       code     value  rank
0  sz300001   25.7099    62
1  sz300002   25.4899    62
'''

ext_data_range-返回指定时间区间内引用的扩展数据的数值

python
ext_data_range(name, output_indicators, frequency, security, start_date, end_date, count)

参数

  • name: string, 扩展数据名
  • output_indicators: string 或 list, 输出指标名
  • frequency: string,k 线频率,'1m','1d',分别代表 1 分钟线 和日线
  • security: string, 标的代码
  • start_date: 区间开始日期,datetime.date/datetime.datetime/'yyyy-mm-dd'/'yyyy-mm-dd hh: mm: ss'/时间戳,不能与 count 同时使用,如果只传入日期, 则日内时间是当日的 00: 00: 00
  • end_date: 区间结束日期,datetime.date/datetime.datetime/'yyyy-mm-dd'/'yyyy-mm-dd hh: mm: ss'/时间戳,如果只传入日期, 则日内时间是当日的 00: 00: 00,默认回测时间
  • count: 从结束日期往前取的数量,即表示获取 end_date 之前几个 frequency 的数据,int,与 start_date 二选一,不可同时使用

返回

  • 单指标: pandas.DataFrame 或 多指标: dict[output_indicators : pandas.DataFrame]

示例

python
data = ext_data_range("2222", "aa", "1d", "sz300001", "2025-04-01", "2025-04-11")
print(data)
    
'''
       code                time    value
0  sz300001 2025-04-01 15: 00: 00  25.7099
1  sz300001 2025-04-02 15: 00: 00  25.4899
2  sz300001 2025-04-03 15: 00: 00  25.2500
3  sz300001 2025-04-07 15: 00: 00  21.7000
4  sz300001 2025-04-08 15: 00: 00  21.8400
5  sz300001 2025-04-09 15: 00: 00  22.8199
6  sz300001 2025-04-10 15: 00: 00  22.8199
'''

文档版本: 1.0.0 | 发布于 2025-01-29