Up and In call barrier
%% Up and in barrier call option
clear;
clc;
mu=0.05;
sig=0.15;
n=20; % No of steps
t1=0.25;
t=t1/n;
m=10; % no of simulations
z=randn(m,n);
st=zeros(m,n+1);
st(:,1)=100;
st(:,n+1) = 110;
barrier=110;
k=100;
for j=1:m
for i=2:n
st(j,i)=st(j,i-1)*exp((mu-sig^2/2)*t+sig*sqrt(t)*z(j,i-1));
end
if(max(st(j,:))>=barrier)
pay_call(j,1)=max(0,st(j,n)-k);
else
pay_call(j,1)=0;
end
end
call_price=exp(-mu*t1)*mean(pay_call);
plot(st)