⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 montecarloeuro.m

📁 蒙特卡洛模拟来计算欧式期权的定价
💻 M
字号:
function [P] = MonteCarloEuro(OptionType,So,K,r,T,sigma,NSimulations)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This function prices a Vanilla European Call/Put Option Value           %
% using Monte Carlo Simulation.                                           %
% No dividends are assumed in this model                                  %
% Parameters are as follows:                                              %
% OptionType = 1 for a Call or 0 for a Put                                %
% So = initial asset price ; K = strike price ; r = risk free rate        %
% T = time to maturity ;  sigma = volatility ;                            %
% NSimulations = number of simulations                                    %
% This function keeps track of the time required to price the option.     % 
% Note: When pricing using Monte Carlo simulations, you increase accuracy %
% by increasing the number of simulations. At least 5,000,000 simulations %
% seems sufficient for pricing accuracy within one cent.                  %
                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

tic % Keep track of time

% Generate time to maturity simulations
ST = So * exp( (r - 0.5 * sigma^2) * T + sigma * sqrt(T) * randn(NSimulations,1) );

% Price the option
if OptionType == 1
    P = mean( exp(-r * T) * max(0, ST - K) ); % Call pricing
else
    P = mean( exp(-r * T) * max(0, K - ST) ); % Put pricing
end

toc % Keep track of time

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -