%% Price Call and Put Stock Options Using the Standard Trinomial Tree Model
% Create a RateSpec.

StartDates = 'Jan-1-2009'; 
EndDates = 'Jan-1-2013'; 
Rates = 0.035; 
Basis = 1; 
Compounding = -1;
RateSpec = intenvset('ValuationDate', StartDates, 'StartDates', StartDates,...
'EndDates', EndDates, 'Rates', Rates,'Compounding', Compounding, 'Basis', Basis)

%
% Create a StockSpec.

AssetPrice = 85; 
Sigma = 0.15; 
StockSpec = stockspec(Sigma, AssetPrice)

%
% Create an STTTree.

NumPeriods = 4;
TimeSpec = stttimespec(StartDates, EndDates, 4);
STTTree = stttree(StockSpec, RateSpec, TimeSpec)

%
% Define the call and put options and compute the price.

Settle = '1/1/09';
ExerciseDates = [datenum('1/1/11');datenum('1/1/12')];
OptSpec =  {'call';'put'};
Strike =[100;80];

Price = optstockbystt(STTTree, OptSpec, Strike, Settle, ExerciseDates)

% Copyright 2015 The MathWorks, Inc.