%% Price an Asian Option 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 Asian option and compute the price.

Settle = '01-Jan-2009';
ExerciseDates = [datenum('1/1/12');datenum('1/1/13')];
OptSpec = 'call';
Strike = 100;

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

% Copyright 2015 The MathWorks, Inc.