Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Note: due to 64 bit floating point limitations, do not call with N>60
- function binomEU(S,K,T,r,sigma,N)
- if N>60
- error("USE N<60")
- end
- dt = T/N
- U = exp((r - (sigma^2)/2)*dt + sigma*(dt^.5))
- D = exp((r - (sigma^2)/2)*dt - sigma*(dt^.5))
- R = exp(r*dt)
- P = (R-D)/(U-D)
- period = Array{Float64}(N)
- for i in 1:N
- period[i] = binomial(N,i) * P^i *(1-P)^(N-i) * max(U^i * D^(N-i) *S - K,0)
- end
- C = (1/R^N)*sum(period)
- P = C - (S - K*R^(-N))
- return C,P
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement