我需要使用 R 的 QuantLib 包计算金融期权的隐含波动率。我在使用函数“EuropeanOptionImpliedVolatility”的迭代时遇到问题,因为它的输出是一个对象(称为 ImpliedVolatility)。
largo = nrow(call26) #number of rows in my data set
impl_vol= vector("list",largo)
for(i in largo){
impl_vol[[i]] = EuropeanOptionImpliedVolatility(type="call", value=valor_opcion[i],
underlying=st[i], strike=strike[i], dividendYield=dividendo[i],
riskFreeRate=rf[i], maturity=maturity[i], volatility=0.4)
}
结果是:
list(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, structure(list(impliedVol = 0.173643438965225,
parameters = structure(list(type = "call", value = 52.95,
underlying = 1497.66, strike = 1680, dividendYield = 0.01,
riskFreeRate = 0.04, maturity = 0.983561644, volatility = 0.4), .Names = c("type",
"value", "underlying", "strike", "dividendYield", "riskFreeRate",
"maturity", "volatility"))), .Names = c("impliedVol",
"parameters"), class = c("EuropeanOptionImpliedVolatility",
"ImpliedVolatility")))
而且我需要隐含的波动率......如果我计算一个单一的金融期权,我可以使用它
valor$impliedVol
我能做些什么?谢谢!