Class HestonCalibrator

java.lang.Object
com.quantfinlib.pricing.HestonCalibrator

public final class HestonCalibrator extends Object
Calibrates the five Heston.Params to a grid of Black-Scholes implied volatilities by Levenberg-Marquardt (Levenberg 1944; Marquardt 1963, with Marquardt's diagonal scaling).

The objective is the vega-weighted price error, a first-order proxy for the implied-volatility error that avoids an implied-vol inversion per iteration:

  r_i = (C_Heston(K_i, T_i; p) - C_BS(K_i, T_i; sigma_i)) / vega_BS(K_i, T_i; sigma_i)
  minimise  sum_i r_i^2 / 2

Each quote is priced as the out-of-the-money option (put below the forward, call at or above), where the COS expansion is most accurate. The Jacobian is the analytic gradient of the COS price from HestonCos.parameterGradient(double, double, double, double, double, Heston.Params) (forward-mode differentiation of the characteristic function, as in Cui, del Bano Rollin and Germano 2017, "Full and fast calibration of the Heston stochastic volatility model", EJOR 263(2), who differentiate it by hand), divided by the same vega. The step solves (J'J + lambda diag(J'J)) delta = -J'r; lambda is divided by 3 after an accepted step and doubled after a rejected one. Parameters are projected after each step onto the box kappa in [1e-3, 50], theta, v0 in [1e-4, 4], sigmaV in [1e-3, 10], rho in [-0.999, 0.999]. The Feller condition is not imposed.

Like any local least-squares fit, the result depends on the starting point when the surface does not pin all five parameters (kappa and sigmaV trade off on short-dated grids). The returned implied-vol RMSE is computed by full inversion of the model prices (the vega proxy is used for a quote whose model price cannot be inverted).

  • Method Details

    • calibrate

      public static HestonCalibrator.Result calibrate(double spot, double rate, double divYield, double[] strikes, double[] maturities, double[] impliedVols, Heston.Params initial)
      Calibrates with at most 200 iterations and tolerance 1e-12.
    • calibrate

      public static HestonCalibrator.Result calibrate(double spot, double rate, double divYield, double[] strikes, double[] maturities, double[] impliedVols, Heston.Params initial, int maxIterations, double tolerance)
      Calibrates to quotes (strikes[i], maturities[i], impliedVols[i]).
      Parameters:
      maxIterations - at least 1
      tolerance - stop when the gradient's max-norm or the relative cost decrease is below it