使用 LOG 在同一公式上宏输出与手动输出的区别
Difference in Macro vs Manual Output on same formula using LOG
好吧,这是一个非常奇怪的问题
我有一个生成选项增量的宏(d1):
Function dOne(UnderlyingPrice, ExercisePrice, Time, Interest, Volatility, Dividend)
dOne = (Log(UnderlyingPrice / ExercisePrice) + (Interest - Dividend + (0.5 * Volatility ^ 2)) * Time) / (Volatility * (Sqr(Time)))
End Function
当我将值传递给它时,它会生成所需的输出:
然而,当我尝试在 Excel 中复制它时,它给出了完全不同的输出
我知道手动生成的输出的计算是正确的。
但是,所需的值是从 VBA.
生成的值
请提出我在这里遗漏了什么。
VBA中的Log
函数是自然对数:ln(x).
公式中的LOG
函数是以10为底的对数:log10(x)。
如果您想在 VBA 中以 10 为底进行对数,则必须使用对数恒等式来转换底数:
Log(x)/Log(10)
你的情况
dOne = (Log(UnderlyingPrice / ExercisePrice) / Log(10) + (Interest - Dividend + (0.5 * Volatility ^ 2)) * Time) / (Volatility * (Sqr(Time)))
好吧,这是一个非常奇怪的问题
我有一个生成选项增量的宏(d1):
Function dOne(UnderlyingPrice, ExercisePrice, Time, Interest, Volatility, Dividend)
dOne = (Log(UnderlyingPrice / ExercisePrice) + (Interest - Dividend + (0.5 * Volatility ^ 2)) * Time) / (Volatility * (Sqr(Time)))
End Function
当我将值传递给它时,它会生成所需的输出:
然而,当我尝试在 Excel 中复制它时,它给出了完全不同的输出
我知道手动生成的输出的计算是正确的。 但是,所需的值是从 VBA.
生成的值请提出我在这里遗漏了什么。
VBA中的Log
函数是自然对数:ln(x).
公式中的LOG
函数是以10为底的对数:log10(x)。
如果您想在 VBA 中以 10 为底进行对数,则必须使用对数恒等式来转换底数:
Log(x)/Log(10)
你的情况
dOne = (Log(UnderlyingPrice / ExercisePrice) / Log(10) + (Interest - Dividend + (0.5 * Volatility ^ 2)) * Time) / (Volatility * (Sqr(Time)))