FMStable::ImpliedVol 中有错误吗?
Is there a bug in FMStable::ImpliedVol?
我是 R 的初学者,一直在使用“FMStable”包中的 ImpliedVol 函数来计算欧式看涨期权的隐含波动率。
一直困扰我的是这个函数似乎给出了错误的输出。我做了一个实验,看看是否是这样,我是这样做的:
#using certain values to do the test
> ImpliedVol(spot=8,strike=10,expiry = 1,price = 2,intRate = 0.05,tol=1.e-9)
[1] 0.8643101
#use the B-S formula to obtain call option prices
> test=function(x){
+ s=8
+ X=10
+ T=1
+ r=0.05
+ d1=(log(s/X)+(r+x^2/2)*T)/(x*T^(1/2))
+ d2=d1-x*T^(1/2)
+ c=s*pnorm(d1)-X*exp(-r*T)*pnorm(d2)
+ return(c)
+ }
#testing list containing possible volatilities
> sig=seq(from=0.5,to=1,by=0.00001)
#test results
> calltest=test(sig)
> plot(sig,calltest)
> abline(h=2)
> abline(z=0.8643101)#the result from the ImpliedVol function
> abline(v=0.7919,col='blue')
如您所见,真正的隐含波动率应该约为 0.7919,而不是 0.8643101。
看了ImpliedVol函数包裹的代码,发现作者在f(ImpVol)=0时使用uniroot函数求根。我看不出这里有什么问题,希望有人能帮助我。
(这个问题是因为多次尝试失败,联系不上R包的作者"FMStable")
我不从事金融工作,但我看到 ImpliedVol
函数有一个默认值为 0 的 carryCost
参数。设置 carryCost
等于 intRate
给你所谓的 "true Implied Volatility."
ImpliedVol(spot=8,strike=10,expiry = 1,price = 2,intRate = 0.05, carryCost = 0.05,
tol=1.e-9)
# [1] 0.7918341
参见例如这里的公式:http://help.cqg.com/cqgic/default.htm#!Documents/blackscholesgeneralizedextendedmodel.htm
我是 R 的初学者,一直在使用“FMStable”包中的 ImpliedVol 函数来计算欧式看涨期权的隐含波动率。 一直困扰我的是这个函数似乎给出了错误的输出。我做了一个实验,看看是否是这样,我是这样做的:
#using certain values to do the test
> ImpliedVol(spot=8,strike=10,expiry = 1,price = 2,intRate = 0.05,tol=1.e-9)
[1] 0.8643101
#use the B-S formula to obtain call option prices
> test=function(x){
+ s=8
+ X=10
+ T=1
+ r=0.05
+ d1=(log(s/X)+(r+x^2/2)*T)/(x*T^(1/2))
+ d2=d1-x*T^(1/2)
+ c=s*pnorm(d1)-X*exp(-r*T)*pnorm(d2)
+ return(c)
+ }
#testing list containing possible volatilities
> sig=seq(from=0.5,to=1,by=0.00001)
#test results
> calltest=test(sig)
> plot(sig,calltest)
> abline(h=2)
> abline(z=0.8643101)#the result from the ImpliedVol function
> abline(v=0.7919,col='blue')
如您所见,真正的隐含波动率应该约为 0.7919,而不是 0.8643101。
看了ImpliedVol函数包裹的代码,发现作者在f(ImpVol)=0时使用uniroot函数求根。我看不出这里有什么问题,希望有人能帮助我。
(这个问题是因为多次尝试失败,联系不上R包的作者"FMStable")
我不从事金融工作,但我看到 ImpliedVol
函数有一个默认值为 0 的 carryCost
参数。设置 carryCost
等于 intRate
给你所谓的 "true Implied Volatility."
ImpliedVol(spot=8,strike=10,expiry = 1,price = 2,intRate = 0.05, carryCost = 0.05,
tol=1.e-9)
# [1] 0.7918341
参见例如这里的公式:http://help.cqg.com/cqgic/default.htm#!Documents/blackscholesgeneralizedextendedmodel.htm