スプレッドシートはマクロ分析の最も一般的なツールです. Excel や Google Sheets を好むか否かは別として,ライブの中央銀行と経済指標データをセルに直接引き込むこと 値を手動でコピーする代わりに は静的テーブルを自己更新決定補助装置にします.このガイドでは,FXMacroData を両方のプラットフォーム:Excel の Power Query と VBA と Google スクリプト の Apps に接続する方法を示します. 終了時までに,お気に召すすべてのマクロ番号は,スプレッドシーートを離さないで自動的にリフレッシュされます.
建設する
- Excel パワークエリ 構造化テーブルに任意の指標をクリックで呼び出すクエリ
- Excel VBA をインストールする 公式やチャートに準備されている,名前あるセルに直接値を書き込むマクロ
- Google アプリスクリプト シーツタブに行を書き込み,タイム駆動トリガーでリフレッシュするスクリプト
条件
- FXMacroData API キーを 登録する / サブスクリプト任意のレベルキーでは多くの指標のエンドポイントがカバーされます.
- Excel 2016+ をインストールする コンピュータの検索結果 ほか Excel 365/オンライン Power Query は Windows/Mac に組み込まれ,オンラインで利用できます
- Google アカウント Google Sheets と Apps Script にアクセスできるアカウント (追加ソフトウェアは必要ありません)
- Excel の公式 を 基本 的 に 知っている の です ほか Google Sheets Power Query セクションにはプログラミングの背景は必要ありません
PART 1 EXCEL
部分1 Excel
Excel offers two routes for live API data: パワークエリ 分析家にとって素晴らしいです VBA (コード駆動で,特定のセルに値を書き込む必要があり,ボタンやイベントから論理を起動する場合は最適です)
ステップ 1Step 1 — Understand the API endpoint shape
FXMacroDataのすべての指標は同じRESTパターンをフォローします.
GET https://fxmacrodata.com/api/v1/announcements/usd/policy_rate?api_key=YOUR_API_KEY&start=2020-01-01
JSON応答は,平面のオブジェクトで, data 配列:
{
"data": [
{ "date": "2025-03-19", "val": 4.25, "announcement_datetime": "2025-03-19T18:00:00Z" },
{ "date": "2025-01-29", "val": 4.25, "announcement_datetime": "2025-01-29T19:00:00Z" },
{ "date": "2024-12-18", "val": 4.25, "announcement_datetime": "2024-12-18T19:00:00Z" }
]
}
記録には date (YYY-MM-DD) 番号 val, and — where available —
a second-level UTC announcement_datetime指示値の端点がすべてこの形を共有しているため,Power Query機能またはVBAヘルパーはすべてに対応できます. API ドキュメントほら
ステップ2
ステップ2 Excel Power Query: Web コンネクタでインポート
電力検索は内蔵されている ウェブ から 接続器は,コードなしで,任意の JSON REST エンドポイントを消費することができます.
- Excelでクリックします データ → データを取得する → 他のソースから → ウェブからほら
-
ダイアログに URL を貼り付けます
YOUR_API_KEY鍵を入れると
https://fxmacrodata.com/api/v1/announcements/usd/policy_rate?api_key=YOUR_API_KEY&start=2020-01-01 - クリック わかったJSON構造を表示して開きます.
- 押す データ 拡張するには,それをクリックします. テーブルに変換 ほら わかったほら
-
やってみろ 列を拡張する 上のボタンをクリックします.
Column1嵌入したレコードをフラットコラムに解くヘッダ:dateほらvalほらannouncement_datetimeほら - クリック 閉じる&負荷する テーブルを新しいシートに書き込む
提示: 自動的に更新
右クリックで読み込みテーブル → 表 → 外部データプロパティ → 許可する ファイルを開くときにデータをリフレッシュする 設定する N 分ごとに更新する マクロテーブルは,ワークブックを開くたびに更新されます.
ステップ3
ステップ3 Excel Power Query:再利用可能な関数でパラメータ化
単一指標のクエリが動作すると,それを再利用可能な M 関数にプロモートして Web コネクタ手順を繰り返さずに任意の通貨/インディケーターの組み合わせを抽出できます.
- 左のパネル → 上のクエリを右クリックします 関数を作成するわかった
- 名前言って
FetchMacroDataわかった - 機体には以下のMコードが付きます.
// FetchMacroData — reusable Power Query function
// Parameters: currency (e.g. "usd"), indicator (e.g. "policy_rate"), apiKey, startDate
(currency as text, indicator as text, apiKey as text, startDate as text) =>
let
url = "https://fxmacrodata.com/api/v1/announcements/"
& currency & "/" & indicator
& "?api_key=" & apiKey
& "&start=" & startDate,
raw = Json.Document(Web.Contents(url)),
records = raw[data],
tbl = Table.FromList(records, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
expand = Table.ExpandRecordColumn(tbl, "Column1",
{"date", "val", "announcement_datetime"},
{"Date", "Value", "AnnouncementDatetime"}),
typed = Table.TransformColumnTypes(expand, {
{"Date", type date},
{"Value", type number}
})
in
typed
- 機能編集を閉じて 新しい機能編集を作成します 空のクエリ 必要な各指標について
= FetchMacroData("usd", "inflation", "YOUR_API_KEY", "2022-01-01")
= FetchMacroData("eur", "policy_rate", "YOUR_API_KEY", "2022-01-01")
Each query loads into its own table. The function handles the HTTP call, JSON parse, column rename, and type conversion. To add a new indicator, add one blank query — no connector wizard needed. Find indicator slugs on the API ドキュメント 通貨ペアに
ステップ4
ステップ 4 Excel VBA: 値を直接セルに書き込む
VBA は,特定の名前あるセルに値を置く,既存の式にリンクする,またはボタンをクリックしてリフレッシュを起動する,あるいはワークブックを開くイベントを行うときにより適しています.
VBA エディタを開く (Alt+F11 について追加する (挿入 → モジュール),次の文字を貼り付けます.
Option Explicit
' ─────────────────────────────────────────────────────────────────
' FetchLatestIndicator
' Returns the most recent val for a given currency/indicator.
' Requires a reference to "Microsoft XML, v6.0" (VBA Editor →
' Tools → References → tick "Microsoft XML, v6.0").
' ─────────────────────────────────────────────────────────────────
Function FetchLatestIndicator(currency As String, indicator As String, _
apiKey As String) As Variant
Dim http As New MSXML2.XMLHTTP60
Dim url As String
Dim json As String
Dim dataArr As Variant
Dim parsed As Object
url = "https://fxmacrodata.com/api/v1/announcements/" & _
LCase(currency) & "/" & LCase(indicator) & _
"?api_key=" & apiKey & "&limit=1"
http.Open "GET", url, False
http.setRequestHeader "Accept", "application/json"
http.Send
If http.Status <> 200 Then
FetchLatestIndicator = CVErr(xlErrValue)
Exit Function
End If
' ── Minimal JSON parser (no external library needed) ──────────
' Locate the first "val": number pattern after "data":[{
Dim pos As Long
Dim valStr As String
json = http.responseText
pos = InStr(json, """val"":")
If pos = 0 Then
FetchLatestIndicator = CVErr(xlErrNA)
Exit Function
End If
pos = pos + Len("""val"":")
valStr = Mid(json, pos, 20)
' Trim to the actual number (stop at comma, space, or brace)
valStr = Split(Trim(valStr), ",")(0)
valStr = Split(valStr, "}")(0)
valStr = Trim(valStr)
FetchLatestIndicator = CDbl(valStr)
End Function
' ─────────────────────────────────────────────────────────────────
' RefreshMacroDashboard
' Writes the latest value of several indicators into named cells.
' Define Named Ranges (Formulas → Name Manager) matching the keys
' used in the pairs array below.
' ─────────────────────────────────────────────────────────────────
Sub RefreshMacroDashboard()
Dim apiKey As String
apiKey = "YOUR_API_KEY" ' ← replace with your key
Dim pairs(5, 1) As String
pairs(0, 0) = "usd" : pairs(0, 1) = "policy_rate"
pairs(1, 0) = "eur" : pairs(1, 1) = "policy_rate"
pairs(2, 0) = "gbp" : pairs(2, 1) = "policy_rate"
pairs(3, 0) = "usd" : pairs(3, 1) = "inflation"
pairs(4, 0) = "usd" : pairs(4, 1) = "unemployment"
pairs(5, 0) = "usd" : pairs(5, 1) = "gdp"
Dim i As Integer
Dim val As Variant
Dim nm As String
For i = 0 To 5
val = FetchLatestIndicator(pairs(i, 0), pairs(i, 1), apiKey)
nm = UCase(pairs(i, 0)) & "_" & pairs(i, 1)
On Error Resume Next
ThisWorkbook.Names(nm).RefersToRange.Value = val
On Error GoTo 0
Next i
MsgBox "Dashboard updated — " & Now(), vbInformation, "FXMacroData"
End Sub
ボタンを接続する方法
作業表で, 挿入 → 形状右クリックして描きます
マクロを割り当て →選択する RefreshMacroDashboard自動で起動することもできます. ファイルを開く時に,
Workbook_Open() ほら ほろ ThisWorkbook コードモジュール
PART 2 グーグルシート
第2部 グーグルシート
Google Apps Script は,Google ワークスペースに直接埋め込まれた JavaScript ランタイムです.Google のインフラストラクチャでサーバー側で実行されますので,インストールする必要はありません.FXMacroData を呼び出すには,
UrlFetchApp 計算表に書き込みます SpreadsheetApp自動更新をスケジュールできます. 自動刷新は,
ステップ 5 Apps スクリプトエディタを開きます
- オープン シーツ.グーグル.com ページをクリックして,新しい空白のスプレッドシートを作成します.
- クリック エクステンション → アプリスクリプトわかった
- プロジェクトを 名前変更 FXMacroData ロードヤー (左上部)
- 削除する
myFunction()プレスホルダー
API キーを安全に保存します
行く プロジェクト設定 → スクリプトプロパティ → プロパティを追加名前でプロパティを追加します.
FXMACRODATA_API_KEY 実行時に読みます. 実行中に読みます PropertiesService.getScriptProperties() 鍵は脚本ファイルにはない
ステップ6
ステップ6 検索ヘルパーとシートライターを書いて
入力してください Code.gs. The three functions handle fetching, normalising,
and writing:
// ── Config ──────────────────────────────────────────────────────
const BASE_URL = 'https://fxmacrodata.com/api/v1';
// List of {currency, indicator} pairs to load.
// Add or remove rows to customise your dashboard.
const INDICATORS = [
{ currency: 'usd', indicator: 'policy_rate' },
{ currency: 'usd', indicator: 'inflation' },
{ currency: 'usd', indicator: 'unemployment' },
{ currency: 'eur', indicator: 'policy_rate' },
{ currency: 'gbp', indicator: 'policy_rate' },
{ currency: 'aud', indicator: 'policy_rate' },
];
// ── Fetch helper with retry ─────────────────────────────────────
/**
* Fetches the latest N records for a currency/indicator pair.
* Retries up to maxRetries times with exponential back-off.
*
* @param {string} currency - e.g. 'usd'
* @param {string} indicator - e.g. 'policy_rate'
* @param {string} apiKey
* @param {number} limit - number of records to return (default 12)
* @param {number} maxRetries
* @returns {Array} array of {date, val, announcement_datetime} objects
*/
function fetchIndicator(currency, indicator, apiKey, limit = 12, maxRetries = 3) {
const url = `${BASE_URL}/announcements/${currency}/${indicator}`
+ `?api_key=${apiKey}&limit=${limit}`;
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
const resp = UrlFetchApp.fetch(url, { muteHttpExceptions: true });
if (resp.getResponseCode() === 200) {
return JSON.parse(resp.getContentText()).data || [];
}
} catch (e) {
if (attempt < maxRetries - 1) {
Utilities.sleep(Math.pow(2, attempt) * 1000); // 1 s, 2 s, 4 s
}
}
}
return [];
}
// ── Sheet writer ────────────────────────────────────────────────
/**
* Writes all indicator rows to a sheet named 'MacroData'.
* Creates the sheet if it does not exist; clears it on each run
* so stale rows are removed.
*/
function refreshMacroData() {
const apiKey = PropertiesService.getScriptProperties()
.getProperty('FXMACRODATA_API_KEY');
if (!apiKey) {
throw new Error('FXMACRODATA_API_KEY script property is not set.');
}
const ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheetByName('MacroData');
if (!sheet) {
sheet = ss.insertSheet('MacroData');
}
sheet.clearContents();
// Header row
const headers = ['Currency', 'Indicator', 'Date', 'Value', 'AnnouncementDatetime'];
sheet.appendRow(headers);
// Style header
const headerRange = sheet.getRange(1, 1, 1, headers.length);
headerRange.setBackground('#1e3a5f');
headerRange.setFontColor('#ffffff');
headerRange.setFontWeight('bold');
// Data rows
INDICATORS.forEach(({ currency, indicator }) => {
const records = fetchIndicator(currency, indicator, apiKey);
records.forEach(r => {
sheet.appendRow([
currency.toUpperCase(),
indicator,
r.date,
r.val,
r.announcement_datetime || ''
]);
});
});
// Auto-resize columns for readability
sheet.autoResizeColumns(1, headers.length);
}
ステップ7
ステップ7 実行して確認
- 押す 保存する 編集ツールバーのアイコン (フラッピーディスク)
- 選択する
refreshMacroData実行ボタンの隣の機能のドロップダウン (▶) で - クリック 逃げろ. 最初の実行は,スプレッドシートにアクセスし,外部HTTPリクエストを行うための許可を求めます クリックします 閲覧 → 許可するわかった
- プレスシートに戻る 新しいタブを マクロデータ 列を表示する
| 通貨 | 指示 | 日付 | 価値 | 発表日時 |
|---|---|---|---|---|
| ドル | 政策率 | 2025-03-19 | 4.25 について | 2025-03-19T18:00:00Z |
| ドル | インフレ | 2025-03-12 | 2.8 について | 2025-03-12T12:30:00Z |
| ドル | 失業 | 2025-03-07 | 4.1 医療 | 2025-03-07T13:30:00Z |
ステップ8
ステップ 8 自動更新をトリガーでスケジュールする
タイム・ドライブ・トリガー・コール refreshMacroData 作業の仕方なく スケジュールで
- 画面の画面をクリックします 誘発器 左側バーのアイコン (時計)
- クリック + トリガーを追加 (右下)
- セット 実行する関数を選択する ほら
refreshMacroDataわかった - セット イベントソースを選択 ほら タイム・ドリブンわかった
- セット タイムベースのトリガータイプを選択 ほら 日計わかった
- セット 選択する時間 7時~8時 (ヨーロッパオープン前)
- クリック 保存する触発するリストに表示されます.
提示: リリース日監視の毎時間トリガー
影響が大きい日हरुमा 米国CPI,NFP,または中央銀行の決定 トリガーを切り替える
時計 → 毎時間 API が更新されるとすぐに (通常は公式リリースから数秒以内に) 新しい読み取りを記録します.
インフレ ほら
農地以外の給与
endpoints carry second-level announcement_datetime 読み取りがいつ公開されたかを正確に特定できます
ステップ9
ステップ 9 任意のセルに最新の値を引く
式に足す Code.gs セル式に直接マクロ値を参照したい場合 GOOGLEFINANCE() 銀行データについては:
/**
* Custom Sheets function: returns the latest value for a currency/indicator.
*
* Usage in a cell: =FXMD("usd","policy_rate")
*
* @param {string} currency e.g. "usd"
* @param {string} indicator e.g. "policy_rate"
* @customfunction
*/
function FXMD(currency, indicator) {
const apiKey = PropertiesService.getScriptProperties()
.getProperty('FXMACRODATA_API_KEY');
const records = fetchIndicator(currency, indicator, apiKey, 1);
if (!records || records.length === 0) return null;
return records[0].val;
}
保存した後,入力します =FXMD("usd","policy_rate") フレームは関数を呼び出し,APIから取り出し,現在の値を返します.それを隣接するセル内の通貨ラベルと組み合わせてコンパクトな要約パネルを構築します.
サポートされる指標
FXMacroData カタログからの任意の指標スラグは動作します policy_rateほら
inflationほら unemploymentほら gdpほら pmiほら
retail_sales更に多くの 参照
API ドキュメント 通貨ごとに完全なリストを表示するか,
FX ダッシュボード 視覚的に指標を探索する
── 概要 ──
概要
FXMacroData を Excel と Google Sheets に接続しました:
- Excel パワークエリ 設定可能なM関数で,任意の指標を構造化テーブルに読み込み,ファイルを開く時に更新します.
- Excel VBA をインストールする 各指標の最新の値をボタンを指定できる名前付きのセルに書き込むマクロです
- Google アプリスクリプト a
refreshMacroData()追加して,マクロデータタブを構成する機能です=FXMD()細胞ごとに検索するカスタム式で 自動的にリニューアルされます
複数の指標を層に並べて を加えるようにしましょう
基本インフレ
インフレ率の上昇や 引き下げ
PMI 地域間の成長勢いを比較する.一貫したエンドポイント形は,すべての追加が"行変化であることを意味します. INDICATORS M関数呼び出しです.