www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PricebondbyhwTwoBondswithAmortizationSchedulesExample.m

    %% Price Two Bonds with Amortization Schedules  
% Price two bonds with amortization schedules using the |Face| input argument
% to define the schedules.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Define the interest rate term structure. 
Rates = 0.035;
ValuationDate = '1-Nov-2011';
StartDates = ValuationDate;
EndDates = '1-Nov-2017';
Compounding = 1;  

%% 
% Create the |RateSpec|. 
RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,...
'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding);  

%% 
% Create the bond instrument. The bonds have a coupon rate of 4% and 3.85%,
% a period of one year, and mature on 1-Nov-2017. 
CouponRate = [0.04; 0.0385];
Settle ='1-Nov-2011';
Maturity = '1-Nov-2017';
Period = 1;  

%% 
% Define the amortizing schedule. 
Face = {{'1-Nov-2015' 100;'1-Nov-2016' 85;'1-Nov-2017' 70};
{'1-Nov-2015' 100;'1-Nov-2016' 90;'1-Nov-2017' 80}};  

%% 
% Build the HW tree and assume the volatility to be 10%. 
VolDates = ['1-Nov-2012'; '1-Nov-2013';'1-Nov-2014';'1-Nov-2015';'1-Nov-2016';'1-Nov-2017'];
VolCurve = 0.1;
AlphaDates = '01-01-2017';
AlphaCurve = 0.1;

HWVolSpec = hwvolspec(RateSpec.ValuationDate, VolDates, VolCurve,... 
AlphaDates, AlphaCurve);
HWTimeSpec = hwtimespec(RateSpec.ValuationDate, VolDates, Compounding);
HWT = hwtree(HWVolSpec, RateSpec, HWTimeSpec);  

%% 
% Compute the price of the amortizing bonds. 
Price = bondbyhw(HWT, CouponRate, Settle, Maturity, 'Period',Period,...
'Face', Face)