%% Create a CRR Tree
% Using the data provided, create a stock specification (StockSpec), rate specification (RateSpec), and tree time layout specification (TimeSpec). Then use these specifications to create a CRR tree with crrtree.

Sigma = 0.20;
AssetPrice = 50;
DividendType = 'cash';
DividendAmounts = [0.50; 0.50; 0.50; 0.50];
ExDividendDates = {'03-Jan-2003'; '01-Apr-2003'; '05-July-2003';
'01-Oct-2003'};

StockSpec = stockspec(Sigma, AssetPrice, DividendType, ...
DividendAmounts, ExDividendDates);

RateSpec = intenvset('Rates', 0.05, 'StartDates',...
'01-Jan-2003', 'EndDates', '31-Dec-2003','Compounding',-1);

ValuationDate = '1-Jan-2003';
Maturity = '31-Dec-2003';
TimeSpec = crrtimespec(ValuationDate, Maturity, 4);

CRRTree = crrtree(StockSpec, RateSpec, TimeSpec)

% Copyright 2020 The MathWorks, Inc.