An interactive Streamlit app that visualizes a 3D implied volatility surface for options on a chosen stock ticker.
Explore how implied volatility varies across time to expiration and either strike or moneyness.
- Flexible Ticker Symbol: Analyze options for any supported ticker (via Yahoo Finance /
yfinance). - OTM put/call blend: The surface is built from out-of-the-money options on each side (OTM puts below spot, OTM calls above) — the liquid, informative quotes — instead of calls only.
- Configurable Inputs:
- Risk-Free Rate and Dividend Yield: User-defined (scenario testing).
- Strike Range Filter: Choose a strike range as a percentage of spot price.
- Liquidity Filters: Minimum volume, minimum open interest, and maximum bid-ask spread (%).
- Y-Axis Selection: Strike Price or Log-moneyness (\ln(K/F)), where (F = S \cdot e^{(r-q)T}).
- Two surface methods:
- Raw (interpolated) — grid interpolation of the observed IV points.
- SVI fit — an arbitrage-free Gatheral SVI smile fit per expiry for a smooth surface.
- Smile / Skew viewer: 2D implied-vol-vs-strike plot for a chosen expiry, with the SVI fit overlaid.
- Export: Download the IV points as CSV and the surface as an interactive HTML file.
- Fast & cached: Network fetches and IV solves are cached and run in parallel, so moving the sliders is instant.
3D implied volatility surface (put/call blended):
Volatility smile / skew for a single expiry, with the arbitrage-free SVI fit overlaid:
-
Clone the Repository:
git clone https://github.com/George-Dros/Volatility_Surface cd Volatility_Surface -
Create and activate a virtual environment
py -3.12 -m venv .venv .\.venv\Scripts\Activate.ps1
-
Install requirements
pip install -r requirements.txt
-
Run the Streamlit app
streamlit run app.py
-
Data Collection: Fetches call and put option chains, expirations, strikes, and market prices via
yfinance(chains fetched in parallel and cached). -
OTM blend & filtering: Keeps the out-of-the-money side per strike (puts ≤ spot, calls > spot), drops very short-dated expirations, and applies strike/liquidity filters.
-
Implied Volatility Calculation: Solves for σ in the Black–Scholes model (with dividend yield q) using Brent's method, on the mid price (falling back to last price).
-
Surface Construction: Either interpolates the IV points onto a grid, or fits an arbitrage-free SVI smile per expiry, then plots a 3D surface with Plotly.
pip install -r requirements-dev.txt
pytestThe suite covers the Black–Scholes/IV round-trip, time-to-expiry determinism, the OTM-blend + liquidity pipeline, and the SVI fit. It runs in CI (GitHub Actions) on every push and pull request.
-
Data quality depends on Yahoo Finance quotes; some tickers/expirations may return sparse or missing data.
-
The SVI fit enforces no butterfly (per-expiry) arbitrage via parameter bounds, but does not enforce calendar arbitrage across expiries.
-
Volatility Smile / Skew Inspection: Visualize skew patterns across maturities and strikes/moneyness.
-
Scenario Testing: Change r and q to see how assumptions affect the surface.
-
Learning Tool: A quick way to connect option market prices to implied vol behavior.
-
Calendar-arbitrage-free surface fitting (currently only per-expiry butterfly arbitrage is constrained).
-
Greeks display and a term-structure (ATM vol vs. expiry) view.
-
PNG/static image export (currently CSV + interactive HTML).
This project is open-source and available under the MIT License.
Created by Georgios Drosogiannis

