### Question:
DiscountingFxNdfProductPricer { public MultiCurrencyAmount currencyExposure(ResolvedFxNdf ndf, RatesProvider provider) { if (provider.getValuationDate().isAfter(ndf.getPaymentDate())) { return MultiCurrencyAmount.empty(); } Currency ccySettle = ndf.getSettlementCurrency(); CurrencyAmount notionalSettle = ndf.getSettlementCurrencyNotional(); double dfSettle = provider.discountFactor(ccySettle, ndf.getPaymentDate()); Currency ccyOther = ndf.getNonDeliverableCurrency(); double agreedRate = ndf.getAgreedFxRate().fxRate(ccySettle, ccyOther); double dfOther = provider.discountFactor(ccyOther, ndf.getPaymentDate()); return MultiCurrencyAmount.of(notionalSettle.multipliedBy(dfSettle)) .plus(CurrencyAmount.of(ccyOther, -notionalSettle.getAmount() * agreedRate * dfOther)); } DiscountingFxNdfProductPricer(); CurrencyAmount presentValue(ResolvedFxNdf ndf, RatesProvider provider); PointSensitivities presentValueSensitivity(ResolvedFxNdf ndf, RatesProvider provider); MultiCurrencyAmount currencyExposure(ResolvedFxNdf ndf, RatesProvider provider); CurrencyAmount currentCash(ResolvedFxNdf ndf, RatesProvider provider); FxRate forwardFxRate(ResolvedFxNdf ndf, RatesProvider provider); static final DiscountingFxNdfProductPricer DEFAULT; }### Answer:
@Test public void test_currencyExposure_ended() { ResolvedFxNdf ndf = ResolvedFxNdf.builder() .settlementCurrencyNotional(CURRENCY_NOTIONAL) .agreedFxRate(FxRate.of(USD, KRW, FX_RATE)) .observation(FxIndexObservation.of(INDEX, LocalDate.of(2011, 5, 2), REF_DATA)) .paymentDate(LocalDate.of(2011, 5, 4)) .build(); MultiCurrencyAmount computed = PRICER.currencyExposure(ndf, PROVIDER); assertThat(computed.size()).isEqualTo(0); }
@Test public void test_currencyExposureVsForex() { MultiCurrencyAmount pvNDF = PRICER.currencyExposure(NDF, PROVIDER); MultiCurrencyAmount pvFX = PRICER_FX.currencyExposure(FOREX, PROVIDER); assertThat(pvNDF.getAmount(USD).getAmount()).isCloseTo(pvFX.getAmount(USD).getAmount(), offset(NOMINAL_USD * TOL)); assertThat(pvNDF.getAmount(KRW).getAmount()).isCloseTo(pvFX.getAmount(KRW).getAmount(), offset(NOMINAL_USD * TOL * FX_MATRIX.fxRate(USD, KRW))); }