0% found this document useful (0 votes)
17 views62 pages

Vasicek Model Calibration in Python

Uploaded by

mohaawad2020
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views62 pages

Vasicek Model Calibration in Python

Uploaded by

mohaawad2020
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs.

30-yr vs. 2-yr, 5-yr, & 10-yr

Interest Rate Instruments


Lecture 4 - Data-Driven Analysis on LIBOR &
Swap Rates (Part I)

Financial Engineering
Industrial Engineering & Operations Research
Columbia University
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

Conjecture based on graphs

From the graphs, we can assume the following (linear) relationship


between swap rates1

ussw 5,t = a0 + a1 ussw 2,t


or
ussw 30,t = a0 + a1 ussw 10,t
or
ussw 30,t = a0 + a1 ussw 2,t + a2 ussw 5,t + a3 ussw 10,t

for simplicity we write it as

ŷt = f (xt ; Θ) = a0 + a1 x1,t + a2 x2,t + a3 x3,t

1
can do the same for LIBOR rates
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

Linear regression problem

This a linear regression problem


There are many options to find coefficients of the linear model

linear regression using least squares


using a gradient-free (e.g. Nelder-Mead) or gradient-based
(e.g. Mini-batch Gradient Descent) optimizer to minimize the
following objective function
T
1 X
`(Θ) = (ŷt − yt )2
2T t=1
T
1 X
= (f (xt ; Θ) − yt )2
2T t=1
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

Python sample code for linear regression

import pandas
from sklearn import linear model

df = [Link] csv(’[Link]’)

xX = [Link][:,6:12]
yY = [Link][:,12:13]

regr = linear [Link]()


[Link](xX, yY)
B = [Link]
[Link]
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

The Coefficient of Determination, R 2

PT
2 t=1 (ŷt − ȳ )2
R = PT
2
t=1 (yt − ȳ )
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

regress 5-yr against 2-yr (1 of 3)

regressing 5-yr against 2-yr from 1/2/14 to 5/24/16


Θ = (a0 , a1 ) = (1.8079, −0.2480)
R 2 = 4%
using Θ to construct 5-yr for that period
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

regress 5-yr against 2-yr (2 of 3)

regressing 5-yr against 2-yr from 5/25/16 to 10/11/18


Θ = (a0 , a1 ) = (0.4369, 0.9032)
R 2 = 97%
using Θ to construct 5-yr for that period
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

regress 5-yr against 2-yr (3 of 3)

regressing 5-yr against 2-yr from 1/2/14 to 10/11/18


Θ = (a0 , a1 ) = (1.038765, 0.62619)
R 2 = 77%
using Θ to construct 5-yr for that period
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

regress 30-yr against 15-yr (1 of 3)

regressing 30-yr against 15-yr from 1/2/14 to 5/24/16


Θ = (a0 , a1 ) = (0.0243, 1.0816)
R 2 = 99.5%
using Θ to construct 30-yr for that period
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

regress 30-yr against 15-yr (2 of 3)

regressing 30-yr against 15-yr from 5/25/16 to 10/11/18


Θ = (a0 , a1 ) = (0.4483, 0.8516)
R 2 = 99.5%
using Θ to construct 30-yr for that period
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

regress 30-yr against 15-yr (3 of 3)

regressing 30-yr against 15-yr from 1/2/14 to 10/11/18


Θ = (a0 , a1 ) = (0.19385, 0.986361)
R 2 = 95.4%
using Θ to construct 30-yr for that period
Conjecture Regression using least squares 5-yr vs. 2-yr 30-yr vs. 15-yr 30-yr vs. 2-yr, 5-yr, & 10-yr

regress 30-yr against 2-yr, 5-yr, and 10-yr


regressing 30-yr against 2-yr, 5-yr, & 10-yr from 1/2/14 to
5/24/16
Θ = (a0 , a1 , a2 , a3 ) = (0.3504, 0.0124, −0.7662, 1.6149)
R 2 = 99.4%
using Θ to construct 30-yr for that period
Regression using Nelder-Mead Regression using Gradient Descent

Interest Rate Instruments


Lecture 5 - Data-Driven Analysis on LIBOR &
Swap rates (Part II)

Financial Engineering
Industrial Engineering & Operations Research
Columbia University
Regression using Nelder-Mead Regression using Gradient Descent

Minimizing `(Θ) using Nelder-Mead

Using Nelder-Mead Simplex method to minimize the following


objective function
T
1 X
`(Θ) = (ŷt − yt )2
2T t=1
T
1 X
= (f (xt ; Θ) − yt )2
2T t=1
Regression using Nelder-Mead Regression using Gradient Descent

results obtained from Nelder-Mead (1/2/14 to 5/24/16)

5-yr against 2-yr


starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (1.8079, −0.2480)
30-yr against 10-yr
starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (−0.08145, 1.26867)
30-yr against 2-yr, 5-yr, & 10-yr
starting point: Θ0 = (a0 , a1 , a2 , a3 ) = (−100, −100, 100, 200)
optimal point:
Θ? = (a0 , a1 , a2 , a3 ) = (0.3504, 0.0124, −0.7662, 1.6149)
Regression using Nelder-Mead Regression using Gradient Descent

results obtained from Nelder-Mead (5/25/16 to 10/11/18)

5-yr against 2-yr


starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (0.437067, 0.90311)
30-yr against 10-yr
starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (0.76711, 0.762174)
30-yr against 2-yr, 5-yr, & 10-yr
starting point: Θ0 = (a0 , a1 , a2 , a3 ) = (−100, −100, 100, 200)
optimal point:
Θ? = (a0 , a1 , a2 , a3 ) = (0.2184, 0.3723, −1.4662, 2.0193)
Regression using Nelder-Mead Regression using Gradient Descent

results obtained from Nelder-Mead (1/2/14 to 10/11/18)

5-yr against 2-yr


starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (1.03876, 0.62619)
30-yr against 10-yr
starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (0.55861, 0.9203)
30-yr against 2-yr, 5-yr, & 10-yr
starting point: Θ0 = (a0 , a1 , a2 , a3 ) = (−100, −100, 100, 200)
optimal point:
Θ? = (a0 , a1 , a2 , a3 ) = (0.3102, 0.0499, −0.8208, 1.6563)
Regression using Nelder-Mead Regression using Gradient Descent

Batch, Mini-batch Gradient Descent

Batch Gradient Descent: using the entire


dataset
Mini-batch Gradient Descent: at each iteration,
compute the loss function for some subset of
the total dataset
Regression using Nelder-Mead Regression using Gradient Descent

Minimizing `(Θ) using Batch Gradient Descent

Vanilla (Batch) GD:


Θn+1 = Θn − γ∇`(Θn )
− yt ) ∂ŷ
∂` 1 PM t
where ∂θi = T j=1 (ŷt ∂θi
Mini-batch GD:
Θn+1 = Θn − γ∇`(D) (Θn )
∂`(D) 1
− yt ) ∂ŷ
∂θi for data in D
P t
where ∂θi = L j∈D (ŷt
Regression using Nelder-Mead Regression using Gradient Descent

Look at 5-yr vs. 2-yr for visualization purposes


Regression using Nelder-Mead Regression using Gradient Descent

Gradient Descent (1 of 3)

Closer the contours the steeper the slope


The direction of the steepest descent is (always)
perpendicular to the contours
This direction is expressed as a vector known as
the gradient
By evaluating the gradient at the current
position, can find the direction of steepest
descent and can take a step in that direction
By keep doing this we find the global minimum
Regression using Nelder-Mead Regression using Gradient Descent

Gradient Descent (2 of 3)

At each step of moving perpendicular to the


contour, we need to determine how far we want
to go before recalculating the new direction
It depends on the steepness of the surface to
make sure we do not overshoot
Closer we are to the minimum, wish to move
forward slower
Close to minimum the surface could be a lot
flatter
Steepness could be an indicator of how close we
are to minimum
Regression using Nelder-Mead Regression using Gradient Descent

Gradient Descent (3 of 3)

In general, we multiply the gradient by a factor


γ, learning rate to control that
For what γ & n?
We never find the minimum if γ is too big
If γ is too small, we would need much larger n
Regression using Nelder-Mead Regression using Gradient Descent

Various Learning Rates (1 of 5)


starting point: Θ0 = (a0 , a1 ) = (−100, −100)
terminal point: Θ300 = (a0 , a1 ) = (−14.82315, 10.68748) did
not converge, γ too small
Regression using Nelder-Mead Regression using Gradient Descent

Various Learning Rates (2 of 5)


starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (1.035979, 0.627968)
Regression using Nelder-Mead Regression using Gradient Descent

Various Learning Rates (3 of 5)


starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (1.037465, 0.6270249)
Regression using Nelder-Mead Regression using Gradient Descent

Various Learning Rates (4 of 5)


starting point: Θ0 = (a0 , a1 ) = (−100, −100)
optimal point: Θ? = (a0 , a1 ) = (1.037890, 0.626750)
Regression using Nelder-Mead Regression using Gradient Descent

Various Learning Rates (5 of 5)


starting point: Θ0 = (a0 , a1 ) = (−100, −100)
terminal point: diverged, γ too large
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Interest Rate Instruments


Lecture 6 - Short Rate Models (Vasicek)

Financial Engineering
Industrial Engineering & Operations Research
Columbia University
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Data-driven analysis to model-driven calibration

Transitioning from data-driven analysis to


model-driven calibration problem
There are various different frameworks for
valuing and pricing interest rate instruments and
derivatives
Short Rate Models
The Heath-Jarrow-Morton (HJM) model
Libor Market Models (LMM)
Swap Market Models (SMM)
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Short & Forward Rate Models

In short rate models, we assume a stochastic


process for evolution of instantaneous short rate
Zero-coupon bonds prices and other derivatives
being priced of that model
In HJM, we assume a stochastic process for
evolution of the instantaneous forward rate
Zero-coupon under HJM is straightforward
Other instruments being priced of that model
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Market Models

Unlike short rate models and HJM where the


rates are not observable, in market models,
either LIBOR or swaps which are both
observable and traded instruments would be
modeled
In market models, we assume LIBOR or swap
rates are evolving according to some stochastic
process
In LMM, we assume a stochastic process for
evolution of LIBOR rates
In SMM, we assume a stochastic process for
evolution of swap rates
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Short Rate Models (1 of 3)

The model under consideration would be short


rate models
They still remain popular because of their
parsimoniousness and ease of implementation
This is especially in situations where the level of
rates, and not the shape of the term structure,
is of primary importance
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Short Rate Models (2 of 3)

The focus is on the evolution of the term


structure of interest rates in terms of the
instantaneous short rate rs at time s
This is the instantaneous continuously
compounded interest rate
So discounting the exponential of integral of this
rate from the current time to any future time
and then taking the expectation would give the
zero-coupon bond price for that maturity
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Short Rate Models (3 of 3)

That is
 RT 
− rs ds
P(t, T ) = EQ
t e t
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Vasicek Model (1 of 5)

One of the first short rate models developed was


the Vasicek model
Like the Black-Merton-Scholes model, the
Vasicek model is the simplest model for the
evolution of interest rates
The Vasicek model assumes that the
instantaneous short rate, rt , follows the
following stochastic differential equation:

drt = κ(θ − rt )dt + σdWt


Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Vasicek Model (2 of 5)

The short rate is given a mean reversion component

drt = κ(θ − rt )dt + σdWt

with
θ being the long term mean of the short rate
κ being the mean reversion rate
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Vasicek Model (3 of 5)

The exact solution to the Vasicek SDE given by


Z t
rt = e κt
r0 + θ (1 − e κ t ) + σ e −κt

e κs dWs
0
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Vasicek Model (4 of 5)

The most important quantity when pricing fixed income


instruments is not the actual short rate, but the zero-coupon
bond prices
 RT 
P(t, T ) = EQ
t e− t
rs ds

= e A(t,T )−B(t,T )rt

where the loading factors are

1 − e −κ(T −t)
B(t, T ) =
κ
σ2 σ2 2
A(t, T ) = (θ − 2 )[B(t, T ) − (T − t)] − B (t, T )
2κ 4κ
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Vasicek Model (5 of 5)

Note that the function P(t, T ) is time-homogeneous


From these results, if interested in the evolution of
zero-coupon bond prices under this model, we can show
P(t, T ) satisfies the following SDE:

dP(t, T ) = rt P(t, T )dt − P(t, T )B(t, T )σdWt


Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Calibration Procedure

Calibration procedure for the Vasicek model is straightforward


It is a four-parameter model, namely Θ = {κ, θ, σ, r0 }
It is important to note that the parsimonious set of
parameters associated with this model provides very little in
the way of degrees of freedom, which will be essential in
model calibration
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Calibrating LIBOR & Swap rates to Vasicek

Because we have only four free parameters, it is impossible to


perfectly calibrate the model to the current term structure of
interest rates
For illustration purposes, we calibrate the Vasicek model to
LIBOR & swap rates
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

LIBOR rates for calibration

The next two tables contain LIBOR and swap rates used for
calibration as of Oct 18, 2016 and Oct 11, 2018

Table: LIBOR rates

LIBOR rates
maturity rate (%) rate (%)
(months) Dec 14, 2017 Oct 11, 2018
1 1.49078 2.27950
2 1.52997 2.33075
3 1.60042 2.43631
6 1.76769 2.63525
12 2.04263 2.95425
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Swap rates for calibration

Table: Swap rates

Swap rates
term rate (%) rate (%)
(years) Dec 14, 2017 Oct 11, 2018
2 2.0130 3.0408
3 2.1025 3.1054
5 2.1950 3.1332
7 2.2585 3.1562
10 2.3457 3.1990
15 2.4447 3.2437
30 2.5055 3.2270
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Objective Function

I (i) (i)
!2
X LMODEL − LMARKET
SSRE = (i)
i=1 LMARKET
J (j) (j)
!2
X SMODEL − SMARKET
+ (j)
j=1 SMARKET
Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Calibration using LIBOR & swap rates on Dec 14, 2017


Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Calibration using LIBOR & swap rates on Oct 11, 2018


Interest Rate Models Short Rate Models Vasicek Model Calibration Objective Function Calibration Results

Zero-Coupon Curves on Oct 11, 2018 vs. Dec 14, 2017


Drawback of Vasicek model CIR Objective Function Calibration Results

Interest Rate Instruments


Lecture 7 - Short Rate Models (CIR)

Financial Engineering
Industrial Engineering & Operations Research
Columbia University
Drawback of Vasicek model CIR Objective Function Calibration Results

CIR model

One of the major drawbacks of the Vasicek


model is that the instantaneous short rate can
become negative, implying negative interest
rates
In order to address this shortcoming, the CIR
model was developed
In the CIR process we assume that the
instantaneous short rate, rt , follows the
following stochastic differential equation:

drt = κ(θ − rt )dt + σ rt dWt
Drawback of Vasicek model CIR Objective Function Calibration Results

CIR model

We note that this is very similar to the Vasicek



model, with the single addition of the rt term
This term will go to zero as the short rate
approaches zero, effectively eliminating volatility
as the short rate declines
The addition of this term will force rt to remain
non-negative in the CIR model, unlike the
Vasicek model
However, one large downside is that the addition
of the volatility limiting term causes the CIR
model, unlike the Vasicek model, to be
non-Gaussian
Drawback of Vasicek model CIR Objective Function Calibration Results

CIR model
That means that pricing under the model is not nearly as
straightforward as Vasicek. However, a closed-form solution does
exist for zero-coupon bond prices. That is,
 RT 
− rs ds
P(t, T ) = EQ
t e t

= e A(t,T )−B(t,T )rt


where
!
2κθ exp(κ(T − t)/2)
A(t, T ) = ln
σ 2 cosh(γ(T − t)/2) + κγ sinh(γ(T − t)/2)
2
B(t, T ) =
κ + γ coth(γ(T − t)/2)

with
p
γ= κ2 + 2σ 2
Drawback of Vasicek model CIR Objective Function Calibration Results

CIR model

Closed-form solutions do not exist for most


interest rate derivatives under this model, so if
we are interested in pricing derivatives we
generally must use either Monte Carlo
simulation or numerical solutions of the PDE
While in the CIR model, we do have to deal with
the issue of negative rates, its similarly small
parameter set means it too cannot be calibrated
to the current term structure of interest rates
Drawback of Vasicek model CIR Objective Function Calibration Results

CIR model

The calibration procedure for the CIR model is


analogous to the calibration procedure for the
Vasicek model
We have three parameters to be calibrated:
Θ = {κ, θ, σ, r0 }
While the CIR model eliminates the negative
interest rate problem, we still have only four free
parameters, so we cannot expect to match the
current term structure of interest rates exactly,
nor price derivatives accurately
Drawback of Vasicek model CIR Objective Function Calibration Results

LIBOR rates for calibration

The next two tables contain LIBOR and swap rates used for
calibration as of Oct 18, 2016 and Oct 11, 2018

Table: LIBOR rates

LIBOR rates
maturity rate (%) rate (%)
(months) Dec 14, 2017 Oct 11, 2018
1 1.49078 2.27950
2 1.52997 2.33075
3 1.60042 2.43631
6 1.76769 2.63525
12 2.04263 2.95425
Drawback of Vasicek model CIR Objective Function Calibration Results

Swap rates for calibration

Table: Swap rates

Swap rates
term rate (%) rate (%)
(years) Dec 14, 2017 Oct 11, 2018
2 2.0130 3.0408
3 2.1025 3.1054
5 2.1950 3.1332
7 2.2585 3.1562
10 2.3457 3.1990
15 2.4447 3.2437
30 2.5055 3.2270
Drawback of Vasicek model CIR Objective Function Calibration Results

Objective Function

I (i) (i)
!2
X LMODEL − LMARKET
SSRE = (i)
i=1 LMARKET
J (j) (j)
!2
X SMODEL − SMARKET
+ (j)
j=1 SMARKET
Drawback of Vasicek model CIR Objective Function Calibration Results

Calibration using LIBOR & swap rates on Dec 14, 2017


Drawback of Vasicek model CIR Objective Function Calibration Results

Calibration using LIBOR & swap rates on Oct 11, 2018


Drawback of Vasicek model CIR Objective Function Calibration Results

Zero-Coupon Curves on Oct 11, 2018 vs. Dec 14, 2017


Drawback of Vasicek model CIR Objective Function Calibration Results

Vasicek vs. CIR on Dec 14, 2017


Drawback of Vasicek model CIR Objective Function Calibration Results

Vasicek vs. CIR on Oct 11, 2018

You might also like