Function BinoptVal(iopt, iea, S, X, r, tyr, sigma, nstep)
'Returns Binomial Option Value(ipot=1 for call,-1for put;
'iea=1 for euro,=2 for amer)
Dim delt, erdt, ermqdt, u, d, P, pstar, mu
Dim i As Integer, j As Integer
Dim vvec As Variant 'to be a vector
ReDim vvec(nstep) 'know size of vector
'caculate parameters
delt = tyr / nstep 'length of the time step
erdt = Exp(r * delt) 'compounding factor
mu = 0
u = Exp(mu * delt + sigma * Sqr(delt)) 'up multiplier
d = Exp(mu * delt - sigma * Sqr(delt)) 'down multiplier
P = (ermqdt - d) / (u - d) ' up prob
pstar = 1 - P 'down prob
'calculating vector of option values after n steps
For i = 0 To nstep
vvec(i) = Application.Max(iopt * (S * (u ^ i) * (d ^ (nstep - i)) - X), 0)
Next i
'calculating conditional payoffs & discounting back step by step
For j = nstep - 1 To 0 Step -1
For i = 0 To j
vvec(i) = (P * vvec(i + 1) + pstar * vvec(i)) / erdt
Next i
Next j
BinoptVal = vvec(0)
End Function |