MATLAB Price Barrier Up and Out Call Flashcards
Simulate M trajectories in [t0,t0+T] in N time-steps of size delta T
Number of trajectories and time step for the simulation
M = 4 deltaT = T/N
Generate M x N samples from N(0,1)
X = randn (M,N)
Generate the matrix of initial stock price in the first column and multipliers in other columns
Y = [S0*ones(M,1)
exp((r-0.5sigma^2)deltaT+sigmasqrt(deltaT)X)]
Generate M trajectories with N monitoring times
S = cumprod(Y,2)
Check whether the trajectory is below the barrier:
1 if the price did not cross the barrier at some monitoring time;
0 otherwise
indexUnderBarrier = all(S kleiner als B,2)
Compute the payoff for each trajectory
value of S at maturity
ST = S(:,end)
Compute the payoff for the European Call Option
payoff = max(ST-K,0)
Assign payoff equal to zero if the price crossed the barrier
payoff = payoff*indexUnderBarrier
MC estimate of the price of the option and standard deviation of this estimate
discountFactor = exp(-r*T)
price_MC_UO = discountFactor*mean(payoff) stdev_MC_UO = discountFactor*std(payoff)/sqrt(M)