Implementation of the Heston model for European call pricing by Monte Carlo simulation, and analysis of the impact of the correlation (
- Monte Carlo simulation: generation of price and variance paths using a full-truncation Euler scheme
- European call pricing: with both the Heston and Black-Scholes models
- Implied volatility: extraction by numerical inversion of Black-Scholes (Brent's method)
-
Skew analysis: impact of the correlation (
$\rho$ ) on the asymmetry of the volatility skew - Feller condition: exposed as a dataclass property and checked in the test suite
The model describes the joint evolution of the asset price
Parameters:
-
$\kappa$ : mean-reversion speed -
$\theta$ : long-run variance -
$\sigma_v$ : volatility of variance -
$\rho$ : correlation between price and variance
The price is simulated in log form (
To guarantee that the variance process
It is exposed through HestonParameters.satisfies_feller and verified in the tests (satisfied case, violated case, and strict boundary).
The script produces a graphical comparison of the volatility skew for:
$\rho = -0.9$ $\rho = -0.7$ $\rho = -0.5$ $\rho = 0.0$
black_scholes.py # closed-form call price + implied vol inversion (Brent)
model.py # HestonParameters dataclass + HestonMonteCarlo simulator
plot_smile.py # plots the skew across the different correlation scenarios
tests/
test_heston.py
pip install numpy scipy matplotlib
python plot_smile.pyimport numpy as np
from model import HestonParameters, HestonMonteCarlo
from black_scholes import implied_vol
params = HestonParameters(spot=100.0, rate=0.03, kappa=2.0, theta=0.04, sigma_v=0.30, v0=0.04)
sim = HestonMonteCarlo(params, n_paths=300_000, n_steps=100, seed=42)
strikes = np.linspace(80.0, 120.0, 40)
prices = sim.call_prices(strikes, maturity=1.0, rho=-0.7)
iv = [implied_vol(100.0, k, 1.0, 0.03, p) for k, p in zip(strikes, prices)]pip install pytest ruff
pytest -q
ruff check .The suite covers the Feller condition (including the strict boundary), the Black-Scholes / implied vol round-trip, the monotonic decrease of the call price in the strike, the degenerate case
numpy
scipy
matplotlib
Alexandre R. - Université Paris Cité