%% Compute the Price of an Amortizing Floor Using the BDT Model
% Define the RateSpec.

Rates = [0.03583; 0.042147; 0.047345; 0.052707; 0.054302];
ValuationDate = '15-Nov-2011';
StartDates = ValuationDate;
EndDates = {'15-Nov-2012';'15-Nov-2013';'15-Nov-2014' ;'15-Nov-2015';'15-Nov-2016'};
Compounding = 1;
RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,...
'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding)

%
% Define the floor instrument.

Settle ='15-Nov-2011';
Maturity = '15-Nov-2015';
Strike = 0.039;
Reset = 1;
Principal ={{'15-Nov-2012' 100;'15-Nov-2013' 70;'15-Nov-2014' 40;'15-Nov-2015' 10}};

%
% Build the BDT Tree.

BDTTimeSpec = bdttimespec(ValuationDate, EndDates);
Volatility = 0.10;  
BDTVolSpec = bdtvolspec(ValuationDate, EndDates, Volatility*ones(1,length(EndDates))');
BDTTree = bdttree(BDTVolSpec, RateSpec, BDTTimeSpec)

%
% Price the amortizing floor.

Basis = 0;
Price = floorbybdt(BDTTree, Strike, Settle, Maturity, Reset, Basis, Principal)

% Copyright 2015 The MathWorks, Inc.