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

    %% Price a Bond with an Amortization Schedule  
% Price a bond with an amortization schedule using the |Face| input argument
% to define the schedule.   

% Copyright 2015 The MathWorks, Inc.


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

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

%% 
% Create the bond instrument. The bond has a coupon rate of 7%, a period
% of one year, and matures on 1-Jan-2017. 
CouponRate = 0.07;
Settle ='1-Jan-2011';
Maturity = '1-Jan-2017';
Period = 1;
Face = {{'1-Jan-2015' 100;'1-Jan-2016' 90;'1-Jan-2017' 80}};  

%% 
% Build the BK tree with the following market data: 
VolDates = ['1-Jan-2012'; '1-Jan-2013';...
'1-Jan-2014';'1-Jan-2015';'1-Jan-2016';'1-Jan-2017'];
VolCurve = 0.01;
AlphaDates = '01-01-2017';
AlphaCurve = 0.1;

BKVolSpec = bkvolspec(RateSpec.ValuationDate, VolDates, VolCurve,... 
AlphaDates, AlphaCurve);
BKTimeSpec = bktimespec(RateSpec.ValuationDate, VolDates, Compounding);
BKT = bktree(BKVolSpec, RateSpec, BKTimeSpec);  

%% 
% Compute the price of the amortizing bond. 
Price = bondbybk(BKT, CouponRate, Settle, Maturity, 'Period', Period,...
'Face', Face)  

%% 
% Compare the results with price of a vanilla bond. 
PriceVanilla = bondbybk(BKT, CouponRate, Settle, Maturity, Period)