MultiCapFloorPricerGrid extends MultiCapFloorPricer { @Override public double[] priceFromCapletVols(double[] capletVolGridValues) { ArgumentChecker.notEmpty(capletVolGridValues, "null caplet volatilities"); ArgumentChecker.isTrue(_gridSize == capletVolGridValues.length, "Expect caplet vols on a (flatened) grid of {} strikes by {} expiries, so {} values. Given {} capletVols", getStrikes().length, getCapletExpiries().length, _gridSize, capletVolGridValues.length); int n = getNumCaplets(); double[] capletPrices = new double[n]; for (int i = 0; i < n; i++) { capletPrices[i] = BlackFormulaRepository.price(getOption(i), capletVolGridValues[_optionsToGridMap[i]]); } return priceFromCapletPrices(capletPrices); } MultiCapFloorPricerGrid(List<CapFloor> caps, MulticurveProviderInterface curves); @Override double[] priceFromCapletVols(double[] capletVolGridValues); @Override DoubleMatrix2D vegaFromCapletVols(double[] capletVolGridValues); int getGridSize(); @Override DoublesPair[] getExpiryStrikeArray();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void wrongNumCapletVolsPriceTest() { List<CapFloor> caps = getATMCaps(); MultiCapFloorPricerGrid pricer = new MultiCapFloorPricerGrid(caps, getYieldCurves()); double[] capletVols = new double[pricer.getNumCaplets()]; Arrays.fill(capletVols, 0.35); pricer.priceFromCapletVols(capletVols); }