Monte Carlo Pricing of Down-and-Out Calls and Discretization Bias
Summary
The document diagnoses a Monte Carlo implementation for a European down-and-out call under Black–Scholes dynamics. Its central bug is that the payoff vector is reset to zeros inside the simulation loop, so previously simulated paths are discarded and only the final path contributes to the reported estimate. The suggested structure stores paths across simulations, computes each terminal payoff subject to the barrier condition, then discounts and averages the payoffs.
It also highlights two broader implementation issues: the original nested loops are inefficient in Matlab, and the special treatment of the first time step is poor practice. Because a discretely sampled path can cross a continuous barrier between observation times, the answer recommends Brownian bridge correction to reduce discretization error. It does not provide a correction formula or compare convergence, and its sample implementation is illustrative rather than a full treatment of variance reduction or Greeks. Greeks are asked about but not answered.
Key ideas
- Resetting the payoff vector inside the path loop discards earlier Monte Carlo outcomes and can leave only the last path in the estimate.
- A Monte Carlo barrier option estimate should average discounted payoffs across all simulated paths.
- Vectorizing path generation can make a Matlab implementation more efficient and clearer.
- Discrete path monitoring can miss barrier crossings between time steps, creating pricing error.
- Brownian bridge correction can compensate for some barrier-monitoring discretization error.
Tags
Full text
# Black scholes model for down and out European call option using Monte Carlo
# Black scholes model for down and out European call option using Monte Carlo
I tried to implement Matlab program computing the price of the European down and out call option using Monte Carlo and Euler discretization scheme. I have initial price S0=50, strike K=50, barrier level B=45 and time of expiration 6 months. The final price I obtain is very small(0.005). Even when I increase T to 1 or when I decrease the barrier, the price doesn't increase. I don't know what is the problem. I also have one additional question - how can I find Greeks(Delta,Vega,Gamma,Theta,Rho) with Monte Carlo simulation on this model? Here is my code:
```
function [Price]= BlackScholes (n,m,r,T,Var,S0,K,B)
Price=1:50;
for i=1:n
I=1;
for j = 0:(m-1);
Z(j+1)= randn (1 ,1);
dW=sqrt (T/m)*Z(j+1);
if j==0
S(j+1) = S0*exp((r-Var/2)*(T/m)+sqrt(Var)*dW);
if (I==1) & (S(j+1) <= B)
I = 0;
end
else
S(j +1) = S(j)* exp ((r - Var /2) *(T/m) + sqrt ( Var )* dW);
if all([ I==1 , S(j+1) <=B])
I = 0;
end
end
end
C=zeros(n,1);
C(i)= exp(-r*T)* max ((S(m-1)-K), 0)*I;
Price = sum (C (1:n))/n;
end
```
Thanks a lot!
## Answer by Quantuple (score 1, accepted)
https://quant.stackexchange.com/a/28038
There are many things wrong with your code. I'll leave aside the manner in which it is implemented, but note that it is: (1) not Matlab friendly with all the for loops (you should vectorise), (2) the fact that you have splitted the case j==0 in the main loop is a poor coding practice.
```
for i=1:n
I=1;
for j = 0:(m-1);
Z(j+1)= randn (1 ,1);
dW=sqrt (T/m)*Z(j+1);
if j==0
S(j+1) = S0*exp((r-Var/2)*(T/m)+sqrt(Var)*dW);
if (I==1) & (S(j+1) <= B)
I = 0;
end
else
S(j +1) = S(j)* exp ((r - Var /2) *(T/m) + sqrt ( Var )* dW);
if all([ I==1 , S(j+1) <=B])
I = 0;
end
end
end
C=zeros(n,1); %%% [1] THIS IS WRONG
C(i)= exp(-r*T)* max ((S(m-1)-K), 0)*I;
Price = sum (C (1:n))/n; %%% [2] THIS IS USELESS
end
```
The reason you observe very small prices, is that only the last path of your MC simulation contributes to the option price. This is because at the line marked with [1] above, you always reinitialise the price vector as a vector full of zeros. Also note that the line [2] is pretty useless and should lie outside of the for loop.
I would recommend an implementation along the lines of:
```
function price = mc_pricer(n,m,r,T,var,S0,K,B)
rng(0);
S = zeros(n,m);
S(:,1)=S0;
Z = randn(n,m-1);
t = linspace(0,T,m);
dt = diff(t);
for i=2:m
S(:,i)=S(:,i-1).*exp( (r-var/2)*dt(i-1) + sqrt(var*dt(i-1))*Z(:,i-1) );
end
S_T = S(:,end);
payoff = max(S_T-K, 0).*(1-any(S<=B,2));
price = exp(-r*T)*mean(payoff);
end
```
## Answer by zyy2016 (score 2)
https://quant.stackexchange.com/a/28048
Besides the code's problem, I highly recommend the Brownian Bridge correction method which can compensate the pricing error resulting from discretization of the continuous path.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.