MATLAB: How to price an existing bond using the FLOATBYZERO function in the Financial Derivatives Toolbox

dateFinancial Derivatives Toolboxfloatfloatbyzerointenvsetpriceratespecsettlementvaluation

I would like to price the following bond using the FLOATBYZERO function:
The spread of the bond is 50bp. It is an existing floating bond which was issued two years ago. The last reset is 12/31/2004 and it will mature 12/31/2010. I would like to find the price of this bond on 4/5/2005.

Best Answer

The following code uses the FLOATBYZERO function to meet the bond specification:
Spread = 50;
Maturity = '12-31-2010';
Settle = '04-05-2005';
RateData = [datenum('12/31/2004') datenum('6/30/2005') 2.78
datenum( '4/5/2005') datenum('10/5/2005') 3.38
datenum( '4/5/2005') datenum( '4/5/2006') 3.79
datenum( '4/5/2005') datenum( '4/5/2007') 4.16
datenum( '4/5/2005') datenum( '4/5/2008') 4.36
datenum( '4/5/2005') datenum( '4/5/2010') 4.59
datenum( '4/5/2005') datenum( '4/5/2012') 4.76
datenum( '4/5/2005') datenum( '4/5/2015') 4.94];
StartDates = RateData(:,1);
EndDates = RateData(:,2);
Rates = RateData(:,3) / 100;
RateSpec = intenvset('ValuationDate', '12-31-2004', 'StartDates',StartDates, 'EndDates', EndDates, 'Rates', Rates)
Price = floatbyzero(RateSpec, Spread, Settle, Maturity, 2)