Python ivsurface package: real options data (yfinance), Black-Scholes pricing, SVI/SSVI/Heston calibration, Monte Carlo, and Streamlit app.
IVSurface (ivsurface) is an open-source educational project to build and calibrate an implied volatility surface from real options data. The package covers options chain ingestion and cleaning (via yfinance), Black-Scholes pricing and IV inversion, SSVI calibration (coherent global surface), slice-by-slice SVI, the Heston model (Carr-Madan), plus Monte Carlo simulations and delta-hedging.
Interactive Streamlit app, tutorial notebooks, and a full pytest suite. Public code: khonen-git/ImpliedVolatilitySurface.
pip install -e .) with ruff lint and local CIImplied volatility compresses options market information beyond spot moves. For a quant profile focused on FX research, this project complements my EURUSD lab by exploring the derivatives side: option pricing and term/moneyness structure.
Unlike the private lab, all code is public: data fetched on demand (SPY by default), local parquet cache, no IP constraints.
^IRX (3M) → ^TNX (10Y), linear interpolation in maturityshort / long / mixed modes via FetchConfigprepare_options_chain() cleans bid/ask, filters outlier strikes, and returns a calibration-ready DataFrame. Chains cache under data/cache/ (not versioned).
Cleaned market → Implied volatility
├── SSVI (coherent global surface, primary)
├── Raw SVI (slice-by-slice fit, smile comparison)
├── Heston (dynamic model, calibrated on mid prices)
└── Market / SSVI / SVI / Heston comparison (Streamlit, notebooks)
ivsurface.pricing module: vanilla pricing, sensitivities (delta, gamma, vega, theta, rho), and numerical IV inversion. Starting point of notebook 01_black_scholes.ipynb.
Main API:
from ivsurface.viz import run_svi_pipeline, run_heston_pipeline, run_full_pipeline
svi = run_svi_pipeline(df, stats)
sigma = svi.svi_surface(t_years, log_moneyness)
heston = run_heston_pipeline(df, stats)
result = run_full_pipeline(df, stats, heston_use_svi_guess=True)
heston_use_svi_guess=True)simulation module: Monte Carlo, delta-hedging, simplified exotic pricing (notebook 05_simulation_hedging.ipynb)streamlit run src/ivsurface/viz/app.py
Two modes:
data/cache/{TICKER}_clean_*.parquetPlotly visualizations: 2D/3D smiles, model comparison, fit diagnostics.
| Notebook | Content |
|---|---|
01_black_scholes.ipynb | BS pricing, Greeks, IV inversion |
02_iv_surface.ipynb | IV surface, 2D interpolation |
03_svi_calibration.ipynb | SVI calibration by maturity |
04_heston.ipynb | Heston Carr-Madan, SVI vs market |
05_simulation_hedging.ipynb | Heston Monte Carlo, delta-hedge, exotics |
[viz] extra required for Plotly/Matplotlib; [dev] for pytest and ruff.
pytest # all tests
pytest -m integration # network (yfinance)
pytest -m "not integration" # local only (CI)
integration markers isolate network tests; local CI runs the non-integration suite.
src/ and tests/pip install -e ".[dev,viz]"uv sync --extra dev --extra vizsrc/ivsurface/
├── data/ # fetch & cleaning
├── pricing/ # Black-Scholes, Greeks, IV
├── surface/ # grid & interpolation
├── models/ # SVI, SSVI, Heston
├── simulation/ # Monte Carlo, hedging, exotics
└── viz/ # Plotly & Streamlit
Python 3.11+
yfinance · pandas · parquet cache
SciPy (optimization) · Carr-Madan FFT · SVI/SSVI calibration
Plotly · Matplotlib · Streamlit
pytest · ruff · integration markers
python scripts/fetch_spy.pyThis project is deliberately educational: it does not target production options trading, but hands-on understanding of IV surfaces and industry-standard models. It complements my quant profile with an equity derivatives building block, distinct from tick-level FX research.
src/ layout), [dev] / [viz] extrasrun_full_pipeline)Python Documentation
Official Python language documentation
SciPy
Scientific algorithms: optimization, statistics, linear algebra
Jupyter
Interactive notebooks for data exploration and research
Matplotlib
Data visualization and plotting in Python
Quant Guild
Resources to master quantitative finance