R の QuantLib パッケージを使用して、金融オプションのインプライド ボラティリティを計算する必要があります。出力がオブジェクト (ImpliedVolatility と呼ばれる) であるため、関数 "EuropeanOptionImpliedVolatility" の反復を使用するのに問題があります。
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
私に何ができる?ありがとう!