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

    %% Compute the Price of an American Spread Option Using Monte Carlo Simulation Based on Geometric Brownian Motion  

% Copyright 2015 The MathWorks, Inc.


%% 
% Define the option. 
S1 = 110; % Price of first underlying asset
S2 = 100; % Price of second underlying asset
Sigma1 = .1;  % Volatility of first underlying asset
Sigma2 = .15; % Volatility of second underlying asset
Strike = 15; % Strike
Rho = .3; % Correlation between underlyings
OptSpec = 'put'; % Put option
Settle = '1-Jan-2013'; % Settlement date of option
Maturity = '1-Jan-2014'; % Maturity date of option
r = .05; % Risk-free rate (annual, continuous compounding)
Compounding = -1; % Continuous compounding
Basis = 0; % Act/Act day count convention
T = yearfrac(Settle, Maturity, Basis); % Time to expiration in years  

%% 
% Set up the |gbm| object and run the Monte Carlo simulation based on Geometric
% Brownian Motion (GBM) using the |simBySolution| method from Financial
% Toolbox(TM). 
NTRIALS = 1000;
NPERIODS = daysact(Settle, Maturity);
dt = T/NPERIODS;
SpreadGBM = gbm(r*eye(2), diag([Sigma1;Sigma2]),'Correlation',...
[1 Rho;Rho 1],'StartState',[S1;S2]);
[Paths, Times, Z] = simBySolution(SpreadGBM, NPERIODS,'NTRIALS',NTRIALS,...
'DeltaTime',dt,'Antithetic',true);  

%% 
% Create the interest-rate term structure to define |RateSpec|. 
RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ...
           'EndDates', Maturity, 'Rate', r, 'Compounding', Compounding, ...
           'Basis', Basis)  

%% 
% Price the American spread option. 
Spread = squeeze(Paths(:,1,:) - Paths(:,2,:));
SpreadPrice = optpricebysim(RateSpec, Spread, Times, OptSpec, Strike, ...
T, 'AmericanOpt', 1)