mcpField
A
alterlab-usfiscaldata

alterlab-usfiscaldata

github.com/alterlab-ieuデータ・データベース7867 回インストール5 週間前に更新
リポジトリ

alterlab-usfiscaldata について

米国財務省 Fiscal Data REST APIを照会するスキルで、連邦財務データの分析に利用できます。債務、財務省報告書、金利、入札、貯蓄債券を扱い、絞り込み、ページネーション、結果の読み込み例を掲載しています。

主な機能

  1. 01債務と財務省報告書のデータ
  2. 02金利と為替レート
  3. 03入札と貯蓄債券のデータ
  4. 04フィールド選択と絞り込み
  5. 05並べ替えとページ取得

活用シーン

  1. 01連邦債務の推移確認
  2. 02財務省の資金収支の確認
  3. 03入札結果と金利の分析
  4. 04財政データのDataFrameへの読み込み

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/alterlab-ieu/alterlab-academic-skills --skill alterlab-usfiscaldata

インストール後、Claude Code で/alterlab-usfiscaldataを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

evals/
evals.json
references/
api-basics.md
datasets-debt.md
datasets-fiscal.md
datasets-interest-rates.md
datasets-securities.md
examples.md
parameters.md
response-format.md

詳細

米国財務省財政データ API

連邦政府の財務データを提供する、米国財務省の無料オープン REST API です。API キーも登録も不要です。

ベース URL: https://api.fiscaldata.treasury.gov/services/api/fiscal_service

2026-09-23 の確認時点で、カタログには 56 のデータセット/183 のデータテーブルがありました。最新の一覧と各テーブルのエンドポイントのバージョン(v1 または v2)は、https://fiscaldata.treasury.gov/datasets/ をご覧ください。

このスキルを使用する場面

  • 連邦政府の債務(Debt to the Penny、過去の債務残高、連邦債務の明細)
  • 日次および月次の財務省報告書:運転資金残高、預金/引き出し、歳入、歳出、赤字
  • 財務省証券の入札(結果および今後の予定)、平均金利、利息費用
  • 財務省公表為替レート、貯蓄債券、I Bonds の金利
対象外
シナリオ代わりに使用
市場利回り(DGS10)、FF 金利、または FRED ID によるマクロ経済系列とその変換alterlab-fred
商用フィードによる市場相場や日次の FX/暗号資産価格alterlab-alpha-vantage
ヘッジファンドのレバレッジやレポ市場の集計値(Form PF、FICC)alterlab-hedgefund-monitor
SEC EDGAR による企業の提出書類および財務諸表alterlab-edgartools

クイックスタート

import requests
import pandas as pd

BASE_URL = "https://api.fiscaldata.treasury.gov/services/api/fiscal_service"

# Get the current national debt (Debt to the Penny)
resp = requests.get(f"{BASE_URL}/v2/accounting/od/debt_to_penny", params={
    "sort": "-record_date",
    "page[size]": 1
})
data = resp.json()["data"][0]
print(f"Total public debt as of {data['record_date']}: ${float(data['tot_pub_debt_out_amt']):,.0f}")
# Get Treasury exchange rates for recent quarters
resp = requests.get(f"{BASE_URL}/v1/accounting/od/rates_of_exchange", params={
    "fields": "country_currency_desc,exchange_rate,record_date",
    "filter": "record_date:gte:2024-01-01",
    "sort": "-record_date",
    "page[size]": 100
})
df = pd.DataFrame(resp.json()["data"])

認証

不要です。API は完全にオープンで無料です。

主なパラメーター

パラメーター例説明
fields=fields=record_date,tot_pub_debt_out_amt特定の列を選択
filter=filter=record_date:gte:2024-01-01レコードをフィルタリング
sort=sort=-record_date並べ替え(降順にするには先頭に - を付けます)
format=format=json出力形式:json、csv、xml
page[size]=page[size]=1001 ページあたりのレコード数(既定値 100、最大 10000)
page[number]=page[number]=2ページ番号(1 から開始)

フィルター演算子: lt、lte、gt、gte、eq、in

# Multiple filters separated by comma
"filter=country_currency_desc:in:(Canada-Dollar,Mexico-Peso),record_date:gte:2024-01-01"

主なデータセットとエンドポイント

債務
データセットエンドポイント頻度
Debt to the Penny/v2/accounting/od/debt_to_penny日次
Historical Debt Outstanding/v2/accounting/od/debt_outstanding年次
Schedules of Federal Debt/v1/accounting/od/schedules_fed_debt月次
日次および月次の報告書
データセットエンドポイント頻度
DTS Operating Cash Balance/v1/accounting/dts/operating_cash_balance日次
DTS Deposits & Withdrawals/v1/accounting/dts/deposits_withdrawals_operating_cash日次
Monthly Treasury Statement (MTS)/v1/accounting/mts/mts_table_1(16 テーブル)月次
金利および為替
データセットエンドポイント頻度
Average Interest Rates on Treasury Securities/v2/accounting/od/avg_interest_rates月次
Treasury Reporting Rates of Exchange/v1/accounting/od/rates_of_exchange四半期
Interest Expense on Public Debt/v2/accounting/od/interest_expense月次
証券および入札
データセットエンドポイント頻度
Treasury Securities Auctions Data/v1/accounting/od/auctions_query必要に応じて
Treasury Securities Upcoming Auctions/v1/accounting/od/upcoming_auctions必要に応じて
Average Interest Rates/v2/accounting/od/avg_interest_rates月次
貯蓄債券
データセットエンドポイント頻度
I Bonds Interest Rates/v1/accounting/od/i_bonds_interest_rates半年ごと
U.S. Treasury Savings Bonds: Issues, Redemptions & Maturities/v1/accounting/od/savings_bonds_report月次

レスポンスの構造

{
  "data": [...],
  "meta": {
    "count": 100,
    "total-count": 3790,
    "total-pages": 38,
    "labels": {"field_name": "Human Readable Label"},
    "dataTypes": {"field_name": "STRING|NUMBER|DATE|CURRENCY"},
    "dataFormats": {"field_name": "String|10.2|YYYY-MM-DD"}
  },
  "links": {"self": "...", "first": "...", "prev": null, "next": "...", "last": "..."}
}

注: すべての値は文字列として返されます。必要に応じて(例:float()、pd.to_datetime())変換してください。Null 値は文字列 "null" として表示されます。

よくあるパターン

すべてのページを DataFrame に読み込む
def fetch_all_pages(endpoint, params=None):
    params = dict(params or {})
    params["page[size]"] = 10000  # the API maximum; larger values return HTTP 400
    params["page[number]"] = 1
    rows = []
    while True:
        resp = requests.get(f"{BASE_URL}{endpoint}", params=params, timeout=60)
        resp.raise_for_status()
        result = resp.json()
        rows.extend(result["data"])
        if params["page[number]"] >= result["meta"]["total-pages"]:
            break
        params["page[number]"] += 1
    return pd.DataFrame(rows)
集計(自動合計)

グループ化フィールドを省略すると、自動的に集計されます。

# Sum all deposits/withdrawals by record_date and transaction type
resp = requests.get(f"{BASE_URL}/v1/accounting/dts/deposits_withdrawals_operating_cash", params={
    "fields": "record_date,transaction_type,transaction_today_amt"
})

リファレンスファイル

  • api-basics.md — URL 構造、HTTP メソッド、バージョン管理、データ型
  • parameters.md — すべてのパラメーターの詳細な例とエッジケース
  • datasets-debt.md — 債務データセット:Debt to the Penny、Historical Debt、Schedules of Federal Debt、TROR
  • datasets-fiscal.md — Daily Treasury Statement、Monthly Treasury Statement、歳入、支出
  • datasets-interest-rates.md — 平均金利、為替レート、TIPS/CPI、認定金利
  • datasets-securities.md — 米国債オークション、貯蓄債券、SLGS、買い戻し
  • response-format.md — レスポンスオブジェクト、エラー処理、ページネーション、レスポンスコード
  • examples.md — 一般的なユースケース向けの Python、R、pandas のコード例

データセット名、テーブル、取得日を記載してください(Fiscal Data の値は改訂されるため、使用した record_date を保持してください)。

AlterLab Academic Skills スイートの一部です。

コメント