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

    %% Price Options on Stocks Using the Leisen-Reimer Binomial Tree Model
% This example shows how to price options on stocks using the Leisen-Reimer
% binomial tree model. Consider European call and put options with an
% exercise price of $95 that expire on July 1, 2010. The underlying stock
% is trading at $100 on January 1, 2010, provides a continuous dividend
% yield of 3% per annum and has a volatility of 20% per annum. The
% annualized continuously compounded risk-free rate is 8% per annum. Using
% this data, compute the price of the options using the Leisen-Reimer model
% with a tree of 15 and 55 time steps.
%%

% Copyright 2015 The MathWorks, Inc.

AssetPrice  = 100;
Strike = 95;

ValuationDate = 'Jan-1-2010';
Maturity = 'July-1-2010'; 

% define StockSpec
Sigma = 0.2;
DividendType = 'continuous'; 
DividendAmounts = 0.03;

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

% define RateSpec
Rates = 0.08;
Settle = ValuationDate;
Basis = 1;
Compounding = -1;

RateSpec = intenvset('ValuationDate', ValuationDate, 'StartDates', Settle, ...
'EndDates', Maturity, 'Rates', Rates, 'Compounding', Compounding, 'Basis', Basis);

% build the Leisen-Reimer (LR) tree with 15 and 55 time steps
LRTimeSpec15  = lrtimespec(ValuationDate, Maturity, 15); 
LRTimeSpec55  = lrtimespec(ValuationDate, Maturity, 55); 

% use the PP2 method
LRMethod  = 'PP2';

LRTree15 = lrtree(StockSpec, RateSpec, LRTimeSpec15, Strike, 'method', LRMethod);
LRTree55 = lrtree(StockSpec, RateSpec, LRTimeSpec55, Strike, 'method', LRMethod);

% price the call and the put options using the LR model:
OptSpec = {'call'; 'put'}; 

PriceLR15 = optstockbylr(LRTree15, OptSpec, Strike, Settle, Maturity);
PriceLR55 = optstockbylr(LRTree55, OptSpec, Strike, Settle, Maturity);

% calculate price using the Black-Scholes model (BLS) to compare values with
% the LR model:
PriceBLS = optstockbybls(RateSpec, StockSpec, Settle, Maturity, OptSpec, Strike);

% compare values of BLS and LR
[PriceBLS PriceLR15 PriceLR55]

% use treeviewer to display LRTree of 15 time steps
treeviewer(LRTree15)