Live release feed
Sub-second macro releases for FX backtests
Point-in-time history
Official CPI, jobs, GDP, and central-bank events with point-in-time history.
$25/month 14-day free trial
Start Free Trial

Reference

Macro Education

Forecasting Macro Releases: How to Use the FXMacroData Predictions API

Market moves before the number drops. The FXMacroData predictions API surfaces market consensus, central-bank projections, IMF WEO forecasts, and survey data for every covered indicator — all linked to realised observations via a stable announcement_id so you can measure forecast accuracy and build lookahead-free backtests.

其他语言版本 English
Share article X LinkedIn Email

为什么预测与数字本身一样重要

汇率市场不会因数据发布而动态,而是因意外而动作. 美国联邦储备 没有一个 欧洲中央银行 假如数据显示出新的数据,市场已经形成了预期. 如果数据与共识相匹配,那么货币对几乎不会动. 如果它偏离,你就会得到峰.

对于外汇波动的大部分,存在于这一差距之间. 要系统地处理,您需要与实际观察一起访问预测,并将其连接在一起,以便您可以计算出惊喜,而不会污染数据.

FXMacroData预测API是为此工作流程而构建的.它从五个不同的源类别中显示预测,并通过稳定链接每个预测到其目标公告. announcement_id您可以将预测与现实值结合起来, 测量预测的时间准确性,


预测的终点返回的结果

两条路线暴露预测数据:

  • /api/v1/predictions/{currency} 对于每种货币,在目录中的每个指标,具有指标的可选过器,预测类型和来源.
  • /api/v1/predictions/{currency}/{indicator} 对于特定货币和指标对的所有预测.

两条路线都是免费的.非美元货币需要专业API密钥.

响应组通过公告进入. announcement_id 稳定,确定性密钥的形式 {currency}_{indicator}_{date} 后面是一个 predictions 预测值,其来源,以及可读的标签. 美元通货膨胀没有

{
  "currency": "USD",
  "indicator": "inflation",
  "count": 2,
  "prediction_count": 3,
  "data": [
    {
      "announcement_id": "usd_inflation_2026-02-28",
      "currency": "usd",
      "indicator": "inflation",
      "date": "2026-02-28",
      "announcement_datetime": 1772433000,
      "predictions": [
        {
          "predicted_value": 2.9,
          "prediction_type": "market_consensus",
          "prediction_source": "philly_fed_spf",
          "prediction_source_label": "Philadelphia Fed Survey of Professional Forecasters"
        }
      ]
    },
    {
      "announcement_id": "usd_inflation_2026-03-31",
      "currency": "usd",
      "indicator": "inflation",
      "date": "2026-03-31",
      "predictions": [
        {
          "predicted_value": 2.6,
          "prediction_type": "market_consensus",
          "prediction_source": "philly_fed_spf",
          "prediction_source_label": "Philadelphia Fed Survey of Professional Forecasters"
        },
        {
          "predicted_value": 2.5,
          "prediction_type": "imf_weo",
          "prediction_source": "imf_weo",
          "prediction_source_label": "IMF World Economic Outlook"
        }
      ]
    }
  ]
}

没有什么. announcement_id 在每一个预测行上, 值与返回的值相同. /api/v1/announcements/{currency}/{indicator}简单的词典结合是你需要的,


预测来源类别

五个 prediction_type 对于每一个预测的权重和解释,了解差异很重要:

预测_类型 这就是什么 举例来源
market_consensus 专业预测师的市场调查 费城联邦储备局SPF,路透社民意调查
market_prediction 个人专业预测点预测 预测者级别的分析调查数据
survey 中央银行对专业预测人员的调查 欧洲央行对专业预测人员的调查
central_bank_forecast 央行在货币政策声明中公布的官方预测 央行货币政策声明没有人知道. 央行货币政策报告
imf_weo 国际货币基金组织世界经济前景预测 发布每年两次,所有支持货币

市场共识是短期市场预期,在发布日驱动即时外汇反应.央行预测反映了该机构的自身前景,并且有助于跟踪银行预测在会议之间有多大变化.IMF WEO预测提供了中立的多年基线,并且在所有18种覆盖货币中都是一致的,使其对跨货币比较有用.


在Python中建立惊喜索引

预测API的最直接应用是计算发布惊喜指数,即实际印刷品与市场预期的偏差,以历史惊喜的标准偏差表示. 美国非农业工资没有

import requests
import statistics

BASE = "https://fxmacrodata.com/api"

# Fetch predictions — free for USD, no key needed
preds_resp = requests.get(
    f"{BASE}/v1/predictions/usd/non_farm_payrolls",
    params={"prediction_type": "market_consensus"},
    timeout=30,
).json()

# Fetch actuals
actuals_resp = requests.get(
    f"{BASE}/v1/announcements/usd/non_farm_payrolls",
    params={"start_date": "2020-01-01"},
    timeout=30,
).json()

# Index actuals by announcement_id
actuals = {row["announcement_id"]: row["val"] for row in actuals_resp["data"]}

# Compute surprises (actual - consensus)
surprises = []
for group in preds_resp["data"]:
    aid = group["announcement_id"]
    actual = actuals.get(aid)
    if actual is None:
        continue
    # Use the first (or only) prediction in the group
    forecast = group["predictions"][0]["predicted_value"]
    surprises.append({
        "date": group["date"],
        "actual": actual,
        "forecast": forecast,
        "surprise": actual - forecast,
    })

# Normalise to z-scores
values = [s["surprise"] for s in surprises]
mean = statistics.mean(values)
stdev = statistics.stdev(values)
for s in surprises:
    s["z_score"] = (s["surprise"] - mean) / stdev

# Print recent surprises
for s in surprises[-6:]:
    direction = "↑ beat" if s["z_score"] > 0 else "↓ miss"
    print(f"{s['date']}: actual={s['actual']:,.0f}k  forecast={s['forecast']:,.0f}k  "
          f"surprise={s['surprise']:+,.0f}k  z={s['z_score']:+.2f}  {direction}")

输出给出了一个正常的惊喜时间序列,可以直接与发布日的美元现货动作相关,以量化给定指标的惊到FX传输系数.


央行预测与市场共识的比较

汇率敏感货币对中的一个有用信号是央行预测和市场预期之间的分歧.当这两个趋于一致时,通常表明市场已经完全消化了银行的指导.当它们分歧时,它可以表明银行和买方之间的可信度差距或真正的信息不对称性.

您可以在一个请求中检索两个预测类型,并直接计算差异:

import requests

# Fetch all prediction types for EUR inflation together
resp = requests.get(
    "https://fxmacrodata.com/api/v1/predictions/eur/inflation",
    params={"api_key": "YOUR_API_KEY"},
    timeout=30,
).json()

# For each announcement group, compare central_bank_forecast vs market_consensus
for group in resp["data"]:
    preds_by_type = {p["prediction_type"]: p for p in group["predictions"]}
    cb = preds_by_type.get("central_bank_forecast")
    mkt = preds_by_type.get("market_consensus")
    if cb and mkt:
        divergence = cb["predicted_value"] - mkt["predicted_value"]
        print(f"{group['date']}: CB={cb['predicted_value']:.2f}%  "
              f"Market={mkt['predicted_value']:.2f}%  "
              f"Divergence={divergence:+.2f}pp  "
              f"({cb['prediction_source_label']})")

积极分歧 (央行预计通胀率高于市场) 通常是鱼信号.银行要么有非公开信息,要么故意表示容忍目标通胀.持续的积极分差历史上在几个货币对上出现了意外的上. 发布日程现在我们要做什么?


货币间预测与IMF的WEO进行比较

由于IMF的WEO预测存在于每个受保护货币,并且使用一致的方法,因此它们非常适合跨货币比较. 下面的片段引出了 国内生产总值 预测四个主要商品挂货币,并按预期增长排名:

import requests

API_KEY = "YOUR_API_KEY"
CURRENCIES = ["aud", "cad", "nzd", "brl"]

forecasts = {}
for ccy in CURRENCIES:
    resp = requests.get(
        f"https://fxmacrodata.com/api/v1/predictions/{ccy}/gdp",
        params={"prediction_type": "imf_weo", "api_key": API_KEY},
        timeout=30,
    ).json()
    if resp.get("data"):
        # Take the most recent forecast
        latest = resp["data"][-1]
        forecasts[ccy.upper()] = latest["predictions"][0]["predicted_value"]

# Rank by projected growth
ranked = sorted(forecasts.items(), key=lambda x: x[1], reverse=True)
print("IMF WEO GDP forecast ranking:")
for rank, (ccy, val) in enumerate(ranked, 1):
    print(f"  {rank}. {ccy}: {val:.1f}% YoY")

这种排名自然会引入AUD/CAD或NZD/AUD等商品货币对的相对价值框架,其中增长差异是中期货币转移定位的主要驱动力.


根据预测来源进行过

当单个公告有来自不同来源的多个预测时,您可能想孤立一个特定的预测. 使用 prediction_source 查询参数与稳定的源:

# Philadelphia Fed Survey of Professional Forecasters only
curl "https://fxmacrodata.com/api/v1/predictions/usd/inflation?prediction_source=philly_fed_spf"

# ECB Survey of Professional Forecasters (requires API key)
curl "https://fxmacrodata.com/api/v1/predictions/eur/inflation?prediction_source=ecb_spf&api_key=YOUR_API_KEY"

# RBNZ Monetary Policy Statement (requires API key)
curl "https://fxmacrodata.com/api/v1/predictions/nzd/inflation?prediction_source=rbnz_mps&api_key=YOUR_API_KEY"

# IMF World Economic Outlook
curl "https://fxmacrodata.com/api/v1/predictions/usd/inflation?prediction_source=imf_weo"

没有什么. prediction_source_label 答案中的字段给出了源的全文,适合图表标签和报告脚注. prediction_source 镜用于过和编程接头.


对于即将发布的预测,使用发布日历

没有什么. 发布日程 显示所有所涵盖货币的即将发布日期.当您将日历数据与预测终点结合在一起时,您可以构建一个展望未来的仪表板,显示每个即将发行货币目前的共识.

import requests
from datetime import date

API_KEY = "YOUR_API_KEY"
BASE = "https://fxmacrodata.com/api"

# Get upcoming USD releases
calendar = requests.get(f"{BASE}/v1/calendar/usd").json()
upcoming = [row for row in calendar["data"] if row.get("release")]

# For each upcoming release, fetch the current consensus prediction
for release in upcoming[:5]:
    indicator = release["release"]
    preds = requests.get(
        f"{BASE}/v1/predictions/usd/{indicator}",
        params={"prediction_type": "market_consensus"},
        timeout=30,
    ).json()
    if preds.get("data"):
        latest_pred = preds["data"][-1]
        if latest_pred.get("predictions"):
            val = latest_pred["predictions"][0]["predicted_value"]
            print(f"{indicator}: consensus={val}")

终点参考摘要

参数的完整文档可在 应用程序的参考页面下表为两个预测路线提供了快速参考:

参数 类型 描述
currency路径美元是免费的,其他需要钥匙.
indicator路径或查询指示 (例如: inflation没有人知道. policy_rate没有人知道. gdp路径在 /{currency}/{indicator} 路线; 选择性查询 /{currency}现在我们要做什么?
prediction_type查询它们中的一个 market_consensus没有人知道. market_prediction没有人知道. survey没有人知道. central_bank_forecast没有人知道. imf_weo没有人知道. fxmacrodata现在我们要做什么?
prediction_source查询稳定的源 (例如 philly_fed_spf没有人知道. ecb_spf没有人知道. imf_weo) 没有.
start_date 现在我们要做什么? end_date查询期日期范围 (YYY-MM-DD). 默认为12个月/今天.
api_key查询专业API密钥. 需要用于非美元货币.

预测API是设计的坐在 货币膨胀没有人知道. 政策利率其他指标概述页面 汇率比较最有用 及 发布日程预测时间与预测相符.

Blogroll

AI Answer-Ready

Key Facts

Page
Forecasting Macro Releases With Predictions API
Section
Articles
Canonical URL
https://fxmacrodata.com/articles/forecasting-macro-releases-with-predictions-api
Source
FXMacroData editorial and official publisher references
Last Updated
2026-06-15 11:01 UTC

Provenance And Trust

Cite the canonical URL and source field above. Where available, this page maps to official publisher releases and timestamped updates.

Quick Q&A

What is this page about? This page explains Forecasting Macro Releases With Predictions API with directly usable context for trading, research, and API workflows.

What source should be cited? Use the canonical URL and the listed source field; cite official publisher references when available.

How fresh is this content? The last updated value above reflects the page metadata or latest available data timestamp.

Can this be used in AI assistants? Yes. This section is intentionally structured for retrieval and citation in chat assistants.

Prompt Packs

Use these in ChatGPT, Claude, Gemini, Mistral, Perplexity, or Grok for consistent source-aware outputs.

Share page X LinkedIn Email