Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # Monte Carlo path for rate option price
  2. # (problem 6)
  3. def P_MC(a, b, rho, v0, F0, T, K, call_put, numsteps, numsims):
  4. # running sum of rate option price for each MC path
  5. P = 0.
  6.  
  7. # MC iterations
  8. for i in range(numsims):
  9. F = F0
  10. v = v0
  11. dt = 1.*T / numsteps
  12.  
  13. # path simulation for this iteration
  14. for _ in range(numsteps):
  15. # correlated 2D normal random variables
  16. x, y = corr_norm(rho)
  17.  
  18. # F(i+1) = max(F(i) + sigma(i)*F(i)^beta * sqrt(dt) * x, 0)
  19. F = max(F + v*F**b*sqrt(dt)*x, 0.)
  20.  
  21. # sigma(i+1) = sigma(i) * e^(alpha * sqrt(dt) * y - alpha^2 * dt / 2)
  22. v = v * exp(a*sqrt(dt)*y - a*a*dt/2.)
  23.  
  24. # call(1) or put(-1) multiplier
  25. opt_type = 1. if 'c' in call_put else -1.
  26.  
  27. # add rate option value to running sum
  28. P += max(opt_type*(F-K), 0.) * 1 # is this correct rate option price scheme??
  29.  
  30. # rate option average value
  31. P /= numsims
  32.  
  33. return P
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement