Simulation of the Heston Stochastic Volatility Model based on :
[1] Andersen, L. B. (2007). Efficient simulation of the Heston stochastic volatility model. Available at SSRN 946405.
[2] Van der Stoep, A. W., Grzelak, L. A., & Oosterlee, C. W. (2014). The Heston stochastic-local volatility model: Efficient Monte Carlo simulation. International Journal of Theoretical and Applied Finance, 17(07), 1450045.
Execute the following command in folder Surface volatility from data or Heston model if you respectively want to compute the volatility surface based on raw data or if you want to simulate the path from Heston Model.
g++ *.cpp ../*.cpp -o main
to create executable file main
and run it with ./main
in terminal.
In the market, for each asset, we observe a matrix of call prices for a given set of strikes and set of maturities
Then, we need to interpolate/extrapolate this volatility matrix to be able to request the implied volatility at any maturity and strike.
For each maturity, the volatility smile is often interpolated/extrapolated using natural cubic splines.
The interpolation/extrapolation along maturities has different conventions, but the one we will use is linear interpolation in total variance
For each
A better idea is then to perform polynomial interpolation in between points as we need the implied volatility surface to be
Therefore, we use the Natural Cubic Spline approach.
Let's call
The spline interpolation function is therefore the piecewise combination of those cubic polynomials :
Then, we use the conditions at points to find the 4 x (N-1) coefficients
Conditions at points
Firstly, let's use the fact that the spline function contains all the points given by the market :
Which fills 2(N-1) conditions.
Secondly, let's use the
Which completes 2(N-2) conditions as well. Finally, there are 2 conditions left to make the system solvable. The most natural choice is to have zero second order derivative at extremities
Solving the conditions
We note
And the second condition gives
In addition, the condition on zero second order derivative at extremities gives
We can infer
Also, with
We shift the index
We obtain
Using conditions
Matricial expression for the
We can rewrite the two last expressions in a matricial way :
Let's denote A the squared tridiagonal symmetrical matrix of dimension (N-2), Z the unknown vector
This system is a typical application of the Thomas decomposition, given A is tridiagonal. The algorithm will be stable due to the fact that A is strictly diagonally dominant with real positive diagonal entries, therefore A is positive definite.
This algorithm allows us to find the coefficients
Extrapolation along the strike tails
In the regions
We first compute the Left and Right Derivatives:
The extrapolation formula in the tail regions become :
The algorithm below assumes that all M smile functions
Interpolation along maturities
The choice we are making for the interpolation along the maturities is a linear interpolation in variance following constant forward moneyness levels.
For a given maturity
- We compute the forward moneyness level:
$k_{F_T} = \frac{K}{F_T} = \frac{K}{S_0} e^{- \int^T_0 r(s) ds}$ - We extract the strikes
$K^{(i)}$ and$K^{(i+1)}$ corresponding to that forward moneyness for maturities$T_i$ and$T_{i+1}$ :
- We denote the variance quantity
$v(T, k) = (\sigma^{*})² (T,k \text{ x } S_0 e^{\int^T_0 r(s) ds}) \text{ x } T$ - We get the value
$v(T, k_{F_T})$ by linear interpolation of$v(T_i, k_{F_T})$ and$v(T_{i+1}, k_{F_T})$ :
- As a summary, the quantity
$\sigma^{*}(T, K)$ is therefore computed by the following formula:
where
- All the quantities above are obtained thanks to the interpolation/extrapolation of all the smile functions at all maturities
$(T_i)_{i \in [[ 1, M ]]}$
Extrapolation along maturities
The extrapolation of the implied volatility surface outside the range of the market input maturities can be assumed to be constant, still following a same level of forward moneyness from the extreme maturities
where
This section is dedicated to the simulation of stochastic processes to model prices and variance in the Heston stochastic volatility model.
The Heston model is defined as follows :
The price
We consider a probability space
The conditional law followed by
We use discretisation schemas for solving Stochastic Differential Equations (SDE) in the Heston model. Firstly, we simulate the variance process, then we generate the price process to verify the Heston model associated to
For the sake of simplicity, we prefer to simulate the logarithm of the value of the actualised price process
We consider subdivisions of the interval
We denote
where the variables
The positivity of
Distribution function for
Parameters :
The truncated gaussian distribution and the log-normal distribution have been calibrated from moments of the exact distribution of
The log-normal distribution underestimates the weight around the origin
Furthermore, the density function of the decentralized
We obtain an approximation of the variance process at time
- For great values of
$V^{qe}(t_k)$ :$V^{qe}(t_{k+1}) = a(b+Z_V)²$ ,$a$ and$b$ calibrated from the determined formulas of the conditional expectation and conditional variance of$V^{qe}(t_k)|V^e(0)$ . - For small values of
$V^{qe}(t_k)$ : we simulate$V^{qe}(t_ {k+1})$ following the density$\mu \delta(0) + \beta(1 - \mu)(- \beta(\cdot))$ defined on$[0, + \infty]$ , with$\mu$ and$\beta$ calibrated from the determined formulas of the conditional expectation and conditional variance of$V^{qe}(t_k)|V^e(0)$ .
In our implementation, we consider a simulation with gaussian process in case the following condition is fulfilled :
If not, we use the second method for the simulation.
Once the simulation of the variance process is done, we use the discretisation schema of the price proposed in [1] :
where
In the paper, a martingale correction is proposed. A further version of this projet will implement it. The martingale correction consists in generating a martingale process in the QE simulation which enable to have consistant prices regarding the prices observed on the market
Other simulation methods are also implemented in the paper : the Kahl-Jackel schema, the Broadie-Kaya schema, but not implemented here yet.
We want our Monte-Carlo pricer to simulate the prices quickly and with the minimum variance possible. Variance reduction is important for the precision of the prices computed. An extreme case corresponds to the computation of prices which are strongly in/out of the Money for the computation an implied volatility. For a call Outside of The Money (OTM), the Vega is barely uniformely equal to 0 and so the derivative of the implied volatility with respect to the price is very high, as it tends to infinity.
The plot of the implied volatility shows that for an OTM call, its price is closed to the bounds. The sensitivity of the implied volatility to the price of the call is therefore very high, so the computation requires a very high precision as well (i.e a low variance) to compute correctly the implied volatility. Those computations of the implied volatility OTM are necessary if we want to compute the volatility surface over a great amount of strikes, without having to extrapolate a calibration nearby the Money.
A first method to reduce the variance consists in using the call-put parity to price in the direction of the minimum variance, which is performed by the method call_price_auto from the class HestonQECallPricer. Theoretically, we look at pricing from the call when the option is In The Money (ITM) and from the put when the option is OTM, in order to prevent that the support of the greatest probability corresponds to the null part of the payoff.
This method consits in using the relationship
We optimize those expressions with respect to
We need the expressions for
In addition, we use the library OpenMP for the distribution of the computation and the parallelisation of the code.
The computation of greeks is central for the calibration of a volatility surface on the market. The major part of optimisation methods use a gradient descent method to optimise a loss function. For
Then, the gradient of the loss function is :
It is necessary to correctly compute the gradient of the greeks, i.e with the minimum variance to guarantee the convergence of the optimisation algorithm.
The first method consists to use the centered finite difference method
So the variance reduces with higher values of
Automatic differentiation is a technique of numerical differentiation to remove the truncation error by explicitly expressing all the derivatives. For
The option price
with
The automatic differentiation consists in the diffusion of
The class HestonQEHelper contains all the methods to compute the explicit derivatives and the class PointSimulatorHestonQE contains the method multi_state_simulation_multi_thread to diffuse
The calibration of the implied volatility surface is a constraints optimization problem and can be expressed as a convex optimization problem :
where
A first method is to use the projected gradient algorithm defined by :
where
Under conditions of convexity and differentiability, if
The condition of non-linearity induced by the CIR process prevents us to give an explicit formula for the projection operator
Then, the second method chosen uses the theory of the saddle point and the Usawa algorithm.
It requires the dual form of the convex optimization problem. Let
where
In this new optimization problem, we look for a saddle point of
- We compute
$g(\lambda) = \inf_{v} \mathcal{L}(v, \lambda)$ .$\mathcal{L}(\cdot)$ being convex, the optimal conditions are when its gradient is equal to 0 (Euler condition). We can find it by simple gradient descent. - Once
$v_{\lambda}$ is computed, we consider$g(\cdot)$ and we minimise$- g(\cdot)$ by applying the projected gradient on the half-space$\mathbb{R}^4_+$ . Once$\lambda^*$ is computed, the quantity is injected in the formula of$x_{\lambda}$ .
The result is denoted
with
The Usawa algorithm is implemented in the class CalibrateHestonModel.
-
class_Matrix_header.h & class_Matrix.cpp: files containing the definition of matrix class and usual operations. Contains methods to perform Cholesky decomposition, (reduced) row echelon matrix transformation and algorithm to solve a Thomas system
-
folder Surface volatility from data : Folder containing the build of implied volatility surface
- class_surface_vol_header.h & class_surface_vol.cpp: files containing the observation of volatility surface
- class_tenor_cubicspline_header.h & class_tenor_cubicspline.cpp: files containing the interpolation/extrapolation along strikes and maturities as describe above using tenor cubicspline method
- main.cpp: main file to compile which builds the implied volatility surface
- folder data : folder containing raw data to observe
- option_implied_vol.csv
- option_prices.csv
- tenor_vol_chain.csv
- test_vol_curve.csv
-
folder Heston Model : Folder containing the simulation of the Heston model and its dependencies
- class_Random_header.h & class_Random.cpp: files containing the definition of uniform and gaussian random variables
- class_Model2F_header.h & class_Model2F.cpp: files containing the general definition of a 2 Factor model
- class_PathSimulatorEuler2F_header.h & class_PathSimulatorEuler2F.cpp: files containing the definition of path simulator via Euler method for a 2 Factor model
- class_HestonModel_header.h & class_HestonModel.cpp: files containing the definition of Heston model
- main.cpp: main file to simulate the Heston model