The following codes implement all the methods covered in the book, where possible.
In addition to the original R and MATLAB used in the book, Python and Julia implementations are also provided.
All code was verified in July 2020 to run on R 4.0, MATLAB 2019b, Python 3.7.6 and Julia 1.4
The data files to be used with the code are:
We use external packages for estimating GARCH in every language. Currently, the packages used are:R
The MFE Toolbox by Kevin Sheppard includes both univariate and multivariate volatility models estimation.Python
The ARCH package by Kevin Sheppard allows univariate volatility estimations. Multivariate volatility estimation is currently not supported by this nor other Python package.Julia
The ARCHModels.jl package by Simon Broda allows for direct univariate GARCH estimations, along with CCC and DCC multivariate volatility modelling.
If anybody suggests alternative implementations to what is here, we would be happy to include a link.
Any bug fixes are more than welcome.
I would like to thank Alvaro Aguirre and Jia Fan for developing and updating the code and notebooks
The following code is presented pairwise (e.g. R and MATLAB, R and Python etc) for comparison.
Listing numbers correspond to the numbered R/MATLAB listing pairs in the book.
An additional Appendix section is provided as a short introduction, based on Appendix B/C in the book.
For more detailed documentation, please consult the book.
Each piece of code is labeled by the last date it got updated. If the date is 2011, then it is identical to the book. If it is more recent, some bug fix or improvement has been implemented.
|1. Financial Markets, Prices and Risk||✔||✔||✔||✔||✔||✔|
|2. Univariate Volatility Modeling||✔||✔||✔||✔||✔||✔|
|3. Multivariate Volatility Models||✔||✔||✔||✔||✔||✔|
|4. Risk Measures||✔||✔||✔||✔||✔||✔|
|5. Implementing Risk Forecasts||✔||✔||✔||✔||✔||✔|
|6. Analytical Value–at–Risk for Options and Bonds||✔||✔||✔||✔||✔||✔|
|7. Simulation Methods for VaR for Options and Bonds||✔||✔||✔||✔||✔||✔|
|8. Backtesting and Stress Testing||✔||✔||✔||✔||✔||✔|
|9. Extreme Value Theory||✔||✔||✔||✔||✔||✔|
Below is an implementation of the code using Jupyter notebooks. The formatted output is also downloadable as a .html file, for reference.