初学VBA做期权定价公式的程序,可用数据如下:
Current stock price (s) $ 18,75
Divident yield (di) 0
Volatility of stock return (sd) (historical volatility) 0,3
Strike price (x) $ 35
Time to expiration (t) years 5
Risk-free rate (rf) % 0,0602
Number of steps (n) 1000
VBA codes:
Function Euro_call(s, di, sd, x, t, rf, n)
'calculate price of a Europeran call option by Binomial tree model'
Dim u As Double
Dim d As Double
Dim p As Double
Dim bicomp As Double
Dim sumbi As Double
Dim h As Double
Dim j As Integer
'calculate u,d,p'
h = t / n
u = Exp(sd * Sqr(h))
d = Exp(-1 * sd * Sqr(h))
p = (Exp((rf - di) * h) - d) / (u - d)
'calculate expected call payoff at time t'
For j = 1 To n
bicomp = Application.Combin(n, j) * (p ^ j) * ((1 - p) ^ (n - j)) * Application.Max(s * (u ^ j) * (d ^ (n - j)) - x, 0)
sumbi = sumbi + bicomp
Next j
'calculate call price = PV of expected payoff'
Euro_call = sumbi * Exp(-1 * rf * t)
End Function
为什么运行上面的宏程序,电脑显示“参数不可选”?
急用,在线等,谢谢各位大侠!