# 獲取宏觀指標歷史數據

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 次請求
  • 分頁請求僅首頁計入限頻統計