stochvolmodels¶
Author: Artur Sepp / First recorded: 2026-08-16
Implemented in stochvolmodels. Software citation: CITATION.cff.
stochvolmodels is a Python library for pricing European options under stochastic volatility. It prices vanilla, inverse and quadratic-variance options by Fourier inversion of a closed-form moment generating function, checks the analytic prices against a Monte Carlo simulation of the same dynamics, and calibrates the models to option chains. It is the reference implementation of the log-normal stochastic volatility model with quadratic drift, with the Heston model as benchmark. Its core depends on no sibling package other than vanilla-option-pricers.
The provisional stochvolmodels.pde_solvers module provides PDE1DSolver and PDE2DADISolver
for evolving option values backward or densities forward. The 2.21.0.dev7 source checkout
also supports partial integro-differential equations (PIDEs) with exponential jumps.
The two-name example computes the probability that both names stay above their default
barriers under shared and individual jumps. Two-name survival example ·
Exponential-jump API
To price a chain of European calls and puts under the money-market measure, use the opt-in LogSvPdePricer.
Solver guide ·
LogSV PDE pricing ·
Local volatility and LSV ·
API reference
Start here¶
Install stochvolmodels and price a first option. The core installation command is
python -m pip install stochvolmodels, and the first example runs offline.Keep the notation and conventions at hand: the paper symbols mapped to code, units, option types, the MMA and inverse measures, the option-chain layout, Monte Carlo seeds and the stability tiers are defined there once for every page.
Browse the analytics gallery for every figure with its question, data and producer, or the examples and recipes for every runnable script, its data requirements and the page it supports.
The model in one picture¶
Under the money-market-account measure, the log-normal stochastic volatility model of Sepp and Rakhmonov (2023, Eq. (3.12)) drives the spot price \(S_t\) with a volatility \(\sigma_t\) that mean reverts with a quadratic drift:
The volatility beta \(\beta\) sets the sign of the return-volatility correlation, and the quadratic term \(\kappa_2\) permits a positive \(\beta\) without losing the martingale property, provided \(\kappa_2 \ge \beta\). Options are priced by inverting the moment generating function (MGF) of the log price, which an affine expansion gives in closed form up to a system of ordinary differential equations.
flowchart TB
P["Model parameters"] --> D["Volatility dynamics"]
D --> M["MGF by affine expansion"]
M --> F["Fourier inversion"]
D --> S["Monte Carlo simulation"]
F --> V["Prices and implied volatilities"]
S -- "independent check" --> V
C["Market option chain"] --> K["Calibration"]
V --> K
K -- "fitted parameters" --> P
In words: parameters define the volatility dynamics; the affine expansion turns the dynamics into an MGF; Fourier inversion turns the MGF into prices and implied volatilities; a Monte Carlo simulation of the same dynamics checks those prices independently; and calibration fits the parameters to the implied volatilities of a market chain.
Step of the diagram |
Pages |
|---|---|
Model parameters and dynamics |
Log-normal SV model, steady state and moments, martingale conditions, Heston model, notation |
MGF and Fourier inversion |
Affine expansion, Fourier pricing, inverse options, QV options, numerical accuracy |
Monte Carlo check |
|
Market chain and calibration |
|
Other models on the same pipeline |
Clustered jumps, mixture and Student-t smiles, factor HJM rates |
Applications |
Bitcoin options, skews of both signs, swaptions and SOFR options, impermanent loss, robust SV models |
The log-normal SV model¶
Log-normal stochastic volatility model with quadratic drift: the dynamics under the physical and risk-neutral measures, the invariance of the quadratic drift, the volatility beta and the model’s parameters and pricer.
Steady-state distribution, moments and expected quadratic variance: the generalised inverse Gaussian law of volatility, how the quadratic drift damps its tail and the kurtosis of returns, the truncated moment system and the variance-swap strike.
Martingale conditions, measures and positive skews: the money-market-account and inverse measures, why a positive volatility beta needs the quadratic drift, a Monte Carlo test and the calibration constraints.
Transform pricing¶
The moment generating function and its affine expansion: the valuation PDE, the first- and second-order coefficient systems, the properties they keep exactly, and densities against Monte Carlo.
Fourier pricing of European options: the capped-payoff formula, the integration grid and its accuracy against Black-Scholes, implied volatilities, and the Black-Scholes and Bachelier analytics.
Inverse options and the inverse measure: options settled in the underlying coin, their valuation under the inverse measure, equivalence with vanilla options and the net delta.
Expected quadratic variance, variance swaps and QV options: the variance-swap strike, its replication by options, and calls on quadratic variance under both measures.
Simulation and validation¶
Monte Carlo simulation schemes: the log-volatility scheme of the paper and the explicit scheme of the package, strong and weak convergence, sampling error, fixed random numbers and historical rough functions.
Experimental rough-logSV pricing: the standalone model, complete factor history, bounded conditional controls, raw-forward diagnostics and selected-case replay.
Analytic versus Monte Carlo validation: what agreement between the transform price and the simulated price establishes, and where on the Bitcoin chain the two separate.
Calibration¶
Calibration to implied volatilities: the vega-weighted objective, free parameters, martingale constraints and engines, with objective profiles and a refit on the Bitcoin chain.
Approximate log-normal SV smile fitter: a three-parameter smile for one maturity, what its parameters mean, and its density and delta helpers.
Fit and surface diagnostics: observed-price/IV agreement, strike/density/calendar checks, optional OCA provenance and repository-only SVI/SSVI research. The workflow guide connects combined reports, OCA event/parity qualification and longitudinal replay, with unavailable data, persistence and observed recovery retained separately.
Other models¶
The Heston model as a benchmark: the square-root variance model and its closed-form MGF, the Feller condition, and how it differs from the log-normal SV model in the distribution of volatility, in smiles and in a fit.
Jump-diffusion with clustered jumps: positive and negative jumps whose intensities are self- and cross-exciting Hawkes processes, priced from an affine MGF (advanced).
Gaussian-mixture and Student-t smiles: terminal laws of one maturity, a mixture of normal log-returns and a Student-t simple return, with closed-form prices and no dynamics.
Stochastic volatility for factor HJM rates: Nelson-Siegel yield-curve factors with one log-normal volatility driver, swaption smiles by drift freezing and the affine expansion, checked by simulation (experimental).
Applications¶
Case studies report the evidence of the research papers, or apply the package to bundled data, in context: the study design, the configuration, the exhibits, and what the study does and does not show.
Bitcoin options: MMA, inverse and QV valuation: weekly calibrations to Deribit options from 2019 to 2023 with a volatility beta that changes sign, and consistent valuation of inverse options (IJTAF paper, Section 6).
One model for equity, VIX, gold and leveraged-ETF skews: dated chains of five underlyings with skews of both signs, the sign of the fitted volatility beta, and the martingale conditions of the positive-beta fits.
USD swaptions and SOFR futures options: the factor HJM model on USD swaptions and 3M SOFR options, with RDR Figures 5 to 9 regenerated and the accuracy of the expansion measured against simulation (RDR paper, Section 7).
Hedging impermanent loss with the LogSV MGF: the static replication of a concentrated-liquidity position by European options, valued with the log-normal SV transform and checked by simulation.
What makes a stochastic volatility model robust: what the log-normal SV parameters recorded for VIX, MOVE, OVX and Bitcoin imply for the persistence and stationary distribution of volatility, with the robustness argument of the working paper.
Implementation and reference¶
Software design: the module layers, the pricer interface, the analytic and Monte Carlo paths, the numba boundary, stability tiers and dependencies.
Numerical accuracy and performance: accuracy controls, compilation and performance expectations.
Testing and coverage: the test lanes, coverage scopes, the documentation gates and the numerical verification map.
Choosing a Python derivatives library: a dated comparison with other open-source packages.
Research papers and replication: the citation ledger, the page each paper supports, the published figures on this site, replication commands and known issues.
API reference: the public names, grouped by the page that explains them, and the parameter maps.
Documentation standard: page forms, citations, executable examples and exhibit provenance.
Research papers¶
The methods are published in two papers whose article PDF and LaTeX source are in the
repository, under
papers/:
Sepp, A. and Rakhmonov, P. (2023). Log-normal stochastic volatility model with quadratic drift. International Journal of Theoretical and Applied Finance 26(8), 2450003. DOI 10.1142/S0219024924500031.
Sepp, A. and Rakhmonov, P. (2025). Stochastic volatility for factor Heath-Jarrow-Morton framework. Review of Derivatives Research 28, article 12. DOI 10.1007/s11147-025-09217-4.
Further working papers that use the package are listed in research papers and replication.
Project resources¶
License: MIT.