This C++ code implements the Bond Option Pricing in a Heath-Jarrow-Morton (HJM) framework. The HJM model is a mathematical framework used for modeling the evolution of interest rates over time. In particular, this code calculates the price of an option on a Zero-Coupon-Bond (ZCB) using the HJM model.
The project contains:
-
utils.h: a file with some utils. It contains:
- linear_interpolation: function to linearly interpolate a set of points
- integral: function to integrate a function nn an interval
-
cdf: cumulative density funcion of a standard gaussian
$N(0,1)$
-
main.cpp: the main of the project. It contains:
- DiscountCurve: a class that represents a Discount Curve with a linear interpolation
- HjmModel: a class to manage an HJM framework with a two-factor volatility
- OptionOnZcb: a class for an option on bond
The Discount Curve represents the relationship between the present value of a future cash flow and its maturity. The Discount Curve is represented as a vector of tenors and their corresponding values.
- Attributes:
- tenor (vector double): a vector of doubles representing tenors
- value (vector double): a vector of doubles representing the values of the tenors
- Methods:
- at: evaluate the discount curve at a specific tenor with a linear interpoation
Example:
int main(){
// ZCB prices obtained from the market
vector<double> zcb_tenor = {0, 1, 2, 3, 4, 5}; // T
vector<double> zcb_price = {1, 0.97, 0.94, 0.91, 0.9, 0.88}; // T -> P_0(T)
// Discount Curve Initialization
DiscountCurve P(zcb_tenor, zcb_price);
cout << P.at(0.5);
return 0;
}A class to collect the functions and the parameters of an HJM model with a two-factor volatility.
- Attributes:
- sigma1 (double): instantaneous volatility
- sigma2 (double): long-run time-dependent volatility
- lambda (double): mean reversion parameter of sigma2
- Methods:
- sigma_sq_mod: function that evaluates the instantaneous volatility depending on sigma1, sigma2 and lambda
Example:
int main(){
// HJM parameters
double sigma1 = 0.3;
double sigma2 = 0.2;
double lambda = 2;
// Discount Curve Initialization
HjmModel hjm(sigma1, sigma2, lambda);
hjm.print();
return 0;
}An OptionOnZcb represents an option on a Zero-Coupon Bond.
- Attributes
- strike (double): the strike price of the option
- option_ttm (double): the time to maturity of the option
- bond_ttm (double): the time to maturity of the underlying bond
- iscall (bool): a boolean representing whether the option is a call option (true) or put option (false)
- Methods:
- price: a method that evaluates the price of the option in a HJM framework
Example:
int main(){
// This is the conent of the main.cpp file
// ZCB prices obtained from the market
vector<double> zcb_tenor = {0, 1, 2, 3, 4, 5}; // T
vector<double> zcb_price = {1, 0.97, 0.94, 0.91, 0.9, 0.88}; // T -> P_0(T)
// HJM parameters
double sigma1 = 0.3;
double sigma2 = 0.2;
double lambda = 2;
// Options parameters
double strike = 0.5;
double option_maturity = 1.5; /* 1 year and half */
double bond_maturity = 4.5; /* 5 years and half */
double iscall = true;
double opt_price;
// Discount Curve Initialization
DiscountCurve P(zcb_tenor, zcb_price);
// HJM Model Initialization
HjmModel hjm(sigma1, sigma2, lambda);
// Option Initialization
OptionOnZcb opt(strike, option_maturity, bond_maturity, iscall);
P.print();
hjm.print();
opt.print();
opt_price = opt.price(P, hjm);
cout << "Price: " << opt_price;
return 0;
};In this section we recall the main results about the Heath–Jarrow–Morton (HJM) framework and we provide a closed formula for the pricing of an option on bond when the dynamic of the instantaneous forward rate is driven by a two-factor volatility.
The Heath Jarrow Morton (HJM) models consist in choosing a dynamic for the instantaneous forward rate
where
Under the risk-neutral measure the processes
The processes
Once chosen an expression for the volatility
where
In practice
In this section we will suppose the following framework for the HJM volatility. Given
Let consider a call option with maturity
where:
This formula calculates the price of an option on a zero-coupon-bond based on the HJM model parameters and the discount factors from a given discount curve.