Skip to content

corbin-r/sector-tracker

Repository files navigation

S&P 500 Sector IV Tracker

A Rust web application that tracks S&P 500 sectors and monitors implied volatility (IV) correlations between each sector.

Features

  • Sector overview: List of 11 S&P 500 sectors with SPDR ETF tickers
  • Implied volatility: Current IV per sector from options on sector ETFs (Yahoo Finance)
  • IV correlation matrix: Pearson correlation of IV across sectors over a rolling window

Tech Stack

  • Backend: Rust, Axum, Tokio
  • Data sources: Yahoo Finance (options/IV), Financial Modeling Prep (S&P 500 constituents, sector performance)
  • Frontend: Static HTML, CSS, JavaScript

Prerequisites

  • Rust (1.70+)
  • FMP API key for sector/constituent data (IV uses Yahoo, no key needed)

Setup

  1. Clone the repository and enter the directory:

    cd sector-tracker
  2. Copy the example environment file:

    cp .env.example .env
  3. Get an API key from Financial Modeling Prep and add it to .env:

    FMP_API_KEY=your_api_key_here
    

    Without the FMP key, the app will still run but:

    • /api/sectors will return sectors without performance data
    • /api/sectors/:id/constituents will fail (requires FMP)

    IV data from Yahoo Finance works without any API key.

  4. Build and run:

    cargo run
  5. Open http://localhost:3000 in your browser.

API Endpoints

Method Path Description
GET /api/health Health check
GET /api/sectors List sectors (optionally with performance)
GET /api/sectors/:id/constituents S&P 500 constituents by sector
GET /api/iv/sectors Current IV per sector
GET /api/iv/correlations IV correlation matrix

Sector IDs use kebab-case, e.g. consumer-discretionary, health-care.

Configuration

Environment variables (see .env.example):

  • FMP_API_KEY (required for FMP features)
  • BIND_ADDRESS (default: 0.0.0.0:3000)
  • CACHE_TTL_CONSTITUENTS_SECS (default: 86400)
  • CACHE_TTL_SECTOR_PERFORMANCE_SECS (default: 1800)
  • CACHE_TTL_IV_SECS (default: 600)
  • CORRELATION_WINDOW_DAYS (default: 30)
  • RUST_LOG (default: info)

Data Notes

  • IV: Fetched from Yahoo Finance options API for the 11 SPDR sector ETFs (XLC, XLY, XLP, XLE, XLF, XLV, XLI, XLB, XLRE, XLK, XLU). ATM options are used to derive sector IV.
  • Correlations: Built from IV snapshots. Call /api/iv/sectors several times (over hours/days) to build history; correlations require at least 2 snapshots.

License

MIT

About

WIP Sector by Sector Volatility Tracker for S&P500

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published