@Override public SabrParameters withPerturbation(ParameterPerturbation perturbation) { return new SabrParameters( paramCombiner.underlyingWithPerturbation(0, Curve.class, perturbation), paramCombiner.underlyingWithPerturbation(1, Curve.class, perturbation), paramCombiner.underlyingWithPerturbation(2, Curve.class, perturbation), paramCombiner.underlyingWithPerturbation(3, Curve.class, perturbation), paramCombiner.underlyingWithPerturbation(4, Curve.class, perturbation), sabrVolatilityFormula); }
@Override public SabrInterestRateParameters withPerturbation(ParameterPerturbation perturbation) { return new SabrInterestRateParameters( paramCombiner.underlyingWithPerturbation(0, Surface.class, perturbation), paramCombiner.underlyingWithPerturbation(1, Surface.class, perturbation), paramCombiner.underlyingWithPerturbation(2, Surface.class, perturbation), paramCombiner.underlyingWithPerturbation(3, Surface.class, perturbation), paramCombiner.underlyingWithPerturbation(4, Surface.class, perturbation), sabrVolatilityFormula); }
@Override public DiscountFxForwardRates withPerturbation(ParameterPerturbation perturbation) { return new DiscountFxForwardRates( currencyPair, fxRateProvider, paramCombiner.underlyingWithPerturbation(0, DiscountFactors.class, perturbation), paramCombiner.underlyingWithPerturbation(1, DiscountFactors.class, perturbation)); }
/** * Applies a perturbation to each underlying. * <p> * The updated list of underlying instances is returned. * * @param <R> the type of the underlying * @param underlyingType the type of the parameterized data at the specified index * @param perturbation the perturbation to apply * @return a parameterized data instance based on this with the specified parameter altered * @throws IndexOutOfBoundsException if the index is invalid */ public <R extends ParameterizedData> List<R> withPerturbation( Class<R> underlyingType, ParameterPerturbation perturbation) { ImmutableList.Builder<R> builder = ImmutableList.builder(); for (int i = 0; i < underlyings.length; i++) { builder.add(underlyingWithPerturbation(i, underlyingType, perturbation)); } return builder.build(); }
public void test_underlyingWithPerturbation() { ParameterPerturbation perturbation = (i, v, m) -> v + i + 0.5d; ParameterizedDataCombiner test = ParameterizedDataCombiner.of(DATA1, DATA2, DATA3); assertEquals(test.underlyingWithPerturbation(0, TestingParameterizedData2.class, perturbation).getParameter(0), 1.5d); assertEquals(test.underlyingWithPerturbation(0, TestingParameterizedData2.class, perturbation).getParameter(1), 3.5d); assertEquals(test.underlyingWithPerturbation(1, TestingParameterizedData.class, perturbation).getParameter(0), 5.5d); assertEquals(test.underlyingWithPerturbation(2, TestingParameterizedData2.class, perturbation).getParameter(0), 7.5d); assertEquals(test.underlyingWithPerturbation(2, TestingParameterizedData2.class, perturbation).getParameter(1), 9.5d); }