SYLLABUS Previous: 5.3.1 The Vasicek model
Up: 5.3 Methods for bonds
Next: 5.4 Computer quiz
// Construct the problem
c=b.dot(f); // A*fp=B*f=c as before
for (int i=1; i<n; i++) // Add swap source term
c[i]+= timeStep*h*(i*h-X);
c0=(f[0]+(x[0]-X)*timeStep)*Math.exp(timeStep*X);// Bounday conditions
a.setL(0, 0.);a.setD(0, 1.);a.setR(0, 0.);c[0]=c0;//left: Dirichlet
dPdyn=(f[n]-f[n-1])/h; cn=c[n-1]-2*dx[0]*a.getL(n-1)*dPdyn;
a.setL(n,a1n);a.setD(n,ann);a.setR(n, 0.);c[n]=cn;//right:Neuman
The Dirichlet boundary condition has been modified to account for the
compounded interest from the fixed swap rate
// Construct the problem
c=b.dot(f); // A*fp=B*f=c as before
for (int i=1; i<n; i++)
if (i*h<X) c[i]+=0;
else c[i]+=timeStep*h*(i*h-X);
a.setL(0, 0.);a.setD(0, 1.);a.setR(0, 0.);c[0]=0.;//left: Dirichlet
dPdyn=0; cn=c[n-1]-2*dx[0]*a.getL(n-1)*dPdyn;
a.setL(n,a1n);a.setD(n,ann);a.setR(n, 0.);c[n]=cn;//right:Neuman
Having calculated the fair price for a bond, a swap, cap or floor, it
is relatively easy to calculate the value of derivatives such as bond
options, swaptions, captions and floortions: their value depends on
the same random variable and therefore satisfies the same equation as
the underlying.
For example, after calculating the value of the bond by solving the
Vasicek equation (3.5#eq.6) backwards in time
SYLLABUS Previous: 5.3.1 The Vasicek model Up: 5.3 Methods for bonds Next: 5.4 Computer quiz