Quant Finance Series: Hull-White Model in Python

Abhinav Saini
3 min readJun 1, 2024

--

In this article, I will be showcasing how to project interest rates using the Hull-White 1 Factor model in python.

Background:

Interest rate modelling is an interesting area of Mathematical Finance. I would argue it is among the most mathematically challenging one too. Interest rates are projected through stochastic processes. A very well known stochastic process in Maths and Physics is Brownian Motion:

It turns out Brownian motion is very useful is describing how stock prices and interest rates move over time. Quants often use Brownian Motion and related concepts like: Radon-Nikodym Derivative, Ito’s Calculus and Girasanov Theorem to setup stochastic processes. For interest rates, we have a very general framework which can fit in most interest rate models: the Heath-Jarrow-Morton (HJM) Model:

Most interest rate models can be described as an HJM model including Hull-White which is defined as:

where alpha and σ are constants, and θ(t) is chosen in order to fit the input term structure of interest rates.

Code Structure:

Here we use QuantLib to show how to simulate the Hull-White model and investigate some of the properties. I am presenting high level steps followed in the code:

  1. Input Data:

We need a term structure of interest rates (yield curve) as an input. For this I am reusing the code in my previous commit. Please refer to my github repo (link provided below).

2. Setting up the parameters:

We need to setup multiple params for the model. First we set the maximum tenor till which we will project interest rates, then we select the time steps to discretize the grid. Finally, I have set the number of paths to be 4096 to give us good convergence results.

Note: I am not calibrating the alpha and σ params. We would need swaption volatilities data for this and short rate model calibration becomes a topic in itself. This code is just for demonstration purposes where we are projecting paths using the HW model given alpha and σ.

3. Generate Random Numbers and assign them to each Monte Carlo Paths:

We need to generate Monte Carlo Paths based on the conditions specified above. Finally I plot some charts to look at some of the outputs in the next section.

Results:

I am presenting two charts below:

  1. Top chart shows 4096 projected paths for the short rate. As can be seen, some of the rate paths are indeed negative. This is is because HW model treats interest rates as normally distributed. We also see very high interest rates courtesy the fact we haven’t calibrated the model to Swaption prices.
  2. The bottom chart shows the average of projected paths and the theoretically predicted averages across the term structure.
Monte Carlo Simulation of Interest Rates

The complete code can be found here: GitHub Repo

--

--

Abhinav Saini
Abhinav Saini

Written by Abhinav Saini

Interested in Technology, Books, Video Games and Finance. Tech geek at heart trying to make sense of the world.

Responses (2)