1
Stochastic Differential Equations and Interest Rate Models Group Project 15 February 2007 On the website you will find a Zip file containing the code for the trinomial tree implemen- tation of the Hull-White model, together with a speadsheet giving yield curve data. At the moment, the code does the calibration and computes ZC bond values p(0,t) for t = . It has an extremely primitive Discount class which just takes a scalar parameter r and returns p(0,t)= e -rt . Your tasks are as follows. Task 1. Rewrite the Discount class so that it reads in a table such as the one on the spreadsheet, which contains a list, of arbitrary length, of times in years and discount factors expressed as continuously-compounding zero-coupon yields. The function B is to return the discount factor for an arbitrary time, by linear interpolation of the yields. You need to write another exported discount factor function as well, for test purposes. Task 2. Write an exported swaption pricing function. The function header will be DOUBLE Swaption(long payer, long T0, long Tswap, long freq, double K, long ppy, double sig, double lam, double* YieldCurveData) Here payer=1 for a payer’s swaption, payer=0 for a receiver’s swaption, T0 is the start time (in integer numbers of years) of the underlying swap, Tswap is the length of the swap once entered (so the last payment date is T0+Tswap), K is the strike (the fixed side rate in the swap) and YieldCurveData is a 1-dimensional array containg the data in the yield curve table. The function Swaption will act in the same way as the function ZCB in the present code—i.e., it will declare an instance of class Tree and call a swaption pricing function written within that class. Task 3. Write a Visual Basic function VBSwaption which calls the C++ Swaption function, so that you can do swaption pricing on the spreadsheet. Calculate the value of a 3 into 5 payer’s swaption (i.e. T0=3, Tswap=5) with K=3.3% and semi-annual coupon dates (the accrual convention is θ i =0.5 for all i). Use the data on the spreadsheet, and take σ =0.012=0.05. Task 4. As we showed in class, in the Hull-White model we can express the option price analytically by decomposing the strike into K = i K i and using the Black ‘forward’ option pricing formula. The data required is σ, λ and the discount factor p(0,t k ) for every coupon date t k . The latter you can get from the discount function you have already written. Now do the calculation and compare the answer with what you get from the tree. [You can organize this computation any way you like: write more C++ code, do it in Excel with a bit of VB, or do an entirely separate calculation in, say, Matlab. It’s up to you.] The deadline for completing this project is 12 noon, Monday 5 March. Each group should email should email me a Zip file (called Group n.zip where n is the group number) containing your complete C++ project, the spreadsheet with the new VB functions included, and a short report—one or two pages at most, in Word or Latex—stating what you’ve done (I don’t need to know who did what), giving the Swaption price requested above, the calculations for Task 4, and any comments or observations you want to make. 1

Irm07 Group Project

Embed Size (px)

DESCRIPTION

Imperial College London assignment.

Citation preview

Page 1: Irm07 Group Project

Stochastic Differential Equations and Interest Rate Models

Group Project

15 February 2007

On the website you will find a Zip file containing the code for the trinomial tree implemen-

tation of the Hull-White model, together with a speadsheet giving yield curve data. At the

moment, the code does the calibration and computes ZC bond values p(0, t) for t = kδ. It

has an extremely primitive Discount class which just takes a scalar parameter r and returns

p(0, t) = e−rt. Your tasks are as follows.

Task 1. Rewrite the Discount class so that it reads in a table such as the one on the spreadsheet,

which contains a list, of arbitrary length, of times in years and discount factors expressed as

continuously-compounding zero-coupon yields. The function B is to return the discount factor

for an arbitrary time, by linear interpolation of the yields. You need to write another exported

discount factor function as well, for test purposes.

Task 2. Write an exported swaption pricing function. The function header will be

DOUBLE Swaption(long payer, long T0, long Tswap, long freq, double K, long ppy,

double sig, double lam, double* YieldCurveData)

Here payer=1 for a payer’s swaption, payer=0 for a receiver’s swaption, T0 is the start

time (in integer numbers of years) of the underlying swap, Tswap is the length of the swap once

entered (so the last payment date is T0+Tswap), K is the strike (the fixed side rate in the swap)

and YieldCurveData is a 1-dimensional array containg the data in the yield curve table. The

function Swaption will act in the same way as the function ZCB in the present code—i.e., it will

declare an instance of class Tree and call a swaption pricing function written within that class.

Task 3. Write a Visual Basic function VBSwaption which calls the C++ Swaption function,

so that you can do swaption pricing on the spreadsheet. Calculate the value of a 3 into 5

payer’s swaption (i.e. T0=3, Tswap=5) with K=3.3% and semi-annual coupon dates (the accrual

convention is θi = 0.5 for all i). Use the data on the spreadsheet, and take σ = 0.012, λ = 0.05.

Task 4. As we showed in class, in the Hull-White model we can express the option price

analytically by decomposing the strike into K =∑iKi and using the Black ‘forward’ option

pricing formula. The data required is σ, λ and the discount factor p(0, tk) for every coupon date

tk. The latter you can get from the discount function you have already written. Now do the

calculation and compare the answer with what you get from the tree. [You can organize this

computation any way you like: write more C++ code, do it in Excel with a bit of VB, or do an

entirely separate calculation in, say, Matlab. It’s up to you.]

The deadline for completing this project is 12 noon, Monday 5 March. Each group should

email should email me a Zip file (called Group n.zip where n is the group number) containing

your complete C++ project, the spreadsheet with the new VB functions included, and a short

report—one or two pages at most, in Word or Latex—stating what you’ve done (I don’t need

to know who did what), giving the Swaption price requested above, the calculations for Task 4,

and any comments or observations you want to make.

1