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

    %% Compute the Price of American and European Call 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 BK tree. 
VolDates = ['1-Jan-2013'; '1-Jan-2014'; '1-Jan-2015';'1-Jan-2016'];
VolCurve = 0.01;
AlphaDates = '01-01-2016';
AlphaCurve = 0.1;

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

%% 
% 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'};
Strike = 95;
ExerciseDates = 'Jan-1-2016';
AmericanOpt = [0;1];   

%% 
% Compute the price of the call options. 
Price= optfloatbyhw(HWT,  OptSpec, Strike, ExerciseDates,AmericanOpt,...
Spread, Settle, Maturity)