public 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).getAmount(), computedPoint.getAmount(EUR).getAmount(), NOTIONAL * TOL); assertEquals(computedPricer.getAmount(USD).getAmount(), computedPoint.getAmount(USD).getAmount(), NOTIONAL * TOL); }
public void test_currencyExposureFromCleanPrice() { MultiCurrencyAmount computed = PRICER.currencyExposureFromCleanPrice( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE); PointSensitivities point = PRICER.presentValueSensitivityFromCleanPrice( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE); MultiCurrencyAmount expected = RATES_PROVIDER.currencyExposure(point).plus( PRICER.presentValueFromCleanPrice(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE)); assertEquals(computed.getAmounts().size(), 1); assertEquals(computed.getAmount(USD).getAmount(), expected.getAmount(USD).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_currencyExposure_afterMaturity() { MultiCurrencyAmount computedRec = SWAPTION_PRICER.currencyExposure( SWAPTION_REC_LONG, RATE_PROVIDER_AFTER_MATURITY, VOLS_AFTER_MATURITY); MultiCurrencyAmount computedPay = SWAPTION_PRICER.currencyExposure( SWAPTION_PAY_SHORT, RATE_PROVIDER_AFTER_MATURITY, VOLS_AFTER_MATURITY); assertEquals(computedRec.size(), 1); assertEquals(computedRec.getAmount(USD).getAmount(), 0d, NOTIONAL * TOL); assertEquals(computedPay.size(), 1); assertEquals(computedPay.getAmount(USD).getAmount(), 0d, NOTIONAL * TOL); }
public void test_currencyExposureFromCleanPriceWithZSpread() { MultiCurrencyAmount computed = PRICER.currencyExposureFromCleanPriceWithZSpread( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); PointSensitivities point = PRICER.presentValueSensitivityFromCleanPriceWithZSpread( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); MultiCurrencyAmount expected = RATES_PROVIDER.currencyExposure(point).plus( PRICER.presentValueFromCleanPriceWithZSpread(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR)); assertEquals(computed.getAmounts().size(), 1); assertEquals(computed.getAmount(USD).getAmount(), expected.getAmount(USD).getAmount(), NOTIONAL * QUANTITY * TOL); }
public 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).getAmount(), ceExpected.getAmount(EUR).getAmount(), TOL * NOTIONAL); assertEquals(ceComputed.getAmount(USD).getAmount(), ceExpected.getAmount(USD).getAmount(), TOL * NOTIONAL); }
public void test_currencyExposureWithZSpread() { MultiCurrencyAmount computed = PRICER.currencyExposureWithZSpread( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); PointSensitivities point = PRICER.presentValueSensitivityWithZSpread( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); MultiCurrencyAmount expected = RATES_PROVIDER.currencyExposure(point).plus(PRICER.presentValueWithZSpread( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR)); assertEquals(computed.getAmounts().size(), 1); assertEquals(computed.getAmount(USD).getAmount(), expected.getAmount(USD).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValueVsForex() { CurrencyAmount pvNDF = PRICER.presentValue(NDF, PROVIDER); MultiCurrencyAmount pvFX = PRICER_FX.presentValue(FOREX, PROVIDER); assertEquals( pvNDF.getAmount(), pvFX.getAmount(USD).getAmount() + pvFX.getAmount(KRW).getAmount() * FX_MATRIX.fxRate(KRW, USD), NOMINAL_USD * TOL); }
public void test_currencyExposure() { PointSensitivities point = PRICER.presentValueSensitivityRates(FUTURE_TRADE, RATE_PROVIDER, HW_PROVIDER); MultiCurrencyAmount expected = RATE_PROVIDER.currencyExposure(point) .plus(PRICER.presentValue(FUTURE_TRADE, RATE_PROVIDER, HW_PROVIDER, LAST_PRICE)); MultiCurrencyAmount computed = PRICER.currencyExposure(FUTURE_TRADE, RATE_PROVIDER, HW_PROVIDER, LAST_PRICE); assertEquals(computed.size(), 1); assertEquals(computed.getAmount(EUR).getAmount(), expected.getAmount(EUR).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_currencyExposure() { MultiCurrencyAmount computed1 = TRADE_PRICER.currencyExposure(CMS_TRADE_PREMIUM, RATES_PROVIDER, VOLATILITIES); MultiCurrencyAmount computed2 = TRADE_PRICER.currencyExposure(CMS_TRADE, RATES_PROVIDER, VOLATILITIES); MultiCurrencyAmount pv1 = TRADE_PRICER.presentValue(CMS_TRADE_PREMIUM, RATES_PROVIDER, VOLATILITIES); PointSensitivities pt1 = TRADE_PRICER.presentValueSensitivityRates(CMS_TRADE_PREMIUM, RATES_PROVIDER, VOLATILITIES); MultiCurrencyAmount expected1 = RATES_PROVIDER.currencyExposure(pt1).plus(pv1); MultiCurrencyAmount pv2 = TRADE_PRICER.presentValue(CMS_TRADE, RATES_PROVIDER, VOLATILITIES); PointSensitivities pt2 = TRADE_PRICER.presentValueSensitivityRates(CMS_TRADE, RATES_PROVIDER, VOLATILITIES); MultiCurrencyAmount expected2 = RATES_PROVIDER.currencyExposure(pt2).plus(pv2); assertEquals(computed1.getAmount(EUR).getAmount(), expected1.getAmount(EUR).getAmount(), NOTIONAL_VALUE * TOL); assertEquals(computed2.getAmount(EUR).getAmount(), expected2.getAmount(EUR).getAmount(), NOTIONAL_VALUE * TOL); }
public void currency_exposure_premium_forward() { CurrencyAmount pv = PRICER_TRADE.presentValue(SWAPTION_PREFWD_LONG_REC, MULTI_USD, HW_PROVIDER); MultiCurrencyAmount ce = PRICER_TRADE.currencyExposure(SWAPTION_PREFWD_LONG_REC, MULTI_USD, HW_PROVIDER); assertEquals(pv.getAmount(), ce.getAmount(USD).getAmount(), TOL * NOTIONAL); }
public void test_currencyExposure() { MultiCurrencyAmount computed1 = PRICER.currencyExposure(CAP_ONE_LEG, RATES, VOLS); MultiCurrencyAmount computed2 = PRICER.currencyExposure(CAP_TWO_LEGS, RATES, VOLS); MultiCurrencyAmount pv1 = PRICER.presentValue(CAP_ONE_LEG, RATES, VOLS); MultiCurrencyAmount pv2 = PRICER.presentValue(CAP_TWO_LEGS, RATES, VOLS); PointSensitivityBuilder point1 = PRICER.presentValueSensitivityRates(CAP_ONE_LEG, RATES, VOLS); PointSensitivityBuilder point2 = PRICER.presentValueSensitivityRates(CAP_TWO_LEGS, RATES, VOLS); MultiCurrencyAmount expected1 = RATES.currencyExposure(point1.build()).plus(pv1); MultiCurrencyAmount expected2 = RATES.currencyExposure(point2.build()).plus(pv2); assertEquals(computed1.getAmount(EUR).getAmount(), expected1.getAmount(EUR).getAmount(), NOTIONAL_VALUE * TOL); assertEquals(computed2.getAmount(EUR).getAmount(), expected2.getAmount(EUR).getAmount(), NOTIONAL_VALUE * TOL); }
public void test_currencyExposure() { MultiCurrencyAmount computed1 = PRICER.currencyExposure(CAP_ONE_LEG, RATES, VOLS); MultiCurrencyAmount computed2 = PRICER.currencyExposure(CAP_TWO_LEGS, RATES, VOLS); MultiCurrencyAmount pv1 = PRICER.presentValue(CAP_ONE_LEG, RATES, VOLS); MultiCurrencyAmount pv2 = PRICER.presentValue(CAP_TWO_LEGS, RATES, VOLS); PointSensitivityBuilder point1 = PRICER.presentValueSensitivityRates(CAP_ONE_LEG, RATES, VOLS); PointSensitivityBuilder point2 = PRICER.presentValueSensitivityRates(CAP_TWO_LEGS, RATES, VOLS); MultiCurrencyAmount expected1 = RATES.currencyExposure(point1.build()).plus(pv1); MultiCurrencyAmount expected2 = RATES.currencyExposure(point2.build()).plus(pv2); assertEquals(computed1.getAmount(EUR).getAmount(), expected1.getAmount(EUR).getAmount(), NOTIONAL_VALUE * TOL); assertEquals(computed2.getAmount(EUR).getAmount(), expected2.getAmount(EUR).getAmount(), NOTIONAL_VALUE * TOL); }
public void test_forecastValue_brl_swap() { DiscountingSwapLegPricer pricerLeg = DiscountingSwapLegPricer.DEFAULT; DiscountingSwapProductPricer pricerSwap = new DiscountingSwapProductPricer(pricerLeg); LocalDate paymentDate = BRL_SWAP.getLegs().get(0).getPaymentPeriods().get(0).getPaymentDate(); LocalDate startDate = BRL_SWAP.getLegs().get(0).getPaymentPeriods().get(0).getStartDate(); double af = BUS_252.yearFraction(startDate, paymentDate); MultiCurrencyAmount forecastComputed = pricerSwap.forecastValue(BRL_SWAP, BRL_DSCON); double forecastExpected = (-Math.pow((1 + COUPON), af) + BRL_DSCON.discountFactor(BRL, startDate) / BRL_DSCON.discountFactor(BRL, paymentDate)) * NOTIONAL; assertTrue(forecastComputed.getCurrencies().size() == 1); assertEquals(forecastComputed.getAmount(BRL).getAmount(), forecastExpected, NOTIONAL * TOLERANCE_RATE); }
public void test_presentValueSensitivity_beforeStart() { PointSensitivities point = PRICER.presentValueSensitivity(SWAP_PRODUCT, PROVIDER); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expectedUsd = CAL_FD.sensitivity( PROVIDER, (p) -> PRICER.presentValue(SWAP_PRODUCT, (p)).getAmount(USD)); CurrencyParameterSensitivities expectedKrw = CAL_FD.sensitivity( PROVIDER, (p) -> PRICER.presentValue(SWAP_PRODUCT, (p)).getAmount(KRW)); assertTrue(computed.equalWithTolerance(expectedUsd.combinedWith(expectedKrw), NOMINAL_USD * FX_RATE * EPS_FD)); }
public void test_presentValue_atMaturity() { CurrencyAmount computedRec = SWAPTION_PRICER.presentValue(SWAPTION_REC_LONG, RATE_PROVIDER_AT_MATURITY, VOLS_AT_MATURITY); CurrencyAmount computedPay = SWAPTION_PRICER.presentValue(SWAPTION_PAY_SHORT, RATE_PROVIDER_AT_MATURITY, VOLS_AT_MATURITY); double swapPV = SWAP_PRICER.presentValue(RSWAP_REC, RATE_PROVIDER_AT_MATURITY).getAmount(USD).getAmount(); assertEquals(computedRec.getAmount(), swapPV, NOTIONAL * TOL); assertEquals(computedPay.getAmount(), 0d, NOTIONAL * TOL); }
public void test_presentValue_atMaturity() { CurrencyAmount computedRec = PRICER.presentValue(SWAPTION_REC_LONG, RATES_PROVIDER_AT_MATURITY, HW_PROVIDER_AT_MATURITY); CurrencyAmount computedPay = PRICER.presentValue(SWAPTION_PAY_SHORT, RATES_PROVIDER_AT_MATURITY, HW_PROVIDER_AT_MATURITY); double swapPv = SWAP_PRICER.presentValue(RSWAP_REC, RATES_PROVIDER_AT_MATURITY).getAmount(EUR).getAmount(); assertEquals(computedRec.getAmount(), swapPv, NOTIONAL * TOL); assertEquals(computedPay.getAmount(), 0d, NOTIONAL * TOL); }
public void test_currencyExposure_fx() { ResolvedSwapLeg expSwapLeg = FIXED_FX_RESET_SWAP_LEG_PAY_GBP; PointSensitivities point = PRICER_LEG.presentValueSensitivity(expSwapLeg, RATES_GBP_USD).build(); MultiCurrencyAmount expected = RATES_GBP_USD.currencyExposure(point.convertedTo(USD, RATES_GBP_USD)) .plus(PRICER_LEG.presentValue(expSwapLeg, RATES_GBP_USD)); MultiCurrencyAmount computed = PRICER_LEG.currencyExposure(expSwapLeg, RATES_GBP_USD); assertEquals(computed.getAmount(USD).getAmount(), expected.getAmount(USD).getAmount(), EPS * NOTIONAL); assertFalse(computed.contains(GBP)); // 0 GBP }
public void present_value_payer_receiver_parity() { CurrencyAmount pvLongPay = PRICER_SWAPTION_NORMAL.presentValue(SWAPTION_LONG_PAY, MULTI_USD, NORMAL_VOLS_USD_STD); CurrencyAmount pvShortRec = PRICER_SWAPTION_NORMAL.presentValue(SWAPTION_SHORT_REC, MULTI_USD, NORMAL_VOLS_USD_STD); MultiCurrencyAmount pvSwapPay = PRICER_SWAP.presentValue(RSWAP_PAY, MULTI_USD); assertEquals(pvLongPay.getAmount() + pvShortRec.getAmount(), pvSwapPay.getAmount(USD).getAmount(), TOLERANCE_PV); }
public void test_presentValueSensitivity_brl_swap() { DiscountingSwapLegPricer pricerLeg = DiscountingSwapLegPricer.DEFAULT; DiscountingSwapProductPricer pricerSwap = new DiscountingSwapProductPricer(pricerLeg); PointSensitivities pts = pricerSwap.presentValueSensitivity(BRL_SWAP, BRL_DSCON).build(); CurrencyParameterSensitivities psComputed = BRL_DSCON.parameterSensitivity(pts); CurrencyParameterSensitivities psExpected = CAL_FD.sensitivity(BRL_DSCON, (p) -> pricerSwap.presentValue(BRL_SWAP, (p)).getAmount(BRL)); assertTrue(psComputed.equalWithTolerance(psExpected, TOLERANCE_PV_PS)); }