CashDiscountingMethod { public double parSpread(final Cash deposit, final MulticurveProviderInterface curves) { ArgumentChecker.notNull(deposit, "Deposit"); ArgumentChecker.notNull(curves, "Multicurves"); ArgumentChecker.isTrue(deposit.getNotional() != 0.0, "Notional is 0"); final double dfStart = curves.getDiscountFactor(deposit.getCurrency(), deposit.getStartTime()); final double dfEnd = curves.getDiscountFactor(deposit.getCurrency(), deposit.getEndTime()); return (deposit.getInitialAmount() * dfStart - (deposit.getNotional() + deposit.getInterestAmount()) * dfEnd) / (deposit.getNotional() * deposit.getAccrualFactor() * dfEnd); } private  CashDiscountingMethod(); static CashDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final Cash deposit, final MulticurveProviderInterface curves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final Cash deposit, final MulticurveProviderInterface curves); double parRate(final Cash deposit, final MulticurveProviderInterface curves); double parSpread(final Cash deposit, final MulticurveProviderInterface curves); MulticurveSensitivity parSpreadCurveSensitivity(final Cash deposit, final MulticurveProviderInterface curves);  }
@Test public void parSpreadMethodVsCalculator() { final ZonedDateTime referenceDate = TRADE_DATE; final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate); final double parSpreadMethod = METHOD_DEPOSIT.parSpread(deposit, PROVIDER); final double parSpreadCalculator = deposit.accept(PSMQDC, PROVIDER); assertEquals("DepositDefinition: present value", parSpreadMethod, parSpreadCalculator, TOLERANCE_RATE); }