Skip to main content

Efficient numerical calibration of the Heston stochastic volatility model.

Project description

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:

View Final Notebook


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:

Open In 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mafn_heston_calib-0.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mafn_heston_calib-0.1.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file mafn_heston_calib-0.1.0.tar.gz.

File metadata

  • Download URL: mafn_heston_calib-0.1.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mafn_heston_calib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d9f407486113421aeee6a965b898159c6f3dc916a3f321ec41abdda2f6e5138e
MD5 f78a0bd938ad24cc62abc34d49139626
BLAKE2b-256 932ddc34a25a5a4b52014109024bae35c72fdfb45e9a77956d5bef385bb014d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mafn_heston_calib-0.1.0.tar.gz:

Publisher: publish.yml on maa2420-cloud/heston_calibration_optimization_ipynb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mafn_heston_calib-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mafn_heston_calib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7fb3b9d02e13e75e7d6ff10d5b24a3399a1c9df70ef64f0dd1d18f32b1816d8
MD5 3aad08ce9b501e2faece1612f4c18790
BLAKE2b-256 7b5a3cac27fc711c41df179cac442e53d7890973f2671dcd6f9ee318ceab02ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for mafn_heston_calib-0.1.0-py3-none-any.whl:

Publisher: publish.yml on maa2420-cloud/heston_calibration_optimization_ipynb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page