up-and-out barrier call

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:
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
 
The straightforward approach does not work and a well-known correction is needed. AFAIR there's some stuff on the Web.
 
The straightforward approach does not work .
By very large number of simulations paths it should do :)

If Nsteps = 1 year = 242 trading days, set Nmc=1e9
It should be enough for cent-precise price
(for practical financial calculation such precision is insufficient, in Germany it is required by the law to calculate with 5 decimal place precision).
 
Yes, a straightforward Monte-Carlo is in either case suboptimal for barrier options.

And I used exactly this case to demonstrate Monte-Carlo pitfalls (unfortunately the paper is in German).
What I meant is that one often sets the starting value of random number generator (i.e. the seed) and thus the simulation results are always perfectly reproducible. But behind this reproducibility one does not see that there is actually no convergence to the genuine values.
 
Can you post? Some of us can read German.

Stress test

sig = 1, Barrier very far away, and r = 0

Euler does not converge even after 10^3 draws LOL.
 
Hi, as this is the only relevant thread I could find, I am having some issues with my matlab code for a down and out call option in the analytical BS approach. It is outputting values but they are no where near as big as they should be for K>B . Would vastly appreciate any help.


function output=daocAnalytical(S,K,sigma,r,T,B)
% Input arguments: S = stock price at time t
% K = strike price
% r = interest rate as a percentage
% sigma = volatility as a percentage
% T = time to maturity in years
% B = barrier level
%% Output argument:f = down and out call price

% Precompute invariant quantities:
alpha = -1+(2*r)/(sigma^2);
beta = 1+(2*r)/(sigma^2);
a = (B/S)^alpha;
b = (B/S)^beta;
d1 = (log(S/K)+(r+0.5*sigma^2)*(T))/(sigma*sqrt(T));
d2 = d1 - sigma*sqrt(T);
d3 = (log(S/B)+(r+0.5*sigma^2)*(T))/(sigma*sqrt(T));
d4 = (log(S/B)+(r-0.5*sigma^2)*(T))/(sigma*sqrt(T));
d5 = (log(S/B)-(r+0.5*sigma^2)*(T))/(sigma*sqrt(T));
d6 = (log(S/B)-(r-0.5*sigma^2)*(T))/(sigma*sqrt(T));
d7 = (log(S*K/(B^2))-(r-0.5*sigma^2)*(T))/(sigma*sqrt(T));
d8 = (log(S*K/(B^2))-(r+0.5*sigma^2)*(T))/(sigma*sqrt(T));
% Normal distributions of d values:
Nd1 = 0.5*(1+erf(d1/sqrt(2)));
Nd2 = 0.5*(1+erf(d2/sqrt(2)));
Nd3 = 0.5*(1+erf(d3/sqrt(2)));
Nd4 = 0.5*(1+erf(d4/sqrt(2)));
Nd5 = 0.5*(1+erf(d5/sqrt(2)));
Nd6 = 0.5*(1+erf(d6/sqrt(2)));
Nd7 = 0.5*(1+erf(d7/sqrt(2)));
Nd8 = 0.5*(1+erf(d8/sqrt(2)));
% For down-and-out call:
if K > B
output = S*(Nd1-b*(1-Nd8))-K*exp(-r*T)*(Nd2-a*(1-Nd7));
else
output = S*(Nd3-b*(1-Nd6))-K*exp(-r*T)*(Nd4-a*(1-Nd5));
end
 
What answer do you get and what should the answer be?

Have you debugged your code, line for line? You mighta made a coding error.

Take special case to pinpoint the error, e.g. r = 0, etc.

See Haug's book 2007.
 
Last edited:
I managed to get my correct output, however when B>K=S_{0}, I am getting negative outputs rather than 0 for the DOC, is this a common error with the analytical approach?
for example by inputting into code above: daocAnalytical(950, 950, 0.25, 0.05, 1, 1000) my output is -78.0077.
 
I managed to get my correct output, however when B>K=S_{0}, I am getting negative outputs rather than 0 for the DOC, is this a common error with the analytical approach?
for example by inputting into code above: daocAnalytical(950, 950, 0.25, 0.05, 1, 1000) my output is -78.0077.
What does B > K > S_0 mean financially? can you ever get a down??

What does binomial, PDE, MC methods give?
 
Last edited:
B - barrier
K- strike price
S_0 - starting price

so for a down and out call when K=S_0 and K<B, the output should always be 0. However when using the PDE BS analytical method I am getting negative values. I have not tested with other methods as of yet.
 
Back
Top Bottom