Skip to content
/ RMaFI Public

Solutions for exercises from John C. Hull's Risk Management and Financial Institutions

License

Notifications You must be signed in to change notification settings

ilchen/RMaFI

Repository files navigation

RMaFI

Solutions for exercises from John C. Hull's Risk Management and Financial Institutions using Python and Pandas.

So far I tackled Chapters 10 Volatility, 11 Correlations and Copulas, 13 Market Risk VaR: The Historical Simulation Approach, 14 Market Risk VaR: The Model Building Approach, 18 Fundamental Review of the Trading Book, and 19 Estimating Default Probabilities.

Requirements

For the majority of problems the following will suffice:

python3 -m pip install -r requirements.txt

For one problem in Chapter 11 Copulas and Correlations and a few problems relying on the Extreme Value Theory in Chapter 13 The Historical Simulation Approach, where we need to solve optimization problems, TensorFlow 2.x will be needed:

python3 -m pip install -r requirements_extra.txt

How to install using virtualenv

If you want to avoid mixing up packages in your global python installation, you can prepare the environment as follows:

python3 -m venv venv
source venv/bin/activate
python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements_extra.txt
python3 -m pip install jupyter

Data for Chapters 13, 14, and 18

The spreadsheet I used for exercises in these chapters can be downloaded from this page. I used VaRExampleRMFI3eHistoricalSimulation.xls for all these Chapters. Please remove the first row before feeding it to the code (for the spreadsheet in this repository I already did it).

Code in ch14/ replicates the functionality in VaRExampleRMFI3eModelBuilding.xls.

How to run

  • Chapter 10: Volatility Using Jupiter.

    jupyter notebook ch10.ipynb
    

    A full run of the notebook can be seen here.

  • Chapter 11: Correlations and Copulas

    jupyter notebook ch11.ipynb
    

    A full run of the notebook can be seen here.

    You can also run the notebook in Google cloud. This way you don't need to install anything locally. This takes just a few seconds:

    1. Go to Google Colaboratory in your browser
    2. In the modal window that appears select GitHub
    3. Enter the URL of this repository's notebook: https://github.com/ilchen/RMaFI/blob/master/ch11.ipynb
    4. Click the search icon
    5. Enjoy

    I make heavy use of the SciPy and TensorFlow 2 libraries in these exercises. as they draw heavily on probability theory and solving optimization problems. These exercises are fairly simple from software design point of view, so I limited the implementation to a Jupiter notebook.

    Despite there not being that many challenging exercises concerning the tracking and forecasting variances-covariances, I decided to create required classes to track and visualize correlations in a separate Jupiter notebook:

    jupyter notebook ch11_variance_covariance.ipynb
    

    A full run of the notebook can be seen here.

  • Chapter 13: Market Risk VaR: The Historical Simulation Approach

    python3 ch13/hist_simulation.py ./ext/VaRExampleRMFI3eHistoricalSimulation.xls
    

    Or, much better, using Jupiter. For historical simulation exercises that don't utilize the Extreme Value Theory:

    jupyter notebook ch13.ipynb
    

    For exercises that make use of the Extreme Value Theory:

    jupyter notebook ch13_evt.ipynb
    
  • Chapter 14: Market Risk VaR: The Model Building Approach

    python3 ch14/model_build.py ./ext/VaRExampleRMFI3eHistoricalSimulation.xls
    

    Or, much better, using Jupiter.

    jupyter notebook ch14.ipynb
    
  • Chapter 18: Fundamental Review of the Trading Book:

    python3 ch18/frtb.py ./ext/VaRExampleRMFI3eHistoricalSimulation.xls
    
  • Chapter 19: Estimating Default Probabilities

    jupyter notebook ch19.ipynb
    

    A full run of the notebook can be seen here.

    You can also run the notebook in Google cloud. This way you don't need to install anything locally. This takes just a few seconds:

    1. Go to Google Colaboratory in your browser
    2. In the modal window that appears select GitHub
    3. Enter the URL of this repository's notebook: https://github.com/ilchen/RMaFI/blob/master/ch19.ipynb
    4. Click the search icon
    5. Enjoy

About

Solutions for exercises from John C. Hull's Risk Management and Financial Institutions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published