%% Price Callable Embedded Option for Floating-Rate Note
% Define the interest-rate term structure.

Rates = [0.03;0.034;0.038;0.04];
ValuationDate = 'Jan-1-2012';
StartDates = ValuationDate;
EndDates = {'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'; 'Jan-1-2016'};
Compounding = 1;

%
% Create the RateSpec.

RateSpec = intenvset('ValuationDate', ValuationDate, 'StartDates',...
StartDates, 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding)

%
% Build the BDT tree and assume a volatility of 10%.

Sigma = 0.1;
BDTTimeSpec = bdttimespec(ValuationDate, EndDates);
BDTVolSpec = bdtvolspec(ValuationDate, EndDates, Sigma*ones(1, length(EndDates))');
BDTT = bdttree(BDTVolSpec, RateSpec, BDTTimeSpec);

%
% Define the floater instruments with the embedded call option.

Spread = 10;
Settle = 'Jan-1-2012';
Maturity =  {'Jan-1-2015';'Jan-1-2016'};
Period = 1;
OptSpec = {'call'};
Strike = 101;
ExerciseDates = 'Jan-1-2015';

%
% Compute the price of the floaters with the embedded call.

Price= optemfloatbybdt(BDTT, Spread, Settle, Maturity, OptSpec, Strike,...
ExerciseDates)

% Copyright 2015 The MathWorks, Inc.