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

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

% 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 BDT tree and assume the volatility to be 10%. 
MatDates = {'1-Nov-2012'; '1-Nov-2013';'1-Nov-2014';'1-Nov-2015';'1-Nov-2016';'1-Nov-2017'};
BDTTimeSpec = bdttimespec(ValuationDate, MatDates);
Volatility = 0.1;  
BDTVolSpec = bdtvolspec(ValuationDate, MatDates, Volatility*ones(1,length(MatDates))');
BDTT = bdttree(BDTVolSpec, RateSpec, BDTTimeSpec);  

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