public Matrix VolMatrix(double scalingLevel) { if (scalingLevel == 1.0) { return(VolMatrix()); } Console.WriteLine("WARNING : DOES NOT WORK."); throw new NotImplementedException(); int rows = Strikes().Count(); int cols = _data.Count(); int r = 0; int c = 0; Matrix res = new Matrix(rows, cols, 0.0); foreach (DateTime dt in _data.Keys) { MarkitSmile smile = _data[dt]; foreach (double strike in smile.Strikes()) { res[c, r] = smile[strike] * scalingLevel; c++; } c = 0; r++; } return(res); }
// ACCESSING VOL MATRIX public Matrix VolMatrix() { int rows = Strikes().Count(); int cols = _data.Count(); int r = 0; int c = 0; Matrix res = new Matrix(rows, cols, 0.0); foreach (DateTime dt in _data.Keys) { MarkitSmile smile = _data[dt]; foreach (double strike in smile.Strikes()) { res[c, r] = smile[strike]; c++; } c = 0; r++; } return(res); }
public Matrix VolMatrix(double scalingLevel, double smileLevel) { if (scalingLevel == 1.0 && smileLevel == 1.0) { return(VolMatrix()); } Console.WriteLine("WARNING : DOES NOT WORK."); throw new NotImplementedException(); int rows = Strikes().Count(); int cols = _data.Count(); int r = 0; // tenor - maturity int c = 0; // strike - moneyness Matrix tmp = new Matrix(rows, cols, 0.0); //Matrix res = new Matrix(rows, cols, 0.0); foreach (DateTime dt in _data.Keys) { MarkitSmile smile = _data[dt]; double smileATM = smile.data[1.0]; foreach (double strike in smile.Strikes()) { double atm_vol = smile[strike] * scalingLevel; double smile_excess = (smile[strike] - smileATM); tmp[c, r] = scalingLevel * (smile[strike] + smileLevel * (smile[strike] - smileATM)); c++; } c = 0; r++; } return(tmp); }