How to plot a monte carlo simulation
10 次查看(过去 30 天)
显示 更早的评论
I am trying to price a call option using a monte carlo simulation and I have priced it, but I want to plot how it changes given the number of steps. My code is as follows:
function Value=cw2q6(S,E,T,r,sigma,A,M)
S=100;
E=90;
T=2;
r=0.03;
sigma=0.2;
A=110;
M=10000;
C = zeros(1,M);
for i=1:M
psi=randn;
ST = S*exp((r-0.5*sigma^2)*T+sigma*psi*sqrt(T));
if ST>E
payoff = A;
elseif ST==E
payoff = A/2;
elseif ST<E
payoff = 0;
end
C(1,i)=payoff*exp(-r*T);
end
Value = sum(C)/M;
end
I know that as I increase the number of steps the answer gets more accurate, I just want to show how the accuracy changes as we increase the number of steps. Any help is appreciated.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!