/** * Calculates the currency exposure of the bond trade. * * @param trade the trade * @param ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @return the currency exposure of the trade */ public MultiCurrencyAmount currencyExposure( ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider) { CurrencyAmount pv = presentValue(trade, ratesProvider, discountingProvider); return MultiCurrencyAmount.of(pv); }
public void test_presentValue_coherency_standard() { CurrencyAmount pvFromCleanPrice = PRICER.presentValueFromCleanPrice( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, CLEAN_REAL_FROM_CURVES); CurrencyAmount pvFromCurves = PRICER.presentValue( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER); assertEquals(pvFromCleanPrice.getAmount(), pvFromCurves.getAmount(), NOTIONAL * TOL); }
public void test_presentValueSensitivity_late() { PointSensitivities point = PRICER.presentValueSensitivity(TRADE_LATE, RATES_PROVIDER, ISSUER_RATES_PROVIDER); CurrencyParameterSensitivities computed = ISSUER_RATES_PROVIDER.parameterSensitivity(point) .combinedWith(RATES_PROVIDER.parameterSensitivity(point)); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(RATES_PROVIDER, p -> PRICER.presentValue(TRADE_LATE, p, ISSUER_RATES_PROVIDER)).combinedWith( FD_CAL.sensitivity(ISSUER_RATES_PROVIDER, p -> PRICER.presentValue(TRADE_LATE, RATES_PROVIDER, p))); assertTrue(computed.equalWithTolerance(expected, NOTIONAL * QUANTITY * EPS)); }
public void test_presentValueSensitivity_standard() { PointSensitivities point = PRICER.presentValueSensitivity(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER); CurrencyParameterSensitivities computed = ISSUER_RATES_PROVIDER.parameterSensitivity(point) .combinedWith(RATES_PROVIDER.parameterSensitivity(point)); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(RATES_PROVIDER, p -> PRICER.presentValue(TRADE_STANDARD, p, ISSUER_RATES_PROVIDER)).combinedWith( FD_CAL.sensitivity(ISSUER_RATES_PROVIDER, p -> PRICER.presentValue(TRADE_STANDARD, RATES_PROVIDER, p))); assertTrue(computed.equalWithTolerance(expected, NOTIONAL * QUANTITY * EPS)); }
public void test_presentValue_coherency_exCoupon() { CurrencyAmount pvFromCleanPrice = PRICER.presentValueFromCleanPrice( TRADE_EX_COUPON_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, CLEAN_REAL_FROM_CURVES); CurrencyAmount pvFromCurves = PRICER.presentValue( TRADE_EX_COUPON_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER); assertEquals(pvFromCleanPrice.getAmount(), pvFromCurves.getAmount(), NOTIONAL * TOL); }
public void test_presentValue_position() { CurrencyAmount computed = PRICER.presentValue(POSITION, RATES_PROVIDER, ISSUER_RATES_PROVIDER); double expected1 = PRODUCT_PRICER.presentValue( RPRODUCT, RATES_PROVIDER, ISSUER_RATES_PROVIDER, VALUATION).getAmount() * QUANTITY; assertEquals(computed.getAmount(), expected1, NOTIONAL * QUANTITY * TOL); }
public void test_presentValueSensitivity_fixed() { PointSensitivities point = PRICER.presentValueSensitivity(TRADE_ILF_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER); CurrencyParameterSensitivities computed = ISSUER_RATES_PROVIDER.parameterSensitivity(point) .combinedWith(RATES_PROVIDER.parameterSensitivity(point)); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(RATES_PROVIDER, p -> PRICER.presentValue(TRADE_ILF_STANDARD, p, ISSUER_RATES_PROVIDER)).combinedWith(FD_CAL .sensitivity(ISSUER_RATES_PROVIDER, p -> PRICER.presentValue(TRADE_ILF_STANDARD, RATES_PROVIDER, p))); assertTrue(computed.equalWithTolerance(expected, NOTIONAL * QUANTITY * EPS)); }
public void test_presentValue_late() { CurrencyAmount computed = PRICER.presentValue(TRADE_LATE, RATES_PROVIDER, ISSUER_RATES_PROVIDER); double expected1 = PRODUCT_PRICER.presentValue( RPRODUCT, RATES_PROVIDER, ISSUER_RATES_PROVIDER, SETTLEMENT_LATE).getAmount() * QUANTITY; double df = ISSUER_RATES_PROVIDER.repoCurveDiscountFactors(SECURITY_ID, LEGAL_ENTITY, USD) .discountFactor(SETTLEMENT_LATE); double expected2 = df * PERIOD_PRICER.forecastValue(SETTLE_PERIOD_LATE, RATES_PROVIDER); assertEquals(computed.getAmount(), expected1 + expected2, NOTIONAL * QUANTITY * TOL); }
public void test_presentValueSensitivity_position() { PointSensitivities point = PRICER.presentValueSensitivity(POSITION, RATES_PROVIDER, ISSUER_RATES_PROVIDER); CurrencyParameterSensitivities computed = ISSUER_RATES_PROVIDER.parameterSensitivity(point) .combinedWith(RATES_PROVIDER.parameterSensitivity(point)); CurrencyParameterSensitivities fdRates = FD_CAL.sensitivity(RATES_PROVIDER, p -> PRICER.presentValue(POSITION, p, ISSUER_RATES_PROVIDER)); CurrencyParameterSensitivities fdPrice = FD_CAL.sensitivity(ISSUER_RATES_PROVIDER, p -> PRICER.presentValue(POSITION, RATES_PROVIDER, p)); CurrencyParameterSensitivities expected = fdRates.combinedWith(fdPrice); assertTrue(computed.equalWithTolerance(expected, NOTIONAL * QUANTITY * EPS)); }
public void test_presentValue_standard() { CurrencyAmount computed = PRICER.presentValue(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER); double expected1 = PRODUCT_PRICER.presentValue( RPRODUCT, RATES_PROVIDER, ISSUER_RATES_PROVIDER, SETTLEMENT_STANDARD).getAmount() * QUANTITY; double df = ISSUER_RATES_PROVIDER.repoCurveDiscountFactors(SECURITY_ID, LEGAL_ENTITY, USD) .discountFactor(SETTLEMENT_STANDARD); double expected2 = df * PERIOD_PRICER.forecastValue(SETTLE_PERIOD_STANDARD, RATES_PROVIDER); assertEquals(computed.getAmount(), expected1 + expected2, NOTIONAL * QUANTITY * TOL); }
public void test_currencyExposure() { MultiCurrencyAmount computed = PRICER.currencyExposure(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER); PointSensitivities point = PRICER.presentValueSensitivity( TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER); MultiCurrencyAmount expected = RATES_PROVIDER.currencyExposure(point).plus( PRICER.presentValue(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER)); assertEquals(computed.getAmounts().size(), 1); assertEquals(computed.getAmount(USD).getAmount(), expected.getAmount(USD).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValue_fixed() { CurrencyAmount computed = PRICER.presentValue(TRADE_ILF_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER); double expected1 = PRODUCT_PRICER.presentValue( RPRODUCT_ILF, RATES_PROVIDER, ISSUER_RATES_PROVIDER, SETTLEMENT_STANDARD).getAmount() * QUANTITY; double df = ISSUER_RATES_PROVIDER.repoCurveDiscountFactors(SECURITY_ID, LEGAL_ENTITY, USD) .discountFactor(SETTLEMENT_STANDARD); double expected2 = df * PAYMENT_PRICER.forecastValueAmount(SETTLE_PERIOD_ILF.getPayment(), RATES_PROVIDER); assertEquals(computed.getAmount(), expected1 + expected2, NOTIONAL * QUANTITY * TOL); }