Quantitative finance platform for options pricing, volatility arbitrage, and interactive market analysis.
Volatility arbitrage system that exploits mispricing between implied and realized volatility.
Core components:
- Heston FFT pricer (0.00-0.03% error after fixing Carr-Madan implementation bugs)
- Event-driven backtester with portfolio Greeks
- Interactive dashboard for parameter exploration
PYTHONPATH=./src:. python3 backend/main.py
# Backend at http://localhost:8000
# API docs at http://localhost:8000/docscd frontend
npm install # First time only
npm run dev
# Dashboard at http://localhost:5173PYTHONPATH=./src:. python3 -m pytest tests/ -vVolatility arbitrage trades the magnitude of price movement rather than direction. The edge comes from forecasting realized volatility more accurately than the market's implied volatility.
Basic mechanics:
- Buy straddles when your forecast > implied vol
- Delta hedge daily to stay directionally neutral
- Profit via gamma scalping as the underlying moves
P&L driver: realized_vol > implied_vol + theta_cost
Heston (1993) stochastic volatility model with Carr-Madan (1999) FFT pricing. Implementation at research/lib/heston_fft.py.
Accuracy (after fixing Carr-Madan bugs, see below):
- ATM: 0.0000% error
- ITM/OTM: 0.0002-0.03% error
- Speed: 10-100x faster than numerical integration
from research.lib.heston_fft import HestonFFT
heston = HestonFFT(
v0=0.04, theta=0.05, kappa=2.0,
sigma_v=0.3, rho=-0.7, r=0.05, q=0.02
)
call = heston.price(S=100, K=110, T=1.0, option_type="call")FastAPI backend + React 18 + Plotly.js frontend. Real-time parameter exploration with LRU caching (80% hit rate, <5ms cache hits).
API:
POST /api/v1/heston/price-surface
GET /api/v1/heston/cache/stats
DELETE /api/v1/heston/cache
Event-driven multi-asset engine at src/volatility_arbitrage/backtest/multi_asset_engine.py.
- Portfolio Greeks (delta, gamma, vega, theta)
- Option expiration handling
- Commission and slippage modeling
from volatility_arbitrage.backtest.multi_asset_engine import MultiAssetEngine
engine = MultiAssetEngine(initial_capital=100000, commission=0.50, slippage=0.01)
engine.execute_trade(symbol="SPY", asset_type="option", quantity=10, price=12.50, ...)
greeks = engine.portfolio_greeks(spot=450, vol=0.20, r=0.05, q=0.02)Base class at src/volatility_arbitrage/strategy/base.py.
Included strategies:
- Volatility mean reversion (z-score extremes)
- Realized vs implied (classic vol arb)
- Term structure arbitrage
- Delta-neutral vol trading (gamma scalping)
backend/ FastAPI REST API
frontend/ React + Plotly.js dashboard
src/volatility_arbitrage/
├── backtest/ Event-driven backtesting
├── strategy/ Trading strategies
├── models/ Heston, Black-Scholes
└── core/ Types, config
research/lib/ Pricing implementations (heston_fft.py)
tests/ 71 tests
config/ YAML configurations
# Backend
pip install fastapi uvicorn numpy pandas scipy pydantic pyyaml
# or: poetry install
# Frontend
cd frontend && npm install| Component | Latency |
|---|---|
| FFT pricing (cache miss) | 150-300ms |
| FFT pricing (cache hit) | <5ms |
| Greeks calculation | <1ms/position |
| Backtest (1 year daily) | 2-5s |
PYTHONPATH=./src:. python3 -m pytest tests/ -v71 tests: multi-asset engine (14), core types (24), Black-Scholes (16), Heston (17).
Pricing model:
- Market impact modeled linearly (no square-root impact)
- No discrete dividend handling (assumes continuous yield)
- Heston calibration assumes stationary vol-of-vol
Backtester:
- Fill simulation assumes immediate execution at mid
- No bid-ask spread modeling for options
- Greeks computed at trade time, not continuously
Data:
- Historical IV from EOD snapshots, not tick-level
- No handling for option early exercise (American vs European)
Historical options data from public sources (OptionMetrics, CBOE). Raw files excluded from version control.
- Heston (1993), "A Closed-Form Solution for Options with Stochastic Volatility"
- Carr & Madan (1999), "Option Valuation using the Fast Fourier Transform"
- Lord & Kahl (2006), "Optimal Fourier Inversion in Semi-Analytical Option Pricing"
MIT