Welcome to THETAWIKI. If you like to create or edit a page please make sure to login or register an account. All registered users please make sure to provide a valid email address.

Barrier Option

From ThetaWiki
Jump to: navigation, search

There are numerous different Barrier options. The following code prices an up-and-out barrier option with barrier level H.


P = 100;
sigma = 0.4;
r = 0.05;
t = 0;
T = 2;
H = 120;
X = 100;
 
d_1 = (log(P/X)+(r+0.5*sigma^2)*(T-t) ) /(sigma*sqrt(T-t) );
d_2 = (log(P/X)+(r-0.5*sigma^2)*(T-t) ) /(sigma*sqrt(T-t) );
d_3 = (log(P/H)+(r+0.5*sigma^2)*(T-t) ) /(sigma*sqrt(T-t) );
d_4 = (log(P/H)+(r-0.5*sigma^2)*(T-t) ) /(sigma*sqrt(T-t) );
d_5 = (log(P/H)-(r-0.5*sigma^2)*(T-t) ) /(sigma*sqrt(T-t) );
d_6 = (log(P/H)-(r+0.5*sigma^2)*(T-t) ) /(sigma*sqrt(T-t) );
d_7 = (log(P*X/(H^2))-(r-0.5*sigma^2)*(T-t) ) /(sigma*sqrt(T-t) );
d_8 = (log(P*X/(H^2))-(r+0.5*sigma^2)*(T-t) ) /(sigma*sqrt(T-t) );
 
a=(H/P)^(-1+2*r/(sigma^2));
b=(H/P)^( 1+2*r/(sigma^2));
 
V = P*(normcdf(d_1) - normcdf(d_3) - b*(normcdf(d_6)- normcdf(d_8)))...
 - X*exp(-r*(T-t))*(normcdf(d_2)-normcdf(d_4)-a*(normcdf(d_5)-normcdf(d_7)))