如何在 Julia 中使用 Black-Scholes 模型计算期权的公平价格?
How to calculate the fair price of an option using Black-Scholes model in Julia?
在 python 中,期权价格可以使用以下公式计算:
from math import *
def bs_call(S,X,T,r,sigma):
d1 = (log(S/X)+(r+sigma*sigma/2.)*T)/(sigma*sqrt(T))
d2 = d1-sigma*sqrt(T)
return S*CND(d1)-X*exp(-r*T)*CND(d2)
请指导我这样做(如果有的话,最好使用内置函数)julia。
您可以使用 BS.jl
包 - 自述文件显示了如何使用它。请注意,它尚未注册,因此您必须 ]add https://github.com/felipenoris/BS.jl
才能添加它。
在 python 中,期权价格可以使用以下公式计算:
from math import *
def bs_call(S,X,T,r,sigma):
d1 = (log(S/X)+(r+sigma*sigma/2.)*T)/(sigma*sqrt(T))
d2 = d1-sigma*sqrt(T)
return S*CND(d1)-X*exp(-r*T)*CND(d2)
请指导我这样做(如果有的话,最好使用内置函数)julia。
您可以使用 BS.jl
包 - 自述文件显示了如何使用它。请注意,它尚未注册,因此您必须 ]add https://github.com/felipenoris/BS.jl
才能添加它。