二项欧式期权定价模型
我使用VBA创build了一个程序来计算欧式看涨期权价格,如下所示:
Private Sub CallPrice_Click() Dim K As Single Dim So As Single Dim r As Single Dim T As Single Dim sigma As Single Dim u As Single Dim d As Single Dim p As Single Dim CP As Single Dim M As Single Dim S As Single Dim CB As Double Dim n As Integer Dim i As Integer K = Cells(2, 2) So = Cells(3, 2) r = Cells(4, 2) T = Cells(5, 2) sigma = Cells(6, 2) n = Cells(7, 2) u = Exp(sigma * Sqr(T / n)) d = 1 / u p = (Exp(r * T / n) - d) / (u - d) CP = 0 For i = 0 To n Step 1 M = WorksheetFunction.Max(So * (u ^ i) * d ^ (n - i) - K, 0) CB = WorksheetFunction.Combin(n, i) S = M * CB * (p ^ n) * (1 - p) ^ (n - i) CP = CP + S Next i Cells(9, 2) = CP / (1 + r) ^ n End Sub
这里是电子表格的布局:
当我运行程序时,发生错误。
有人可以在这里解释什么是我的程序错误,以及如何解决它?
你的S方程是否正确? 它似乎应该是:
S = M * CB * (p ^ i) ...
代替
S = M * CB * (p ^ n) ...
如果你的方程确实是错误的,那么你可以使用BINOMDIST而不是COMBIN,因为根据定义:
Binom_Dist(i, n, p, False) = (p ^ i) * (1 - p) ^ (n - i) * Combin(n, i)
所以你的代码是:
S = M * WorksheetFunction.Binom_Dist(i, n, p, False)
代替
CB = WorksheetFunction.Combin(n, i) S = M * CB * (p ^ n) * (1 - p) ^ (n - i)
BINOMDIST对大n,i来说不敏感。
你正在得到一个溢出错误。 如果您检查工作表:
COMBIN(5000, 161) = 3.3E+307 COMBIN(5000, 162) = #NUM! COMBIN(5000, 4838) = #NUM! COMBIN(5000, 4839) = 3.3E+307
请记住,组合的数量将呈指数增长,直到它以一个反比率开始下降的中途点。