- Joined
- 11/20/14
- Messages
- 3
- Points
- 11
Hello,
I tried to simulate the price for an up-and out barrier call with mc in matlab, but I don't have consistent results.
My price is not non decreasing, it is up and down.
There is my code:
Thank you for the help
I tried to simulate the price for an up-and out barrier call with mc in matlab, but I don't have consistent results.
My price is not non decreasing, it is up and down.
There is my code:
Code:
function[prix]=call_mc_eu_bis(S0,Nmc,Nsteps,sigma,T,r,K)
sum = 0;
S(1) = S0
B = 12;
deltat = T / Nsteps;
for k=1:Nmc;
for n=1:Nsteps;
S(n+1)=S(n) * exp((r - sigma^(2) / 2 ) * deltat + sigma * sqrt(deltat) * randn );
if S(n+1) >= B;
gain(k)=0;
sum = sum + gain(k);
n=n+1
k=k+1;
end
end
gain(k) = max(S(Nsteps+1)-K,0);
sum = sum + gain(k);
end
prix = exp(-r*T) * sum / Nmc
end
Thank you for the help