Optcorner: Calibrate the Heston Model Faster Using Derivative-Free Optimization Techniques

Published 17/06/2021 By Benjamin Marteau

In this post, we demonstrate how DFO can speed up a practical calibration problem arising frequently in the finance industry: calibrating an option pricing model to market data.

The following material is based on a recent webinar we presented, a recording is available here.

Recent improvements in DFO solvers

DFO has seen enormous activity in the last years since our previous DFO post. NAG collaborated on a research project with Coralia Cartis and Lindon Roberts from the University of Oxford. This research led to significant improvements, such as noise resilience and enhancements to interpolation models for structured problems, and brought the state of the art of DFO techniques [1] into the NAG Library. We now offer a bound-constrained nonlinear least squares solver suitable for data fitting problems, handle_solve_dfls (e04ff), as well as one that is aimed at general nonlinear functions, handle_solve_dfno (e04jd). We also provide alternative interfaces (reverse communication) to pass the function values to the solvers, handle_solve_dfls_rcomm (e04fg) and handle_solve_dfno_rcomm (e04je), respectively.

Pricing European Options: calibrating the Heston model

A European option is a contract giving the buyer the option to buy (call) or sell (put) an underlying at a given price (strike) and expiration date (maturity). Pricing the option consists in attributing it a price based on the probability that the buyer will want to exercise the option at maturity.

Many numerical pricing methods have been introduced throughout the years, the most common ones still being based on the Black-Scholes equations. However, the Black-Scholes model has some shortcomings, among which the assumption that the volatility is constant over time. It is in fact observed that market implied volatilities are smile-shaped. Stochastic volatility models such as Heston’s were introduced to try to explain this shape. The model consists in the following set of equations:

d S t = μ S t d t + σ v t S t d W t 1 d v t = λ ( 1 v t ) d t + α v t d W t 2 d W t 1 d W t 2 = ρ d t

where \(S_{t}\) is the spot price of the underlying \(vt\) is the time-dependent volatility and \( (dW_{t}^1 , dW_{t}^2) \) are two Brownian motions.

This model still depends on 4 parameters that are not easy to directly observe in the market: the volatility scaling \( σ \) the mean reversion rate \( λ \) the volatility of volatility \(a\) and the Brownian motion correlation \(ρ\). These parameters, therefore, need to be calibrated. This can be done by observing historical data and trying to optimize the parameters to make our model prediction match it as closely as possible. This is a great candidate for DFO due to the lack of readily available derivatives and relatively expensive evaluation.

Introducing term structure in the Heston model

The Heston equations still assume that our 4 parameters are constant with respect to time, which does not necessarily correspond to market reality. To alleviate this problem, a possible extension is to add term structure: \( σ, λ, α \) and \(ρ\) are only considered constant over fixed time periods. This allows the model to better mimic market behaviour but also multiplies the number of parameters to calibrate by the number of time periods considered.

An implementation of the Heston model with term structure is available in the NAG Library (opt_heston_terms30ncf) and is the one used in the following numerical experiments.

Setting up the calibration problem

We have access to historical data in the foreign exchange market for the currency pair EUR-USD ranging from 2012 to 2016. For each date, we have data for 7 maturities (2m, 3m, 6m, 1y, 2y, 3y and 5y):

  • EUR risk-free rate
  • USD risk-free rate
  • 25- Δ RR quotes
  • 25- Δ BF quotes
  • ATM quote

One apparent issue with this data is that we have only 3 quotes and 4 parameters to tune even without considering term structure. To avoid over-fitting, we chose to fix one of the parameters λ to a constant value after some numerical experiments. Without term structure, calibrating the Heston model would then consist in solving the nonlinear least squares optimization problem:

min α , ρ , σ 1 2 i = 1 m H i ( α , ρ , σ ) M i m a r k e t 2

where \(H_{i} (α, ρ, σ) \) are the prices predicted by the model and \(m_{i}market\) the actual data.

The next step is to choose the number of time periods to set in the term structure. With 7 maturities it is natural to consider 7 time periods for our term structure: for every date, we consider \(k\) time periods for the \(k^th \) maturity.

With this structure, each maturity depending on the parameters of the previous ones plus its own, it was also natural to choose to fit the parameters sequentially. The first parameters \( (α_{1}, ρ_{1}, σ_{1} ) \) are tuned to the quotes of the 2m maturity, then fixed to their optimal values and \( (α_{2}, ρ_{2}, σ_{2}) \) are tuned to the second maturity. the process continues until we end up with a sequence of seven 3-parameters calibration problems:

min α 1 , ρ 1 , σ 1 i = 1 m H i ( α 1 , ρ 1 , σ 1 ) M i 2 ( P 1 ) min α 2 , ρ 2 , σ 2 i = 1 m H i ( α 1 , α 2 , ρ 1 , ρ 2 , σ 1 , σ 2 ) M i 2 ( P 2 ) min α 7 , ρ 7 , σ 7 i = 1 m H i ( α 1 , , α 7 , ρ 1 , , ρ 7 , σ 1 , , σ 7 ) M i 2 ( P 7 )

Numerical Experiment

To solve the calibration problem (1), we try two solvers from the NAG Library dedicated to nonlinear least squares problems:

Since we don’t have access to the exact derivatives of the Heston model, we estimate the Jacobian of the residuals needed by e04gg with finite differences. Using finite differences effectively can be quite challenging (as discussed in our previous post). Here we chose a constant perturbation parameter \(h = 10 ^-6 \) after some numerical experiments.

For our comparisons, we use the same realistic stopping criterion for both solvers. The fit is considered good if it reaches 1-basis point precision:

H i ( α , ρ , σ ) M i S 0 . 0 1

The data we use contains 1070 dates defining 1070 sequences of seven calibration problems to solve (7490 total). All were solved using both approaches, the results can be summarized as:

  • Total number of calls to the Heston model:
    • DFO: 258540 (avg 241); gradient-based: 963933 (avg 900)
    • DFO needed 3.7 times fewer evaluations.
  • Total number of calibrations that didn’t reach 1-basis point:
    • DFO: 32 (20 problems); gradient-based: 180 (138 problems)
    • DFO solved to required accuracy 98% of the problems in contrast to 87% for the other.
  • Number of calls to the Heston model for problems that both methods solved:
    • DFO: 211326 (avg 229); gradient-based: 575379 (avg 626)
    • DFO required 2.7 times fewer evaluations.

The figure below captures the speedup of the DFO solver over the finite-differences based solver as a ratio of the number of function evaluations needed per problem. Each blue dot represents a problem where the DFO solver was faster whereas each red dot is in favour of the derivative-based solver. It is clear that the DFO solver offers much faster convergence for a majority of problems.

derivative free speed-up

Things to remember

Calibrating black-box models is not a trivial problem, you should consider using a derivative-free solver if you don’t have access to precise estimations of the derivatives. As shown on the practical Heston calibration example, you are likely to obtain a better fit in fewer model calls with DFO solvers.

You can also find various examples through our GitHub Local optimization page. See you in the next blog.


[1] Coralia Cartis, Jan Fiala, Benjamin Marteau, and Lindon Roberts. Improving the exibility and robustness of model-based derivative-free optimization solvers. ACM Trans. Math. Softw., 45(3), August 2019.

    Please fill out all of the following questions

    What solvers are you interested in trying? (multiple choice)

    By clicking the button below you agree to our Privacy Policy

    This will close in 20 seconds