This project implements the pricing models used in part one of the analysis of [1] as well as fast neural network approximations of these.
We start by outlining the models: Let S(t) denote the time t price of an asset and let r(t) and q(t) denote the risk-free interest rate and the continuously compounded dividend yield respectively; r(t) and q(t) are assumed deterministic. Under some standard assumptions, we then have
under the risk-neutral measure. Here V(t) is some process (the instantaneous variance) and we write W for Brownian motions.
The models for V(t) that we consider are defined below.
Remark: The notation differs slightly between the paper and the code. Keep this in mind.
In the Heston model of [2], we have
We consider also a rough Heston model akin to [3] defined by
The rough Bergomi model of [4] assumes
Under the extended rough Bergomi model we assume that
In the code, we use the reparameterisation:
The code first and foremost implements pricing algorithms for puts and calls on S(t). You should consult the code or the paper for a description of what methods and schemes are used. This part of the project is only implemented in Matlab.
Secondly, there are Matlab scripts for generating large datasets of option prices for different model parameters. Neural networks are then trained (in Python and using Keras) to represent the datasets for each model.
Thirdly, the code implements interfaces to evaluate the neural networks. The interfaces are available in Matlab, Python and R.
The network weights are located in the folder .../code/neural_networks/data/neural_network_weights if one wants to implement the neural networks in other languages. The training and test datasets are rather large (almost 30 GB in total) and can thus instead be downloaded from here. To use the datasets in the project, place the files in the folder *".../code/neural_networks/data/training_and_test_data".
With neural networks we can compute an entire volatility surface in around 1 millisecond on a standard laptop. A typical calibration to SPX options can then be performed in less than a second. Read the paper for the details, or try it yourself.
The networks are also highly accurate as exemplified with the rough Bergomi model below:
The parameters are:
A more detailed analysis of the approximation error can be found in the paper.
There are a number of scripts to help get you started. They are explained below.
Language | Folder | Description |
---|---|---|
Matlab | .../get_started/neural_networks_in_matlab | Examples of using the neural networks in Matlab. |
Python | .../get_started/neural_networks_in_python | Examples of using the neural networks in Python. |
R | .../get_started/neural_networks_in_R | Examples of using the neural networks in R. |
Matlab | .../get_started/models_in_matlab | Examples of using the underlying pricing models in Matlab. |
Remarks:
- The Matlab code was developed in version 2019a, the R code in version 3.4.3 and the Python code in version 3.7.1. There is no guarantee that the code will work in older versions.
- Only the Matlab version of the neural network implementations have been optimised for speed. Thus this is the recommended version (although they are all fast).
- Rømer, S.E., Empirical analysis of rough and classical stochastic volatility models to the SPX and VIX markets, 2022, Quantitative Finance, DOI: 10.1080/14697688.2022.2081592.
- Heston, S. L., A closed-form solution for options with stochastic volatility with applications to bond and currency options. Review of Financial Studies 6, 1993, pp. 327–343.
- El Euch, O., Gatheral, J., and Rosenbaum, M., Roughening Heston. Risk, May 2019, pp. 84-89.
- Bayer, C., Friz, P., and Gatheral, J., Pricing under rough volatility. Quantitative Finance, 2016, 16(6), pp. 887-904.
- Horvath, B., Muguruza, A. and Tomas, M., Deep learning volatility: A deep neural network perspective on pricing and calibration in (rough) volatility models. Quantitative Finance, 2021, 21(1), pp. 11-27.
The following external packages and libraries are included in the project:
- Adi Navve (2020). Pack & Unpack variables to & from structures with enhanced functionality (https://www.mathworks.com/matlabcentral/fileexchange/31532-pack-unpack-variables-to-from-structures-with-enhanced-functionality), MATLAB Central File Exchange. Retrieved March 16, 2020.
- The neural network datasets for the rough Bergomi models are computed with this file in place of the HybridScheme.m file of this project. The only difference between the files is the FFT implementation, which has been made more readable in the current project. The two implementations are equivalent up to round-off error.