Problem
Market prices of European calls are quoted for a grid of strikes and maturities. A pricing model is only useful once its parameters reproduce those prices. Calibration does exactly that: it searches for the parameters that minimise the distance between model and market prices.
Each step of that search prices the whole surface again, so the pricer has to be fast. For models without a closed-form price, such as Heston, the standard answer is to price in Fourier space with the characteristic function of the log price. derivkit is built around that idea. Each model is one class that calibrates (fit), prices with FFT (predict) and simulates paths for Monte Carlo (simulate), all with the same parameters.
Models
Black-Scholes
The stock follows a geometric Brownian motion with constant volatility , interest rate and dividend yield :
The characteristic function of is
Heston
The variance is itself random. It reverts to a long-run level at speed , has volatility of variance , and its shocks are correlated with those of the stock:
There are five parameters, and the starting variance . Calibration only accepts parameters that satisfy the Feller condition , which keeps the variance away from zero. With
the characteristic function of is
Pricing with the FFT
Carr and Madan (1999) price a call through the Fourier transform of its price as a function of the log strike . The call price itself is not integrable in , so it is first damped with a factor , . The transform of the damped price has a closed form in terms of :
and the call price follows by inverting it:
The integral is discretised on points with Simpson weights. Choosing the log strike grid with and turns the sum into a discrete Fourier transform:
One FFT gives prices for all log strikes at once. Market strikes are then read off the grid by linear interpolation. The defaults are , and .
The same FFT also gives the delta. The characteristic function depends on only through , so . Multiplying by that factor before the transform returns instead of . For Black-Scholes this matches up to FFT error.
Calibration
The loss is the sum of squared differences between model and market prices over all strikes and maturities. Options are grouped by maturity, so there is one FFT per maturity. The loss has local minima, especially for Heston, so it is minimised with Nelder-Mead from several starting points and the best result is kept. Parameters outside their bounds or that break the Feller condition get a very large loss, which keeps the simplex in the valid region.
Monte Carlo
Every model can also simulate paths. Heston uses an Euler scheme with correlated normal increments, and a variance that turns negative is reflected back above zero. The same seed always gives the same paths.
Contracts work on paths from any model. A contract only needs its payoff. Its value on every path and every day is then estimated as the discounted conditional expectation of the payoff given , by regressing discounted payoffs on a cubic polynomial plus a spline in , in the spirit of Longstaff and Schwartz. The delta is computed pathwise with the same regression,
with a finite difference as a fallback for payoffs that jump. The variance swap adds the realised variance so far as an extra regression feature, and it can compute its own fair strike from the paths.
Example
import pandas as pd
from derivkit import HestonPricer
from derivkit.contracts import EuropeanCall, VarianceSwap
data = pd.read_csv("Data.csv")
X = data[["Strikes", "Maturities"]].to_numpy()
y = data["Prices"].to_numpy()
pricer = HestonPricer(S0=100, r=0.05)
pricer.fit(X, y) # Nelder-Mead from several starts
print(pricer.get_model_params()) # kappa, theta, eta, rho, V0
T = 4 / 12
paths = pricer.simulate(T=T, steps=round(T * 252), n_paths=10_000, seed=42)
call = EuropeanCall(strike=100, T=T, r=0.05)
values = call.price(paths) # value on every path, every day
deltas = call.delta(paths)
vs = VarianceSwap(T=T, r=0.05)
vs.strike = vs.fair_strike(paths)
References
- P. Carr and D. Madan (1999). Option valuation using the fast Fourier transform. Journal of Computational Finance 2(4).
- S. Heston (1993). A closed-form solution for options with stochastic volatility with applications to bond and currency options. Review of Financial Studies 6(2).
The code, tests and an example notebook are on GitHub.