Skip to content

Timothy-ZZZZ-bit/volforge

Repository files navigation

VolForge

Arbitrage-free volatility surface construction and equity exotics pricing on real listed options data: SVI/SSVI calibration, Dupire local vol, Heston, Monte Carlo + PDE engines, and desk-style risk — with every number cross-validated by an independent method.

CI Python 3.11+ License: MIT

VolForge is the sell-side counterpart to QuantForge: where QuantForge covers systematic portfolio research, VolForge covers the derivatives-desk stack — from raw option quotes to an arbitrage-free surface, calibrated models, exotics pricing, and the model-risk question desks actually argue about.

The headline result

Two models. Both calibrated to the same real SPY option chain (bundled snapshot, 2026-06-10, 2,104 cleaned OTM quotes across 14 expiries). Both reprice the vanilla surface. They disagree on a 1y autocallable by +1.04 per 100 notional — 29× the Monte Carlo noise.

Model risk on the Athena autocallable

model (same smile) PV per 100 notional 99% CI
Dupire local vol (log-Euler MC) 100.00 ±0.07
Heston, calibrated (Andersen QE MC) 101.04 ±0.06

That spread is not calibration error — it is the product's exposure to forward smile dynamics, which vanillas do not pin down. Local vol freezes today's smile into a deterministic σ(S, t); Heston regenerates smile through stochastic variance. They agree on every European option and still imply different joint laws for (min S, S_T) — exactly what an autocallable's barrier loads on. Quantifying that spread is the daily business of equity exotics desks (full write-up).

What's inside

layer contents
volforge.data chain cleaning with per-reason drop accounting; forwards and discounts inferred jointly from put-call parity (no rate curve assumed); OTM implied vols
volforge.surface quasi-explicit SVI slices (Zeliade reduction); global SSVI with Gatheral–Jacquier no-butterfly constraints; Durrleman g diagnostics; analytic Dupire local vol (the Dupire denominator is Durrleman's g — one computation serves both)
volforge.models Heston: hardened little-trap CF, adaptive put-side COS pricing, independent Lewis-transform cross-check, DE + least-squares calibration
volforge.engines MC: GBM exact/Euler/Milstein, Andersen QE with martingale correction, local-vol paths, antithetic/control variates, scrambled Sobol' with Brownian-bridge ordering; PDE: Crank–Nicolson + Rannacher, penalty-method American, barrier-snapped grids
volforge.analytic Reiner–Rubinstein barriers, digitals, discrete geometric Asians, Rubinstein chooser
volforge.instruments path payoffs with Brownian-bridge barrier correction; Athena autocallable; variance swaps via VIX-style log-contract replication
volforge.risk bump / pathwise / likelihood-ratio Greeks (with documented failure modes); spot×vol scenario ladders

Real-data results (bundled SPY snapshot)

Surface. Global SSVI (ρ = −0.60, η = 0.84, γ = 0.57) fit to all 2,104 quotes: 0.25–0.5 vol-point RMSE for every expiry beyond six months, degrading to 1–3 points in sub-month wings — the stated price of a 3-parameter global skew with guaranteed butterfly- and calendar-arbitrage-freeness (0 violations on the fitted surface; the listed refinement is eSSVI). ATM term structure is matched exactly by construction.

SPY smiles vs SSVI

Heston. Calibrated to the same chain: v0 = 0.047, κ = 11.5, θ = 0.047, σ = 3.0, ρ = −0.72; Feller ratio 0.12 (violated — routine for equity index). σ pins its bound chasing short-dated skew, which is precisely the documented reason desks moved to local-stochastic-vol mixtures. Sub-0.8 vol-point RMSE beyond six months.

Variance swaps. VIX-style replication on raw quotes vs a dense strip off the fitted surface: fair vol sits a consistent 3–4 points above ATM implied (the skew premium); the long-maturity gap between the two strips measures listed-strike truncation.

Variance swap term structure

Consistency loop. Dupire local vol extracted analytically from the fitted SPY surface, simulated through the MC engine, reprices the surface's own vanillas within 50bp of vol — the defining self-consistency test of a local-vol setup, run in CI on the real snapshot.

Validation culture

Every number is checked against something that cannot share its bugs:

  • COS vs Lewis transform vs Riccati ODE integration — three independent Heston routes agreeing to ~1e-9 (prices) and 1e-12 (CF), including Feller-violating stress parameters;
  • closed forms vs Monte Carlo — barriers vs Brownian-bridge-corrected MC, chooser vs two-stage MC, geometric Asians vs path simulation;
  • PDE vs binomial vs analytic — American puts within 0.15% of an independent 2,500-step CRR tree; barriers vs Reiner–Rubinstein on barrier-snapped grids;
  • measured convergence orders — Milstein strong ≈ 1, Euler strong ≈ 0.5, Crank–Nicolson joint order ≈ 2, asserted as fitted slopes, not assumed;
  • identities — put-call parity, in-out parity, digital replication, martingale tests under Feller violation, ATM total-variance identity.

Some of these checks earned their keep during development: an early Heston quadrature checker produced negative deep-OTM prices (slowly-decaying oscillatory integrands) and was caught by an MC arbiter and replaced with the Lewis transform; the COS expansion originally priced the call payoff directly and lost catastrophically to e^b coefficient cancellation on fat-tailed parameter sets — it now prices the bounded OTM put and recovers calls via exact parity. The test suite is written so that the next such bug cannot land silently. 116 tests, all offline, ~20s.

Quickstart

git clone https://github.com/Timothy-ZZZZ-bit/volforge && cd volforge
python -m venv .venv && .venv/bin/pip install -e ".[dev]"

.venv/bin/python -m pytest             # full validation suite, ~20s, no network
.venv/bin/python examples/01_build_surface.py          # real-data surface + diagnostics
.venv/bin/python examples/02_calibrate_heston.py       # Heston calibration (~4 min)
.venv/bin/python examples/03_model_risk_autocallable.py  # the headline study
.venv/bin/python examples/04_variance_swap.py          # replication term structure

Examples run straight from a clone (no install needed) against the bundled snapshot; scripts/fetch_snapshot.py pulls a fresh chain (requires pip install -e ".[data]").

from volforge.data.chain import load_snapshot, clean_chain
from volforge.data.forwards import infer_forwards
from volforge.data.iv import chain_implied_vols
from volforge.surface.ssvi import fit_ssvi
from volforge.surface.local_vol import LocalVolSurface

snap = load_snapshot()                      # bundled SPY chain
cleaned = clean_chain(snap)
forwards = infer_forwards(cleaned)          # (F, df) per expiry from parity
points = chain_implied_vols(cleaned, forwards)
surface, report = fit_ssvi(points, forwards)
local_vol = LocalVolSurface(surface)        # sigma_loc(S, t), analytic Dupire

Limitations, stated plainly

  • The discount factor is only weakly identified from American-style quotes. SPY options carry early-exercise premium that tilts the parity regression; VolForge identifies the forward robustly, projects df onto a feasible band, and documents that q_implied is a carry residual, not a dividend forecast. All pricing consumes the (F, df) pair jointly, so surfaces are unaffected.
  • Global SSVI is parsimonious by design. Three skew parameters cannot match 1-week wings and 2-year skew simultaneously; per-expiry errors are published above rather than averaged away.
  • Heston's short-end misfit is structural, not an optimizer failure — the calibration report shows σ at its bound. The honest fix is LSV, which is out of scope here.
  • KI monitoring is discrete (daily simulation grid), matching how the contract is monitored in practice; this is stated on the instrument rather than silently approximated.
  • One snapshot, EOD quotes. The pipeline is built to re-run on any fresh chain, but the bundled results are a single date — they demonstrate methodology, not a production marking system.

Repository map

volforge/         the library (data / surface / models / engines / analytic / instruments / risk)
tests/            116 validation tests, including the real-snapshot consistency loop
examples/         four runnable studies producing everything in reports/
reports/          committed artifacts of the example runs (figures, calibrated params, write-up)
docs/methodology/ the math, conventions, and validation design, written to be read
scripts/          snapshot fetcher (yfinance)

References

Gatheral & Jacquier (2014), Arbitrage-free SVI volatility surfaces · Gatheral (2006), The Volatility Surface · Andersen (2008), Efficient simulation of the Heston model · Fang & Oosterlee (2008), A novel pricing method based on Fourier-cosine expansions · Lewis (2001), A simple option formula for general jump-diffusion and other exponential Lévy processes · Albrecher, Mayer, Schoutens & Tistaert (2007), The little Heston trap · Lord, Koekkoek & van Dijk (2010), A comparison of biased simulation schemes · De Marco & Martini / Zeliade (2009), Quasi-explicit calibration of Gatheral's SVI · Reiner & Rubinstein (1991), Breaking down the barriers · Rubinstein (1991), Options for the undecided · Demeterfi, Derman, Kamal & Zou (1999), More than you ever wanted to know about volatility swaps · Forsyth & Vetzal (2002), Quadratic convergence for valuing American options · Glasserman (2004), Monte Carlo Methods in Financial Engineering · Huang, Wang & Wan (2021), Exploration of JPMorgan chooser option pricing (the chooser here replaces their simulation step with Rubinstein's closed form)

License

MIT — see LICENSE.

About

Arbitrage-free volatility surfaces and equity exotics pricing on real options data: SSVI calibration, Dupire local vol, Heston (COS/QE), Monte Carlo + PDE engines, and model-risk studies

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages