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

    %% Compute the Price of American Call and Put Options on a Floating-Rate Note  

% Copyright 2015 The MathWorks, Inc.


%% 
% 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)  

%% 
% The floater instrument has a spread of 10, a period of one year, and matures
% on Jan-1-2016. 
Spread = 10;
Settle = 'Jan-1-2012';
Maturity =  'Jan-1-2016';
Period = 1;  

%% 
% Define the option for the floating-rate note. 
OptSpec = {'call'; 'put'};
Strike = [100;101];
ExerciseDates = 'Jan-1-2015';
AmericanOpt = 1;  

%% 
% Compute the price of the call and put options. 
Price= optfloatbybdt(BDTT,  OptSpec, Strike, ExerciseDates,AmericanOpt, Spread,...
Settle, Maturity)