www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/ComputethePriceofanAmericanAsianOptionUsingMonteCarloSimExample.m
%% Compute the Price of an American Asian Option Using Monte Carlo Simulation Based on Geometric Brownian Motion % Copyright 2015 The MathWorks, Inc. %% % Define the option. S0 = 100; % Initial price of underlying asset Sigma = .2; % Volatility of underlying asset Strike = 110; % Strike OptSpec = 'call'; % Call 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; OptionGBM = gbm(r, Sigma, 'StartState', S0); [Paths, Times, Z] = simBySolution(OptionGBM, 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 an American Asian option (arithmetic mean) by finding the average % price over periods. AvgPrices = zeros(NPERIODS+1, NTRIALS); for i = 1:NPERIODS+1 AvgPrices(i,:) = mean(squeeze(Paths(1:i,:,:))); end AsianPrice = optpricebysim(RateSpec, AvgPrices, Times, OptSpec, ... Strike, T, 'AmericanOpt', 1)