Overview
The value of the money market account at time {% t %} (when evaluated in a continuous time framework) is given by
{% \displaystyle B(t) = exp(\int_0^t r(u)du) %}
where {% r %} is the random instantaneous interest rate.
The value of {% $1 %} paid at time {% t %}, valued at {% t=0 %} using risk neutral pricing and a risk neutral pricing measure is given by the following formula
{% \displaystyle Price = \mathbb{E}[1/B(t)] = \mathbb{E}[exp(-\int_0^t r(u)du)] %}
Valuation Models
The following code simulates the Vasicek Short Rate Model and prices a zero coupon bond that matures in 1 year.
let ito = await import('/lib/statistics/simulations/v1.0.0/ito.mjs');
function simulate(){
let a = 0.1;
let b = 0.1;
let sigma = 0.1;
//the coefficient of the dt term
let dt = function(points){
return b - a*points[points.length-1]
}
let sims = ito.generate(300, dt, ()=>sigma, 0.5);
let deltaT = 1/300;
let integral = $list(sims).map(p=>p*deltaT/100).sum();
let moneyMarket = Math.exp(integral);
let zeroCoupon = 1/moneyMarket;
return zeroCoupon;
}
let zeroCoupon = $list($range(1,1000).map(p=>simulate())).average();
$console.log(zeroCoupon);
Try it!