当我以以下格式应用 Americanoptionimpliedvolatility 函数时:
impliedvol_test_v1$IV <- NA
impliedvol_test_v1$`risk free rate` <- as.numeric(impliedvol_test_v1$`risk
free rate`)
for(iRow in seq(1,nrow(impliedvol_test_v1),1)){
typeTMP <- impliedvol_test_v1$type[iRow]
valueTMP <- impliedvol_test_v1$value[iRow]
strikeTMP <- impliedvol_test_v1$strike[iRow]
underlyingTMP <- impliedvol_test_v1$underlying[iRow]
dividendyieldTMP <- impliedvol_test_v1$`Dividend yield`[iRow]
riskfreerateTMP <- impliedvol_test_v1$`risk free rate`[iRow]
maturityTMP <- impliedvol_test_v1$maturity[iRow]
volatilityTMP <- impliedvol_test_v1$volatility[iRow]
impliedvol_test_v1$IV[iRow] <- AmericanOptionImpliedVolatility(typeTMP,
valueTMP,strikeTMP, underlyingTMP, dividendyieldTMP, riskfreerateTMP,
maturityTMP, volatilityTMP)
}
我收到以下错误: 美国选项ImpliedVolatilityEngine 中的错误(类型,值,基础,:
../../../QuantLib-1.6.2/ql/math/solver1d.hpp:202:在函数`QuantLib::Real QuantLib::Solver1D::solve(const F&, QuantLib::Real, QuantLib: :Real, QuantLib::Real, QuantLib::Real) const [with F = QuantLib::{anonymous}::PriceError; Impl = QuantLib::Brent; QuantLib::Real = double]':根未括起来:f[1e-007,4] -> [2.230734e+000,2.306800e+001]
这很奇怪,因为我在手动插入 IV 值时收到它们。
数据集如下所示:
当我手动插入值时,我会收到每一行的值。
谢谢你的帮助!本