### Question:
DiscountingFxNdfProductPricer { public PointSensitivities presentValueSensitivity(ResolvedFxNdf ndf, RatesProvider provider) { if (provider.getValuationDate().isAfter(ndf.getPaymentDate())) { return PointSensitivities.empty(); } Currency ccySettle = ndf.getSettlementCurrency(); Currency ccyOther = ndf.getNonDeliverableCurrency(); double notionalSettle = ndf.getSettlementNotional(); double agreedRate = ndf.getAgreedFxRate().fxRate(ccySettle, ccyOther); double forwardRate = provider.fxIndexRates(ndf.getIndex()).rate(ndf.getObservation(), ccySettle); double dfSettle = provider.discountFactor(ccySettle, ndf.getPaymentDate()); double ratio = agreedRate / forwardRate; double dscBar = (1d - ratio) * notionalSettle; PointSensitivityBuilder sensiDsc = provider.discountFactors(ccySettle).zeroRatePointSensitivity(ndf.getPaymentDate()).multipliedBy(dscBar); double forwardRateBar = dfSettle * notionalSettle * ratio / forwardRate; PointSensitivityBuilder sensiFx = provider.fxIndexRates(ndf.getIndex()) .ratePointSensitivity(ndf.getObservation(), ccySettle).withCurrency(ccySettle).multipliedBy(forwardRateBar); return sensiDsc.combinedWith(sensiFx).build(); } 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_presentValueSensitivity_ended() { ResolvedFxNdf ndf = ResolvedFxNdf.builder() .settlementCurrencyNotional(CURRENCY_NOTIONAL) .agreedFxRate(FxRate.of(USD, KRW, FX_RATE)) .observation(FxIndexObservation.of(INDEX, FIXING_DATE_PAST, REF_DATA)) .paymentDate(PAYMENT_DATE_PAST) .build(); PointSensitivities computed = PRICER.presentValueSensitivity(ndf, PROVIDER); assertThat(computed).isEqualTo(PointSensitivities.empty()); }
@Test public void test_presentValueCurveSensitivityVsForex() { PointSensitivities pvcsNDF = PRICER.presentValueSensitivity(NDF, PROVIDER).normalized(); CurrencyParameterSensitivities sensiNDF = PROVIDER.parameterSensitivity(pvcsNDF); PointSensitivities pvcsFX = PRICER_FX.presentValueSensitivity(FOREX, PROVIDER).normalized(); CurrencyParameterSensitivities sensiFX = PROVIDER.parameterSensitivity(pvcsFX); assertThat(sensiNDF.equalWithTolerance(sensiFX.convertedTo(USD, PROVIDER), NOMINAL_USD * TOL)).isTrue(); }