Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Neural Volatility Surface Forecaster

Python PyTorch FastAPI Streamlit QuantLib License

An institutional-style quantitative research platform to model and forecast the implied volatility (IV) surface across strike and expiry dimensions using deep learning.


๐Ÿš€ About The Project

This project treats volatility as a surface evolution problem, not a single-point prediction problem.

Given historical IV surfaces:

  • Input: past N surfaces [time, expiry, strike]
  • Output: future surface [expiry, strike]

The system is designed for:

  • Volatility smile/skew dynamics
  • Term structure shifts
  • Regime transitions
  • Forecast-vs-market visualization

โœจ Key Features

  • ๐Ÿ“ฅ Market Data Ingestion: Pulls options chain snapshots (free default: Yahoo Finance).
  • ๐Ÿงฎ Pricing & IV Engine: Black-Scholes pricing, Greeks, and robust IV inversion (Newton + Brent fallback).
  • ๐Ÿ—บ๏ธ Surface Construction: Strike/expiry grids, interpolation, smoothing, and tensor storage.
  • ๐Ÿง  Neural Forecasting: LSTM, GRU, CNN-LSTM, Transformer, Autoencoder, Conv3D.
  • ๐Ÿ“Š Evaluation Stack: RMSE, MAE, directional skew accuracy, cosine surface similarity.
  • ๐Ÿงช Research Utilities: Regime tagging, feature engineering, notebooks.
  • โšก Serving Layer: FastAPI endpoints + Streamlit dashboard.
  • ๐Ÿ—„๏ธ Persistence: SQLAlchemy + SQLite for raw chains, surfaces, forecasts, and metrics.
Dashboard

๐Ÿ› ๏ธ Tech Stack

Quant & Data

  • numpy, pandas, scipy, statsmodels
  • py_vollib, QuantLib
  • yfinance (default free provider)

ML

  • PyTorch
  • scikit-learn
  • Optional tracking: MLflow

App Layer

  • FastAPI + Pydantic
  • Streamlit
  • Plotly, Matplotlib, Seaborn
  • SQLAlchemy

๐Ÿง  Core Quant Concepts (Quick Glossary)

  • Implied Volatility (IV): Volatility implied by market option prices under Black-Scholes.
  • Smile / Skew: Cross-strike IV shape and directional slope.
  • Term Structure: How IV changes across maturities.
  • Moneyness: Relative strike/spot relationship (K/S or log(K/S)).
  • Risk-Neutral Pricing: Pricing under a measure where discounted prices are martingales.
  • Greeks: Sensitivities (delta, gamma, theta, vega, rho).

๐Ÿ“‚ Project Structure

Neural-Volatility-Surface-Forecaster/
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ raw/
โ”‚   โ”œโ”€โ”€ processed/
โ”‚   โ””โ”€โ”€ cached/
โ”œโ”€โ”€ notebooks/
โ”œโ”€โ”€ configs/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ ingestion/
โ”‚   โ”œโ”€โ”€ pricing/
โ”‚   โ”œโ”€โ”€ iv_surface/
โ”‚   โ”œโ”€โ”€ preprocessing/
โ”‚   โ”œโ”€โ”€ features/
โ”‚   โ”œโ”€โ”€ datasets/
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ training/
โ”‚   โ”œโ”€โ”€ evaluation/
โ”‚   โ”œโ”€โ”€ visualization/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ database/
โ”‚   โ””โ”€โ”€ utils/
โ”œโ”€โ”€ dashboard/
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ docker/
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ main.py
โ””โ”€โ”€ README.md

๐Ÿ—๏ธ Architecture

flowchart LR
    A["Options Data Provider"] --> B["Ingestion + Cache"]
    B --> C["IV Engine (Newton + Brent)"]
    C --> D["Surface Builder (Grid + Interpolation + Smoothing)"]
    D --> E["Surface Tensor Store [T,E,K]"]
    E --> F["Model Training (LSTM/GRU/CNN-LSTM/Transformer/AE/Conv3D)"]
    F --> G["Forecast Surface"]
    F --> H["Evaluation Metrics"]
    D --> I["SQLite via SQLAlchemy"]
    G --> I
    H --> I
    I --> J["FastAPI"]
    I --> K["Streamlit Dashboard"]
Loading

๐Ÿ“Š Streamlit Dashboard (What Each Page Shows)

1) Live options chain

  • Latest contract rows (strike, bid/ask, volume, OI, IV, Greeks).
  • Quick market snapshot (contracts count + median IV).

2) Current IV surface

  • Interactive 3D surface and 2D heatmap.
  • View smile/skew/term-structure shape in one place.

3) Historical surface playback

  • Animated IV surface evolution over time.
  • Great for spotting shock regimes and deformation patterns.

4) Forecasted surface

  • Latest predicted surface from trained model.
  • Term-structure slice compare: predicted vs actual.

5) Model performance

  • Stored run metrics over time.
  • RMSE/MAE trend chart for tracking model quality.

6) Regime analysis

  • Surface feature panel (level/skew/curvature/slope/shock proxy).
  • Cluster-based regime labels and distribution.

โš™๏ธ Local Setup

1) Clone and enter

git clone https://github.com/aryannverse/Neural-Volatility-Surface-Forecaster.git
cd Neural-Volatility-Surface-Forecaster

2) Environment + install

python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

3) Initialize

python main.py

4) Pull surface data

python main.py ingest --ticker SPY
python main.py ingest --ticker SPY --backfill-days 40 --frequency 1D

5) Train

python main.py train --ticker SPY --model transformer --lookback 20 --horizon 1 --epochs 30 --batch-size 32

6) Run services (separate terminals)

python main.py api
python main.py dashboard

๐Ÿ”Œ API Endpoints

  • GET /surface/current/{ticker}
  • GET /surface/history/{ticker}
  • GET /forecast/{ticker}
  • POST /train
  • WS /ws/forecast/{ticker}

Swagger: http://localhost:8000/docs


๐Ÿ’ธ Data Providers

  • Yahoo Finance (yfinance)

Optional integrations

  • Polygon
  • Alpaca

โœ… Testing

PYTHONPATH=. pytest -q

๐Ÿ”ญ Future Extensions

  • Arbitrage-constrained training losses
  • Uncertainty-aware forecasts
  • Regime-conditioned model ensembles
  • Cross-asset transfer learning
  • Volatility strategy overlays

Built with focus, curiosity, and quant obsession by aryannverse โšก

About

An institutional-style quantitative research platform for forecasting the future implied volatility (IV) surface of options markets.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages