Fed Fund Rate Tracker

View the Project on Github
README.md

Federal Funds Rate Analytics Platform

A financial analytics platform for tracking and analyzing Federal Reserve interest rate changes. This system provides real-time insights into monetary policy trends through automated data collection, advanced analytics, and interactive visualizations.

Architecture

flowchart TD %% External Data Source AV[Alpha Vantage API] %% Docker Containers subgraph DOCKER1[🐳 FastAPI Container] ETL[ETL Pipeline
Extract β†’ Transform β†’ Load] API[FastAPI Backend
REST API & Analytics] ETL -.-> API end subgraph DOCKER2[🐳 PostgreSQL Container] DB[(PostgreSQL Database
Federal Funds Data)] end subgraph DOCKER3[🐳 Dashboard Container] DASH[Flask Dashboard
Interactive Charts] end %% Data Flow AV -->|Fetch Data| ETL ETL -->|Store Data| DB DB <-->|Query Data| API API <-->|REST API| DASH %% Styling classDef external fill:#e3f2fd,stroke:#1976d2,stroke-width:2px,color:#000; classDef container fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#000; classDef storage fill:#e8f5e9,stroke:#388e3c,stroke-width:2px,color:#000; classDef frontend fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#000; %% Arrow styling linkStyle 0 stroke:#1976d2,stroke-width:3px,color:#000 linkStyle 1 stroke:#388e3c,stroke-width:3px,color:#000 linkStyle 2 stroke:#1976d2,stroke-width:3px,color:#000 linkStyle 3 stroke:#f57c00,stroke-width:3px,color:#000 class AV external; class DOCKER1,DOCKER2,DOCKER3 container; class DB storage; class DASH frontend;

Tech Stack

  • Backend: Python 3.11, FastAPI, SQLAlchemy
  • Database: PostgreSQL 15
  • Frontend: Flask, Plotly.js
  • Containerization: Docker, Docker Compose
  • Data Processing: Pandas, NumPy
  • API: Alpha Vantage Federal Reserve Data
  • Scheduling: Python Schedule

Quick Start

Prerequisites

  • Docker and Docker Compose
  • Alpha Vantage API key (free at alphavantage.co)

Setup and Run

  1. Clone the repository

git clone https://github.com/utkuyucel/fundratetracker.git cd fundratetracker

  1. Configure environment

cp .env.example .env # Edit .env to add your Alpha Vantage API key

  1. Start all services

docker-compose up -d

  1. Access the applications

  2. Dashboard: http://localhost:5001

  3. API Documentation: http://localhost:8000/docs

  4. Test the API

curl http://localhost:8000/health curl http://localhost:8000/api/rates/latest

Project Structure

fundratetracker/
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Dockerfile              # FastAPI app Dockerfile
β”œβ”€β”€ .env.example
β”œβ”€β”€ README.md
β”œβ”€β”€ app/                    # FastAPI backend service
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ etl_pipeline.py
β”‚   β”œβ”€β”€ database.py
β”‚   β”œβ”€β”€ analytics.py
β”‚   β”œβ”€β”€ scheduler.py
β”‚   └── requirements.txt
β”œβ”€β”€ dashboard/              # Flask dashboard service
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ app.py
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ templates/
β”‚   └── static/
└── sql/
    └── init.sql

API Endpoints

Core Endpoints

  • GET / - API information and version
  • GET /health - Health check status

Data Endpoints

  • GET /api/rates/latest - Get the most recent Federal Funds Rate
  • GET /api/rates/historical - Historical data with optional date filtering
  • Query params: start_date, end_date, limit
  • Date format: YYYY-MM-DD

Analytics Endpoints

  • GET /api/analytics/summary - Comprehensive statistical summary
  • GET /api/analytics/moving-averages - Moving averages (30, 90, 365 days)

Pipeline Management

  • POST /api/pipeline/trigger - Manually trigger ETL pipeline

Monitoring and Logs

# View all service logs
docker-compose logs -f

# View specific service logs
docker-compose logs -f app
docker-compose logs -f postgres
docker-compose logs -f dashboard

# Check service status
docker-compose ps

Data Initialization

The project includes automatic database initialization:

  • SQL Schema: The sql/init.sql file contains all necessary table definitions and indexes
  • Auto-Setup: When PostgreSQL starts for the first time, it automatically executes the initialization script
  • Data Population: The ETL pipeline will populate data from Alpha Vantage API when triggered

Manual Data Population (Optional)

If you want to immediately populate data without waiting for the scheduler:

# Trigger ETL pipeline manually via API
curl -X POST http://localhost:8000/api/pipeline/trigger

# Or run ETL directly inside the container
docker-compose exec app python -c "import asyncio; from etl_pipeline import FedRateETL; asyncio.run(FedRateETL().run_pipeline())"

Troubleshooting

Common Issues

  1. API Key Not Set: Ensure your Alpha Vantage API key is properly set in .env
  2. Database Connection: Check PostgreSQL health with docker-compose logs postgres
  3. Port Conflicts: Ensure ports 5432, 8000, and 5001 are available
  4. API Rate Limits: Alpha Vantage has rate limits; the ETL includes error handling

Health Checks

# Check API health
curl http://localhost:8000/health

# Check dashboard health  
curl http://localhost:5001/health

# Check database connection
docker-compose exec postgres pg_isready -U dataeng -d fed_analytics

License

This project is licensed under the MIT License.