Fast regimes in QuantLib's models

Which of QuantLib's models and processes take regime-switching parameters, and which method handles each.

Any model in QuantLib can have some of its parameters driven by a fast hidden chain. How far the expansion reaches depends on where the switched parameters enter the pricing equation.

The test

Many QuantLib models are exponential-affine: a price or characteristic function has the form

$$u_i(t, x) = e^{-B(t)\cdot x}\,a_i(t),$$

where $B$ solves a Riccati equation. If the switched parameters do not appear in that Riccati equation, $B$ is the same in every regime. The regime then enters only through a forcing $g_i(t)$, and

$$a' = \big(Q + \operatorname{diag} g\big)\,a .$$

The engine expands this to all orders, with the initial layer.

When the switched parameters do enter the Riccati equation, or the model is not affine, the first-order rule still applies to any Markov pricing equation. It adds the Green–Kubo term $\sum_{jk} K_{jk} A_j A_k$ to the averaged operator.

The catalogue

QuantLib model or processswitch, all ordersswitch, first orderchecked here
BlackScholesProcess, GeometricBrownianMotionProcessvolatility, rate, dividendBlack–Scholes
Merton76Process (JumpDiffusionEngine)volatility, jump intensity, jump lawMerton
VarianceGammaProcess$\sigma$, $\nu$, $\theta$variance gamma
HestonModel, PiecewiseTimeDependentHestonModelvariance level $\theta$$\kappa$, $\xi$, $\rho$Heston; $\theta$ and $\xi$
BatesModelvariance level, jump intensity, jump law$\kappa$, $\xi$, $\rho$Bates
Vasicek, HullWhitemean level, volatilityreversion speedregime switching; Hull–White; speed and volatility
CoxIngersollRoss, ExtendedCoxIngersollRossmean levelvolatility, reversion speedCIR
G2 (two-factor Gaussian)both volatilities, correlation, levelreversion speedsG2++
GSRvolatility, levelreversion
Other Gaussian1dModel subclasses, such as MarkovFunctionalall parameters
BSM–Hull–Whiteequity volatility, rate level, rate volatility, equity/rate correlationrate reversionequity with rates
HestonHullWhite, equity and rate uncorrelated (AnalyticHestonHullWhiteEngine)variance level, rate level, rate volatility$\kappa$, $\xi$, $\rho$, rate reversionequity with rates
HestonHullWhite with equity/rate correlation; H1HWall parameters
ExtendedOrnsteinUhlenbeckProcess, ExtOUWithJumpsProcess, KlugeExtOUProcesslevel, volatility, jump intensityreversion speedjumps
BlackKarasinskiall parameters
CEV (AnalyticCEVEngine)volatility scale, as a mixture over the total varianceelasticity $\beta$CEV
SABR (FdSABRVanillaEngine)all parameters
Local volatility, HestonSLV, normal and square-root CLV modelsall parameters
GemanRoncoroniProcessall parameters
LIBOR market modelsall parameters, in high dimension

Three rows need a caveat.

$$\rho_{xr}\,\eta_i\,\sqrt v\;\partial_x\partial_r .$$

AnalyticH1HWEngine replaces that term by an approximation, and the approximate model needs its own analysis. Black–Scholes–Hull–White has a constant equity volatility in place of $\sqrt v$, so the same term is a constant times $\partial_x\partial_r$, and it stays affine with any correlation.

Three families lie outside the framework. Rough Heston is not Markov.

GJR-GARCH is a discrete-time model, which would need the discrete-time analogue of the expansion. The credit loss models (Gaussian large-pool and other latent-factor models) are static one-period factor models; dynamic credit with switching hazards is on the credit page.

Products

The instruments page gives the formulas for each, with coupon-bond options, swaptions, caps, credit default swaps and the geometric Asian option worked out.

The new checks

Merton's jump diffusion, variance gamma and Bates are Lévy or affine with constant or regime-free Riccati parts. For each, the regime-dependent forcing is the switched part of the characteristic exponent:

$$\begin{aligned} g_i &= \psi_i(u) &&\text{Merton, variance gamma}, \\ g_i(t) &= \kappa\,\theta_i\,D(t) + \lambda_i\,\big(\phi_J(u) - 1 - iu\bar k\big) &&\text{Bates}, \end{aligned}$$

where $\psi_i$ is the Lévy exponent in regime $i$, $D$ the Heston Riccati solution, $\phi_J$ the jump characteristic function and $\bar k$ the mean jump size. The certificate compares the expansion with the numerical solution as the switching speeds up. Every order converges at its expected rate, from one to five, until the error reaches rounding. Each model now has its own page with the closed form to second order: Merton, variance gamma and Bates.

Certificate: verify_quantlib_models.py.