我想我可能已经对这个问题视而不见了。它不应该那么难。
我已经让方程式的所有组件分开工作但是有些东西不起作用 - 是变量的声明还是函数本身?
目前,我只是想让它输出一个数字:/
此功能正常
Function d(K, a1, b1)
d = (-Log(K) + a1 + b1 * b1) / b1
End Function
这个没有(两个功能都包含在同一个模块中):
Function LN_Call(r As Double, t As Double, K As Double, w As Double, a1 As Double, b1 As Double, a2 As Double, b2 As Double) As Double
Dim d1 As Double
Dim d2 As Double
Dim d3 As Double
Dim d4 As Double
Dim temp1 As Double
Dim temp2 As Double
Dim result As Double
d1 = d(K, a1, b1)
d2 = d1 - b1
d3 = d(K, a1, b1)
d4 = d3 - b2
temp1 = Exp(a1 + b1 * b1 / 2)
temp2 = Exp(a2 + b2 * b2 / 2)
LN_Call = Exp(-r * t) * (w * (temp1 * Application.WorksheetFunction.NormSDist(d1) - K * Application.WorksheetFunction.NormSDist(d2)) + (1 - w) * (temp2 * Application.WorksheetFunction.NormSDist(d3) - K * Application.WorksheetFunction.NormSDist(d4)))
End Function
你能告诉我出了什么问题吗?
答案 0 :(得分:0)
显然,你的行中没有定义函数d():
d1 = d(K, a1, b1)
除非包含在相同模块中。
如果包含,则:
=LN_Call(1,1,1,1,1,1,1,1)
返回:
<强> 1.301699209 强>
结果是O.K。?