CashDiscountingMethod { public MultipleCurrencyAmount presentValue(final Cash deposit, final MulticurveProviderInterface curves) { ArgumentChecker.notNull(deposit, "Deposit"); ArgumentChecker.notNull(curves, "Multicurves"); final double dfStart = curves.getDiscountFactor(deposit.getCurrency(), deposit.getStartTime()); final double dfEnd = curves.getDiscountFactor(deposit.getCurrency(), deposit.getEndTime()); final double pv = (deposit.getNotional() + deposit.getInterestAmount()) * dfEnd - deposit.getInitialAmount() * dfStart; return MultipleCurrencyAmount.of(deposit.getCurrency(), pv); } 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 presentValueTrade() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 12); final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER); final double dfEnd = PROVIDER.getDiscountFactor(EUR, deposit.getEndTime()); final double dfStart = PROVIDER.getDiscountFactor(EUR, deposit.getStartTime()); final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd - NOTIONAL * dfStart; assertEquals("DepositDefinition: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueBetweenTradeAndSettle() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 13); final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER); final double dfEnd = PROVIDER.getDiscountFactor(EUR, deposit.getEndTime()); final double dfStart = PROVIDER.getDiscountFactor(EUR, deposit.getStartTime()); final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd - NOTIONAL * dfStart; assertEquals("DepositDefinition: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueSettle() { final ZonedDateTime referenceDate = SPOT_DATE; final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER); final double dfEnd = PROVIDER.getDiscountFactor(EUR, deposit.getEndTime()); final double dfStart = PROVIDER.getDiscountFactor(EUR, deposit.getStartTime()); final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd - NOTIONAL * dfStart; assertEquals("DepositDefinition: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueBetweenSettleMaturity() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 20); final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER); final double dfEnd = PROVIDER.getDiscountFactor(EUR, deposit.getEndTime()); final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd; assertEquals("DepositDefinition: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueMaturity() { final ZonedDateTime referenceDate = END_DATE; final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER); final double pvExpected = NOTIONAL + deposit.getInterestAmount(); assertEquals("DepositDefinition: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }