### Question:
DiscountingIborFixingDepositProductPricer { public CurrencyAmount presentValue(ResolvedIborFixingDeposit deposit, RatesProvider provider) { Currency currency = deposit.getCurrency(); if (provider.getValuationDate().isAfter(deposit.getEndDate())) { return CurrencyAmount.of(currency, 0.0d); } double forwardRate = forwardRate(deposit, provider); double discountFactor = provider.discountFactor(currency, deposit.getEndDate()); double fv = deposit.getNotional() * deposit.getYearFraction() * (deposit.getFixedRate() - forwardRate); double pv = discountFactor * fv; return CurrencyAmount.of(currency, pv); } DiscountingIborFixingDepositProductPricer(); CurrencyAmount presentValue(ResolvedIborFixingDeposit deposit, RatesProvider provider); PointSensitivities presentValueSensitivity(ResolvedIborFixingDeposit deposit, RatesProvider provider); double parRate(ResolvedIborFixingDeposit deposit, RatesProvider provider); PointSensitivities parRateSensitivity(ResolvedIborFixingDeposit deposit, RatesProvider provider); double parSpread(ResolvedIborFixingDeposit deposit, RatesProvider provider); PointSensitivities parSpreadSensitivity(ResolvedIborFixingDeposit deposit, RatesProvider provider); static final DiscountingIborFixingDepositProductPricer DEFAULT; }### Answer:
@Test public void test_presentValue_noFixing() { double discountFactor = IMM_PROV_NOFIX.discountFactor(EUR, END_DATE); double forwardRate = IMM_PROV_NOFIX.iborIndexRates(EUR_EURIBOR_6M).rate(RDEPOSIT.getFloatingRate().getObservation()); CurrencyAmount computed = PRICER.presentValue(RDEPOSIT, IMM_PROV_NOFIX); double expected = NOTIONAL * discountFactor * (RATE - forwardRate) * RDEPOSIT.getYearFraction(); assertThat(computed.getCurrency()).isEqualTo(EUR); assertThat(computed.getAmount()).isCloseTo(expected, offset(TOLERANCE_PV)); }
@Test public void test_presentValue_fixing() { CurrencyAmount computedNoFix = PRICER.presentValue(RDEPOSIT, IMM_PROV_NOFIX); CurrencyAmount computedFix = PRICER.presentValue(RDEPOSIT, IMM_PROV_FIX); assertThat(computedFix.getCurrency()).isEqualTo(EUR); assertThat(computedFix.getAmount()).isCloseTo(computedNoFix.getAmount(), offset(TOLERANCE_PV)); }