Efficient Calibration of the Heston Stochastic Volatility Model using Numerical Optimization
Project Summary
This project focuses on calibrating the Heston stochastic volatility model to observed market option prices using numerical optimization techniques.
The Heston model allows volatility to evolve stochastically over time, making it more realistic than constant-volatility models. However, model parameters are not directly observable and must be determined through calibration.
The calibration problem is formulated as:
$$ \min_{v_0, \kappa, \theta, \eta, \rho} \sum_{i=1}^{N} \left( C_{\text{model}}(K_i, T_i) - C_{\text{market}}(K_i, T_i) \right)^2 $$
where $C_{\text{model}}$ represents the model-generated option price and $C_{\text{market}}$ denotes the observed market price for strike $K_i$ and maturity $T_i$.
The main challenge lies in the high computational cost and numerical instability of the calibration process. This project explores efficient numerical methods to improve both speed and stability.
Team Members
- John Wang
- Anish Reddy
- William Qiu
- Louie Tam
- Michael Adegbite
Implemented Methodologies
The project implements and compares several numerical techniques to improve calibration performance:
- Continuous Characteristic Function
- Analytical Gradient Formulation
- Vectorized Gauss-Legendre Integration
- Levenberg-Marquardt Optimization
These methods are designed to reduce computational cost and improve convergence stability during optimization.
Repository Structure
heston_calibration_optimization_ipynb/
│
├── notebooks/
│ └── demo.ipynb # Main notebook (final + demo)
│
├── heston_calibration.ipynb # Earlier development notebook
├── heston_calibration-GPU.ipynb # GPU-related experiment notebook
├── SPY_Complete.xlsx # Market option/input data
│
├── Part5_AnalyticalCalib/ # Analytical calibration package
├── pricerNew/ # Baseline pricing code
├── part_6/ # Final evaluation work
│
└── README.md # Project documentation
Reference Paper Connection
This project is connected to the Heston stochastic volatility framework and the paper:
Cui, Y., del Baño Rollin, S., & Germano, G. (2017). Full and Fast Calibration of the Heston Stochastic Volatility Model.
The project follows similar ideas by improving calibration efficiency through characteristic-function pricing, analytical gradient formulation, efficient numerical integration, and optimization techniques.
Final Project Notebook
The full implementation is contained in:
Notebook Structure: heston_calibration-FINAL.ipynb
The final notebook is organized into 6 main sections.
1. Introduction
The introduction presents the Heston stochastic volatility model and explains why calibration is needed.
The Heston model dynamics are written as:
$$ dS_t = \mu S_t dt + \sqrt{v_t}S_t dW_t^S $$
$$ dv_t = \kappa(\theta - v_t)dt + \eta\sqrt{v_t}dW_t^v $$
$$ dW_t^S dW_t^v = \rho dt $$
This section motivates the calibration problem and highlights the main challenge: Heston calibration is computationally expensive, nonlinear, and sensitive to initial parameter values.
2. Heston Model and Pricing Framework
This section develops the Heston model pricing framework.
The model assumes that the underlying asset price and variance follow correlated stochastic processes:
$$ dS_t = (r - q)S_t dt + \sqrt{v_t}S_t dW_t^S $$
$$ dv_t = \kappa(\theta - v_t)dt + \eta\sqrt{v_t}dW_t^v $$
$$ dW_t^S dW_t^v = \rho dt $$
This section establishes the pricing foundation used later in the calibration process.
3. Calibration Problem Formulation
This section defines the calibration setup used in the notebook.
The calibration process includes:
- setting initial parameter guesses
- applying parameter bounds
- loading market option data
- constructing option prices across strikes and maturities
- minimizing the difference between model prices and market prices
This section prepares the data and optimization structure used in the baseline and improved methods.
4. Baseline Method (Naive Approach)
This section implements a baseline Heston calibration using a single start L-BFGS-B optimizer with simple box constraints. Market prices are derived from implied volatilities via the Black–Scholes formula, and the calibration minimizes the mean squared error across strikes and maturities.
While the method converges to a similar final error (MSE ≈ 0.111582), the computational effort varies across initial guesses, highlighting sensitivity to initialization and high computational cost. This serves as a benchmark for the improved methods in the next section.
5. Improved Calibration Method
This section presents the main contribution of the project.
The improved calibration framework incorporates:
- Continuous Characteristic Function
- Analytical Gradient Formulation
- Vectorized Gauss-Legendre Integration
- Levenberg-Marquardt Optimization
These enhancements improve both computational efficiency and convergence stability compared to the baseline method.
6. Results and Evaluation
This section evaluates calibration performance across different methods.
The notebook compares baseline calibration, improved calibration, the Cui et al. approach, and a GPU-based implementation.
The final method comparison reported in the notebook is:
| Method | Final MSE |
|---|---|
| Baseline | 0.01581340 |
| Improved | 0.04707892 |
| Cui et al. | 0.07711890 |
| GPU | 6.87368833 |
The results show that calibration performance depends on the numerical methods used and highlight differences in accuracy and efficiency across implementations.
Key Takeaways
- The Heston model captures stochastic volatility more realistically than constant-volatility models.
- Calibration is a nonlinear optimization problem.
- PyFeng provides the baseline Heston FFT pricing engine.
- The improved method focuses on characteristic-function pricing, analytical gradients, vectorized Gauss-Legendre integration, and Levenberg-Marquardt optimization.
- GPU/CuPy implementation is included as part of the performance comparison.
- The final framework emphasizes accuracy, stability, and computational efficiency.
Demo Notebook
A demonstration of the full Heston calibration workflow is provided in the final notebook.
You can run the notebook directly in Google Colab:
The notebook includes:
- Data loading and preprocessing
- Construction of the volatility surface
- Baseline calibration
- Improved calibration methods
- Performance comparison across methods
This notebook serves as an end-to-end example of the calibration framework implemented in this project.
API Reference
The final notebook uses the following libraries and project modules:
import numpy as np
import pandas as pd
import time
import matplotlib.pyplot as plt
import pyfeng as pf
import cupy as cp
from scipy.optimize import minimize, least_squares
from scipy.stats import norm
from heston_package import HestonPricer, VolSurfaceBuilder, HestonCalibrator, HestonParams
from _baseline import runSimulation
Core Libraries
| Library / Module | Usage |
|---|---|
numpy |
Numerical calculations, vectorization, exponentials, square roots, and arrays |
pandas |
Loading and organizing market data |
time |
Measuring runtime |
matplotlib.pyplot |
Plotting and visualization in the notebook |
pyfeng |
Heston FFT pricing through pf.HestonFft |
cupy |
GPU acceleration |
scipy.optimize.minimize |
Baseline local optimization |
scipy.optimize.least_squares |
Levenberg-Marquardt least-squares optimization |
scipy.stats.norm |
Black-Scholes call and put price construction |
heston_package |
Project calibration classes for the improved method |
_baseline.runSimulation |
Baseline simulation/calibration support |
Important Functions
| Function / Class | Purpose |
|---|---|
tenor_to_years() |
Converts tenors such as 1M, 3M, and 6M into year fractions |
black_scholes_prices() |
Converts implied volatility quotes into market call and put prices |
load_market_data() |
Loads the SPY dataset and builds the calibration dataset |
pf.HestonFft() |
Computes Heston model prices |
calculate_mse_baseline() |
Computes baseline calibration error |
minimize() |
Runs baseline optimization |
least_squares() |
Runs Levenberg-Marquardt least-squares optimization |
HestonPricer |
Pricing engine used in the improved method |
VolSurfaceBuilder |
Builds the option volatility surface |
HestonCalibrator |
Runs the improved calibration method |
HestonParams |
Stores Heston model parameters |
runSimulation() |
Runs baseline simulation/calibration support |
Metadata
Release files for mafn-heston-calib 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mafn_heston_calib-0.1.2.tar.gz | 33.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mafn_heston_calib-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 66.1 kB
Release files / mafn_heston_calib-0.1.2.tar.gz
| Download URL | mafn_heston_calib-0.1.2.tar.gz |
|---|---|
| Size | 33.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b18f683d14620448d24da45a3e820f0896b2871ece97c75385d31076e045018f
|
|
BLAKE2b-256 checksum How to use checksums |
bca01c43705ef61710e38c0dff1776d244829df7c88a09e6d9772992037d8d6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2026.
Transparency logRelease files / mafn_heston_calib-0.1.2-py3-none-any.whl
| Download URL | mafn_heston_calib-0.1.2-py3-none-any.whl |
|---|---|
| Size | 32.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
498f0fe34c7c478c19f287d360a9e1bb320151aeb63e3d94e2b82a74b4b84e46
|
|
BLAKE2b-256 checksum How to use checksums |
0d04dbdf4e6ba1ca5f39f512ffb27918826377d261ba3d74194a9cf252be2f41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2026.
Transparency log