Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Monte Carlo path for rate option price
- # (problem 6)
- def P_MC(a, b, rho, v0, F0, T, K, call_put, numsteps, numsims):
- # running sum of rate option price for each MC path
- P = 0.
- # MC iterations
- for i in range(numsims):
- F = F0
- v = v0
- dt = 1.*T / numsteps
- # path simulation for this iteration
- for _ in range(numsteps):
- # correlated 2D normal random variables
- x, y = corr_norm(rho)
- # F(i+1) = max(F(i) + sigma(i)*F(i)^beta * sqrt(dt) * x, 0)
- F = max(F + v*F**b*sqrt(dt)*x, 0.)
- # sigma(i+1) = sigma(i) * e^(alpha * sqrt(dt) * y - alpha^2 * dt / 2)
- v = v * exp(a*sqrt(dt)*y - a*a*dt/2.)
- # call(1) or put(-1) multiplier
- opt_type = 1. if 'c' in call_put else -1.
- # add rate option value to running sum
- P += max(opt_type*(F-K), 0.) * 1 # is this correct rate option price scheme??
- # rate option average value
- P /= numsims
- return P
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement