public virtual void test_currencyExposure_from_pt_sensitivity() { MultiCurrencyAmount ceDirect = PRICER.currencyExposure(NDF, PROVIDER); PointSensitivities pts = PRICER.presentValueSensitivity(NDF, PROVIDER); MultiCurrencyAmount cePts = PROVIDER.currencyExposure(pts); CurrencyAmount cePv = PRICER.presentValue(NDF, PROVIDER); MultiCurrencyAmount ceExpected = cePts.plus(cePv); assertEquals(ceDirect.getAmount(USD).Amount, ceExpected.getAmount(USD).Amount, NOMINAL_USD * TOL); assertEquals(ceDirect.getAmount(KRW).Amount, ceExpected.getAmount(KRW).Amount, NOMINAL_USD * TOL * FX_MATRIX.fxRate(USD, KRW)); }
//------------------------------------------------------------------------- public virtual void test_currencyExposure() { MultiCurrencyAmount computedPricer = PRICER.currencyExposure(CALL_OTM, RATES_PROVIDER, VOLS); CurrencyAmount pv = PRICER.presentValue(CALL_OTM, RATES_PROVIDER, VOLS); PointSensitivities point = PRICER.presentValueSensitivityRatesStickyStrike(CALL_OTM, RATES_PROVIDER, VOLS); MultiCurrencyAmount computedPoint = RATES_PROVIDER.currencyExposure(point).plus(pv); assertEquals(computedPricer.getAmount(EUR).Amount, computedPoint.getAmount(EUR).Amount, NOTIONAL * TOL); assertEquals(computedPricer.getAmount(USD).Amount, computedPoint.getAmount(USD).Amount, NOTIONAL * TOL); }
public virtual void test_currencyExposure() { MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(OPTION_TRADE, RATES_PROVIDER, VOLS); PointSensitivities point = PRICER_TRADE.presentValueSensitivityRatesStickyStrike(OPTION_TRADE, RATES_PROVIDER, VOLS); MultiCurrencyAmount pv = PRICER_TRADE.presentValue(OPTION_TRADE, RATES_PROVIDER, VOLS); MultiCurrencyAmount ceExpected = RATES_PROVIDER.currencyExposure(point).plus(pv); assertEquals(ceComputed.size(), 2); assertEquals(ceComputed.getAmount(EUR).Amount, ceExpected.getAmount(EUR).Amount, TOL * NOTIONAL); assertEquals(ceComputed.getAmount(USD).Amount, ceExpected.getAmount(USD).Amount, TOL * NOTIONAL); }
//------------------------------------------------------------------------- public virtual void currency_exposure_GBP() { LocalDate startDate = LocalDate.of(2016, 8, 2); LocalDate fixingDate = LocalDate.of(2016, 11, 2); LocalDate endDate = LocalDate.of(2016, 11, 4); double yearFraction = 0.25; double rate = 0.10; RateAccrualPeriod accrual = RateAccrualPeriod.builder().startDate(startDate).endDate(endDate).yearFraction(yearFraction).rateComputation(FixedRateComputation.of(rate)).build(); double notional = 1000000; RatePaymentPeriod fixedFx = RatePaymentPeriod.builder().accrualPeriods(accrual).fxReset(FxReset.of(FxIndexObservation.of(FxIndices.GBP_USD_WM, fixingDate, REF_DATA), GBP)).notional(notional).paymentDate(endDate).dayCount(DayCounts.ONE_ONE).currency(USD).build(); // 1_000_000 GBP paid in USD at maturity PointSensitivityBuilder pts = PERIOD_PRICER.presentValueSensitivity(fixedFx, PROVIDER); MultiCurrencyAmount ceComputed = PERIOD_PRICER.currencyExposure(fixedFx, PROVIDER); double dfGbp = PROVIDER.discountFactor(GBP, endDate); double ceGbpExpected = notional * yearFraction * rate * dfGbp; assertEquals(ceComputed.getAmount(GBP).Amount, ceGbpExpected, 1.0E-6); MultiCurrencyAmount ceWithoutPvComputed = PROVIDER.currencyExposure(pts.build().convertedTo(GBP, PROVIDER)); CurrencyAmount pvComputed = CurrencyAmount.of(USD, PERIOD_PRICER.presentValue(fixedFx, PROVIDER)); MultiCurrencyAmount ceComputed2 = ceWithoutPvComputed.plus(pvComputed); assertEquals(ceComputed2.getAmount(GBP).Amount, ceGbpExpected, TOLERANCE); assertEquals(ceComputed2.getAmount(USD).Amount, 0.0, TOLERANCE); }