Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

FRED Analyzer

Fetch any FRED economic time series and analyze macro trends — inflation, money supply, employment, yields, credit spreads — all from a single command.

py fred_analyzer.py --api-key YOUR_KEY --series CPIAUCSL:CPI PCEPI:PCE --start 2018-01-01 --plot

Features

  • Any FRED series — CPI, PCE, M2, nonfarm payrolls, Treasury yields, corporate bond spreads, money supply, and 800,000+ more
  • Multi-series merge — combine any number of series into one DataFrame (outer-joined on date)
  • Spread calculator — subtract a baseline series (e.g., 10Y Treasury) to compute credit spreads
  • Missing data handled — NaN for missing dates, bad series IDs reported without crashing
  • Plot flag — optional matplotlib chart with --plot

Setup

pip install fredapi pandas matplotlib

Get a free FRED API key: https://fred.stlouisfed.org/docs/api/api_key.html

Usage

# Compare CPI vs PCE inflation
py fred_analyzer.py --api-key YOUR_KEY --series CPIAUCSL:CPI PCEPI:PCE --start 2018-01-01

# Money supply M0, M1, M2
py fred_analyzer.py --api-key YOUR_KEY --series BOGMBASE:M0 M1SL:M1 M2SL:M2 --start 2015-01-01 --plot

# Credit spreads: AAA and BBB vs 10Y Treasury
py fred_analyzer.py --api-key YOUR_KEY --series BAMLC0A0CMEY:AAA BAMLC0A4CBBBEY:BBB DGS10:10Y_Treasury --baseline 10Y_Treasury --start 2020-01-01 --plot

# Nonfarm payrolls
py fred_analyzer.py --api-key YOUR_KEY --series PAYEMS:Nonfarm_Payrolls --start 2018-01-01

# High yield credit spreads (OAS)
py fred_analyzer.py --api-key YOUR_KEY --series BAMLH0A0HYM2:HY_OAS DGS10:10Y_Treasury --start 2022-01-01

# Custom: any series IDs
py fred_analyzer.py --api-key YOUR_KEY --series DGS2:2Y_Treasury DGS10:10Y_Treasury T5YIE:5Y_BE_Inflation --start 2020-01-01

Parameters

Argument Required Description
--api-key Yes FRED API key
--series Yes Space-separated ID:Name pairs
--baseline No Name to subtract for spread columns
--start No Start date (e.g., 2020-01-01)
--plot No Show matplotlib chart
--rows No Tail rows to print (default: 10)

As a Python Library

from fred_analyzer import fetch_series

df = fetch_series("YOUR_API_KEY", [
    {"id": "CPIAUCSL", "name": "CPI"},
    {"id": "PCEPI", "name": "PCE"},
], start_date="2020-01-01")

print(df.tail())

As an OpenCode Skill

The .opencode/skills/fred-analyzer/SKILL.md file lets AI agents use this tool via natural language queries like:

  • "Pull CPI and PCE from 2018 to compare inflation"
  • "Analyze AAA and BBB credit spreads vs 10Y Treasury"
  • "Fetch M0, M1, M2 money supply from 2015"

Common FRED Series IDs

Series ID Description
CPI CPIAUCSL Consumer Price Index, All Items
PCE PCEPI Personal Consumption Expenditures Price Index
M2 M2SL M2 Money Supply
M1 M1SL M1 Money Supply
Monetary Base BOGMBASE Monetary Base (M0)
Nonfarm Payrolls PAYEMS Total Nonfarm Payrolls
10Y Treasury DGS10 10-Year Treasury Yield
2Y Treasury DGS2 2-Year Treasury Yield
5Y Treasury DGS5 5-Year Treasury Yield
AAA Corp Yield BAMLC0A0CMEY ICE BofA AAA Effective Yield
BBB Corp Yield BAMLC0A4CBBBEY ICE BofA BBB Effective Yield
HY OAS BAMLH0A0HYM2 ICE BofA High Yield OAS
Fed Funds Rate FEDFUNDS Effective Federal Funds Rate
Unemployment UNRATE Civilian Unemployment Rate
GDP GDP Gross Domestic Product

Data Source

All data from the Federal Reserve Bank of St. Louis FRED API — 800,000+ economic time series, free and public.

https://fred.stlouisfed.org/

About

query Fred data for analysis

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages