Topics

VolCube in RQuantLib


Suhas Ghorpadkar
 

I have posted the same question on Quant StatckExchange (https://quant.stackexchange.com/questions/58479/volcube-in-rquantlib) before I discovered this group. 


Working with RQuantLib for the first time and trying to understand how the Swaption Vol Cube is being built. I am looking at volCF2CubeK.R file and my general understanding is that we are collecting ATM lognormal volatilities first in "atmMat" which is fine. Then comes the "smirk" part I don't understand. 

Why not just pass the entire set of vol spreads (with ATM being zero) for a particular tenor and expiry to QuantLib's SwaptionVolCube1 ? 

It looks like there is some interpolation involved with smirk that I don't understand why it's needed.


Also, what does CF2 and K stand for in the name of this file? Why is the file not simply called VolCube.R ?


atmMat = matrix(data = NA, nrow = length(expLvl), ncol = length(tenorLvl), 
dimnames = list(expLvl, tenorLvl))
for (i in 1:length(expLvl)) {
  for (j in 1:length(tenorLvl)) {
    atmMat[i, j] = tbl[tbl$Expiry == expLvl[i] & tbl$Tenor == 
    tenorLvl[j] & tbl$Spread == 0, ]$LogNormalVol
  }
}
smirk = matrix(ncol = length(strikes), nrow = length(expLvl) * 
  length(tenorLvl))
k = 0
for (i in 1:length(expLvl)) {
  for (j in 1:length(tenorLvl)) {
    k = k + 1
    for (n in 1:length(strikes)) {
      smirk[k, n] = tbl[tbl$Expiry == expLvl[i] & 
        tbl$Tenor == tenorLvl[j] & tbl$Spread == strikes[n], 
        ]$LogNormalVol - tbl[tbl$Expiry == expLvl[i] & 
        tbl$Tenor == tenorLvl[j] & tbl$Spread == 0, 
        ]$LogNormalVol
    }
  }
}
smirk <- na.spline(smirk, method = "natural")
On the C++ side, I see this call and it is the "qSwSmile" parameter from R that I am struggling with.


Handle<SwpVolStr>
        res(QuantLib::ext::shared_ptr<SwpVolStr>(new SwaptionVolCube1(swaptionVolAtm, 
        optionTenorsSmile,                                                               
        swapTenorsSmile, strikeSpreads, qSwSmile,
        swapIndex, shortSwapIndex, true,
        parameterGuess, parameterFixed, true, ec,
        .050)));
Thanks for your help, much appreciated.
Suhas