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

    %% Compute the Price of an Amortizing and Vanilla Floors Using the HW Model   

% Copyright 2015 The MathWorks, Inc.


%% 
% Define the |RateSpec|. 
Rates = [0.035; 0.042; 0.047; 0.052; 0.054];
ValuationDate = '01-April-2014';
StartDates = ValuationDate;
EndDates = {'01-April-2019'};
Compounding = 1;
RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,...
'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding)  

%% 
% Define the floor instruments. 
Settle ='01-April-2014';
Maturity = '01-April-2018';
Strike = 0.05;
Reset = 1;
Principal ={{'01-April-2015' 100;'01-April-2016' 60;'01-April-2017' 40;'01-April-2018' 20};
            100};  

%% 
% Build the HW Tree. 
VolDates = ['01-April-2015';'01-April-2016';'01-April-2017';'01-April-2018'];
VolCurve = 0.05;
AlphaDates = '01-April-2018';
AlphaCurve = 0.10;

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

%% 
% Price the amortizing and vanilla floors. 
Basis = 0;
Price  = floorbyhw(HWTree, Strike, Settle, Maturity, Reset, Basis, Principal)