DayPeriodPreCalculatedDiscountCurve extends DiscountCurve { public void preCalculateDiscountFactors(final int numYears) { ArgumentChecker.isTrue(numYears >= 1, "numYears must be more than 1"); _preCalculatedDiscountFactors = new double[numYears * 366]; int numDays = 0; while (numDays < _preCalculatedDiscountFactors.length) { final double xValue = (numDays) / _daysPerYear; final double yValue = super.getDiscountFactor(xValue); _preCalculatedDiscountFactors[numDays] = yValue; numDays++; } } DayPeriodPreCalculatedDiscountCurve(final String name, final DoublesCurve discountFactorCurve);  DayPeriodPreCalculatedDiscountCurve(final String name, final DoublesCurve discountFactorCurve, final double daysPerYear); void preCalculateDiscountFactors(final int numYears); @Override double getDiscountFactor(final double t); boolean isPreCalculated(); boolean isPreCalculated(final int nDaysForward);  }
@Test(enabled = false) public void testWithSwap() { MULTICURVES.replaceCurve(EUR, EUR_DSC); final DayPeriodPreCalculatedDiscountCurve curve = new DayPeriodPreCalculatedDiscountCurve("test", new InterpolatedDoublesCurve(EUR_DSC_TIME, EUR_DSC_DISCOUNT_FACTOR, LINEAR_FLAT, true, EUR_DSC_NAME), 365.25); curve.preCalculateDiscountFactors(50); final MulticurveProviderDiscount MULTICURVES_WITH_PRECALCULATED_DISCOUNT = MULTICURVES.withDiscountFactor(EUR, curve); final MultipleCurrencyAmount pvCalcCpn3 = CPN_IBOR_3.accept(PVDC, MULTICURVES); final MultipleCurrencyAmount pvMethCpn3 = METHOD_CPN_IBOR.presentValue(CPN_IBOR_3, MULTICURVES); final MultipleCurrencyAmount pvCalcCpn6 = CPN_IBOR_6.accept(PVDC, MULTICURVES); final MultipleCurrencyAmount pvMethCpn6 = METHOD_CPN_IBOR.presentValue(CPN_IBOR_6, MULTICURVES); final MultipleCurrencyAmount pvCalcAnnIbor = ANNUITY_IBOR.accept(PVDC, MULTICURVES); final MultipleCurrencyAmount pvCalcAnnFixed = ANNUITY_FIXED.accept(PVDC, MULTICURVES); final MultipleCurrencyAmount pvCalcSwap = SWAP.accept(PVDC, MULTICURVES); final MultipleCurrencyAmount pvCalcCpn3_WITH_PRECALCULATED_DISCOUNT = CPN_IBOR_3.accept(PVDC, MULTICURVES_WITH_PRECALCULATED_DISCOUNT); final MultipleCurrencyAmount pvMethCpn3_WITH_PRECALCULATED_DISCOUNT = METHOD_CPN_IBOR.presentValue(CPN_IBOR_3, MULTICURVES_WITH_PRECALCULATED_DISCOUNT); final MultipleCurrencyAmount pvCalcCpn6_WITH_PRECALCULATED_DISCOUNT = CPN_IBOR_6.accept(PVDC, MULTICURVES_WITH_PRECALCULATED_DISCOUNT); final MultipleCurrencyAmount pvMethCpn6_WITH_PRECALCULATED_DISCOUNT = METHOD_CPN_IBOR.presentValue(CPN_IBOR_6, MULTICURVES_WITH_PRECALCULATED_DISCOUNT); final MultipleCurrencyAmount pvCalcAnnIbor_WITH_PRECALCULATED_DISCOUNT = ANNUITY_IBOR.accept(PVDC, MULTICURVES_WITH_PRECALCULATED_DISCOUNT); final MultipleCurrencyAmount pvCalcAnnFixed_WITH_PRECALCULATED_DISCOUNT = ANNUITY_FIXED.accept(PVDC, MULTICURVES_WITH_PRECALCULATED_DISCOUNT); final MultipleCurrencyAmount pvCalcSwap_WITH_PRECALCULATED_DISCOUNT = SWAP.accept(PVDC, MULTICURVES_WITH_PRECALCULATED_DISCOUNT); assertEquals("PresentValueDiscountingProviderCalculator: multiple Ibor index", pvCalcCpn3_WITH_PRECALCULATED_DISCOUNT.getAmount(EUR), pvCalcCpn3.getAmount(EUR), TOLERANCE_PV); assertEquals("PresentValueDiscountingProviderCalculator: multiple Ibor index", pvCalcCpn6_WITH_PRECALCULATED_DISCOUNT.getAmount(EUR), pvCalcCpn6.getAmount(EUR), TOLERANCE_PV); assertEquals("PresentValueDiscountingProviderCalculator: multiple Ibor index", pvCalcAnnIbor_WITH_PRECALCULATED_DISCOUNT.getAmount(EUR), pvCalcAnnIbor.getAmount(EUR), TOLERANCE_PV); assertEquals("PresentValueDiscountingProviderCalculator: multiple Ibor index", pvCalcAnnFixed.getAmount(EUR), pvCalcAnnFixed_WITH_PRECALCULATED_DISCOUNT.getAmount(EUR), TOLERANCE_PV); assertEquals("PresentValueDiscountingProviderCalculator: multiple Ibor index", pvMethCpn3.getAmount(EUR), pvMethCpn3_WITH_PRECALCULATED_DISCOUNT.getAmount(EUR), TOLERANCE_PV); assertEquals("PresentValueDiscountingProviderCalculator: multiple Ibor index", pvMethCpn6.getAmount(EUR), pvMethCpn6_WITH_PRECALCULATED_DISCOUNT.getAmount(EUR), TOLERANCE_PV); assertEquals("PresentValueDiscountingProviderCalculator: multiple Ibor index", pvCalcSwap_WITH_PRECALCULATED_DISCOUNT.getAmount(EUR), pvCalcSwap.getAmount(EUR), TOLERANCE_PV); }