DepositCounterpartDiscountingMethod { public MultipleCurrencyAmount presentValue(final DepositCounterpart deposit, final IssuerProviderInterface multicurves) { ArgumentChecker.notNull(deposit, "Deposit"); ArgumentChecker.notNull(multicurves, "Multicurves"); final double dfStart = multicurves.getDiscountFactor(deposit.getCounterparty(), deposit.getStartTime()); final double dfEnd = multicurves.getDiscountFactor(deposit.getCounterparty(), deposit.getEndTime()); final double pv = (deposit.getNotional() + deposit.getInterestAmount()) * dfEnd - deposit.getInitialAmount() * dfStart; return MultipleCurrencyAmount.of(deposit.getCurrency(), pv); } private  DepositCounterpartDiscountingMethod(); static DepositCounterpartDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final DepositCounterpart deposit, final IssuerProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final DepositCounterpart deposit, final IssuerProviderInterface multicurves); double parSpread(final DepositCounterpart deposit, final IssuerProviderInterface multicurves); MulticurveSensitivity parSpreadCurveSensitivity(final DepositCounterpart deposit, final IssuerProviderInterface multicurves);  }
@Test public void presentValueTrade() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 12); final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER_ISSUER); final double dfEnd = PROVIDER_ISSUER.getDiscountFactor(ISSUER, deposit.getEndTime()); final double dfStart = PROVIDER_ISSUER.getDiscountFactor(ISSUER, deposit.getStartTime()); final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd - NOTIONAL * dfStart; assertEquals("DepositCounterpartDiscountingMethod: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueMethodVsCalculator() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 12); final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvMethod = METHOD_DEPOSIT.presentValue(deposit, PROVIDER_ISSUER); final MultipleCurrencyAmount pvCalculator = deposit.accept(PVC, PROVIDER_ISSUER); assertEquals("DepositCounterpartDiscountingMethod: present value", pvMethod, pvCalculator); }
@Test public void presentValueBetweenTradeAndSettle() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 13); final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER_ISSUER); final double dfEnd = PROVIDER_ISSUER.getDiscountFactor(ISSUER, deposit.getEndTime()); final double dfStart = PROVIDER_ISSUER.getDiscountFactor(ISSUER, deposit.getStartTime()); final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd - NOTIONAL * dfStart; assertEquals("DepositCounterpartDiscountingMethod: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueSettle() { final ZonedDateTime referenceDate = SPOT_DATE; final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER_ISSUER); final double dfEnd = PROVIDER_ISSUER.getDiscountFactor(ISSUER, deposit.getEndTime()); final double dfStart = PROVIDER_ISSUER.getDiscountFactor(ISSUER, deposit.getStartTime()); final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd - NOTIONAL * dfStart; assertEquals("DepositCounterpartDiscountingMethod: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueBetweenSettleMaturity() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 20); final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER_ISSUER); final double dfEnd = PROVIDER_ISSUER.getDiscountFactor(ISSUER, deposit.getEndTime()); final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd; assertEquals("DepositCounterpartDiscountingMethod: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValueMaturity() { final ZonedDateTime referenceDate = END_DATE; final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate); final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER_ISSUER); final double pvExpected = NOTIONAL + deposit.getInterestAmount(); assertEquals("DepositCounterpartDiscountingMethod: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }