# 获取宏观指标历史数据

get_macro_indicator_history(indicator_id, time=None, max_count=None)

  • 介绍

    获取宏观指标历史数据,返回指定宏观指标的历史数据点列表,包含数据日期、公布日期、公布值、预测值、前值等信息,按时间降序排列。

  • 参数

    参数 类型 说明
    indicator_id int 宏观指标 ID(来自 get_macro_indicator_list 返回)(必填)
    time str 时间节点,格式 "yyyy-MM-dd",从该时间往前拉取;不传默认当前时间
    max_count int 拉取条数,默认 100,上限 1000
  • 返回

    参数 类型 说明
    ret RET_CODE 接口调用结果
    data pd.DataFrame 当 ret == RET_OK,返回数据
    str 当 ret != RET_OK,返回错误描述
    • 数据格式如下:
      字段 类型 说明
      data_time str 数据日期("yyyy-MM-dd")
      release_time str 公布日期("yyyy-MM-dd HH:mm:ss")
      value float 公布值(已还原为原始值)
      predict_value float 预测值(已还原)
      previous_value float 前值(已还原)
      unit_type str 单位类型(PERCENT=百分比 / VALUE=数值 / INDEX=指数)
  • Example

from futu import *

quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)

# 先获取指标ID
ret, indicators = quote_ctx.get_macro_indicator_list(region=MacroRegion.US)
if ret == RET_OK:
    indicator_id = indicators.iloc[0]['indicator_id']

    # 查询历史数据
    ret, data = quote_ctx.get_macro_indicator_history(indicator_id=indicator_id, max_count=2)
    if ret == RET_OK:
        print(data)
    else:
        print('error:', data)

quote_ctx.close()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  • Output
data_time         release_time   value predict_value  previous_value unit_type
0  2026-05-01  2026-06-11 20:34:01  0.0642           N/A          0.0566   PERCENT
1  2026-04-01  2026-05-13 20:31:01  0.0566           N/A          0.0427   PERCENT
1
2
3

接口限制

  • 30 秒内最多 60 次请求
  • 分页请求仅首页计入限频统计