MultiCapFloorPricer { public double[] impliedVols(double[] capPrices) { ArgumentChecker.notEmpty(capPrices, "null cap prices"); ArgumentChecker.isTrue(_nCaps == capPrices.length, "capPrices wrong length"); double[] res = new double[_nCaps]; for (int i = 0; i < _nCaps; i++) { res[i] = BlackFormulaRepository.impliedVolatility(_capToOptionsMap[i], capPrices[i]); } return res; } MultiCapFloorPricer(List<CapFloor> caps,  MulticurveProviderInterface curves); double[] getCapletVols(VolatilitySurface volSurface); double[] price(VolatilitySurface volSurface); double[] priceFromCapletVols(double[] capletVols); double[] price(double[] capVolatilities); double[] impliedVols(double[] capPrices); double[] impliedVols(VolatilitySurface volSurface); double[] vega(double[] capVolatilities); DoubleMatrix2D vegaFromCapletVols(double[] capletVols); DoubleMatrix2D capVolVega(double[] capletVols); double[] getCapletExpiries(); double[] getStrikes(); double[] getIntrinsicCapValues(); double[] getCapStartTimes(); double[] getCapEndTimes(); DoublesPair[] getExpiryStrikeArray(); int getNumCaps(); int getNumCaplets(); double[] getCapletForwardRates();  }
@Test public void volSurfaceImpVolTest() { MulticurveProviderDiscount yieldCurve = getYieldCurves(); List<CapFloor> caps = getAllCaps(); int n = caps.size(); MultiCapFloorPricer multiPricer = new MultiCapFloorPricer(caps, yieldCurve); double[] vols = multiPricer.impliedVols(s_VolSurface); assertEquals("wrong number of vols", n, vols.length); for (int j = 0; j < n; j++) { CapFloorPricer pricer = new CapFloorPricer(caps.get(j), yieldCurve); double v = pricer.impliedVol(s_VolSurface); assertEquals(v, vols[j], 1e-9); } }
@SuppressWarnings("unused") @Test public void volTimeTest() { int warmup = 1; int benchmarkCycles = 0; MulticurveProviderDiscount yieldCurve = getYieldCurves(); List<CapFloor> caps = getAllCaps(); int nCaps = caps.size(); MultiCapFloorPricer multiPricer = new MultiCapFloorPricer(caps, yieldCurve); CapFloorPricer[] pricers = new CapFloorPricer[nCaps]; for (int i = 0; i < nCaps; i++) { pricers[i] = new CapFloorPricer(caps.get(i), yieldCurve); } for (int count = 0; count < warmup; count++) { double[] vols = multiPricer.impliedVols(s_VolSurface); } if (benchmarkCycles > 0) { OperationTimer timer = new OperationTimer(LOGGER, "processing {} cycles on timeTest - multiPricer", benchmarkCycles); for (int count = 0; count < benchmarkCycles; count++) { double[] vols = multiPricer.impliedVols(s_VolSurface); } timer.finished(); } for (int count = 0; count < warmup; count++) { for (int i = 0; i < nCaps; i++) { double v = pricers[i].impliedVol(s_VolSurface); } } if (benchmarkCycles > 0) { OperationTimer timer2 = new OperationTimer(LOGGER, "processing {} cycles on timeTest - single Pricer", benchmarkCycles); for (int count = 0; count < benchmarkCycles; count++) { for (int i = 0; i < nCaps; i++) { double v = pricers[i].impliedVol(s_VolSurface); } } timer2.finished(); } }