How to plot a monte carlo simulation

11 visualizaciones (últimos 30 días)
user3.142
user3.142 el 19 de Mzo. de 2018
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.

Respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by