/** * Calculates the present value sensitivity of the bond product. * <p> * The present value sensitivity of the product is the sensitivity of the present value to * the underlying curves. * * @param bond the product * @param ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @return the present value curve sensitivity of the product */ public PointSensitivityBuilder presentValueSensitivity( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider) { validate(ratesProvider, discountingProvider); return presentValueSensitivity( bond, ratesProvider, discountingProvider, ratesProvider.getValuationDate()); }
/** * Calculates the present value sensitivity of the bond trade. * <p> * The present value sensitivity of the trade is the sensitivity of the present value to * the underlying curves. * <p> * Coupon payments of the underlying product are considered based on the settlement date of the trade. * * @param trade the trade * @param ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @return the present value sensitivity of the bond trade */ public PointSensitivities presentValueSensitivity( ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = settlementDate(trade, ratesProvider.getValuationDate()); PointSensitivityBuilder productSensi = productPricer.presentValueSensitivity(trade.getProduct(), ratesProvider, discountingProvider, settlementDate); return presentValueSensitivityFromProductPresentValueSensitivity( trade, ratesProvider, discountingProvider, productSensi).build(); }
public void test_presentValueSensitivity() { PointSensitivities point = PRICER.presentValueSensitivity(PRODUCT, RATES_PROVIDER, ISSUER_RATES_PROVIDER).build(); CurrencyParameterSensitivities computed1 = RATES_PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities computed2 = ISSUER_RATES_PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = fdPvSensitivity(PRODUCT, RATES_PROVIDER, ISSUER_RATES_PROVIDER); assertTrue(expected.equalWithTolerance(computed1.combinedWith(computed2), EPS * NOTIONAL)); }
public void test_presentValueSensitivity_exCoupon() { PointSensitivities point = PRICER.presentValueSensitivity(PRODUCT_EX_COUPON, RATES_PROVIDER, ISSUER_RATES_PROVIDER).build(); CurrencyParameterSensitivities computed1 = RATES_PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities computed2 = ISSUER_RATES_PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = fdPvSensitivity(PRODUCT_EX_COUPON, RATES_PROVIDER, ISSUER_RATES_PROVIDER); assertTrue(expected.equalWithTolerance(computed1.combinedWith(computed2), EPS * NOTIONAL)); }
PointSensitivityBuilder dirtyNominalPriceSensitivity( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, LocalDate settlementDate) { double notional = bond.getNotional(); CurrencyAmount pv = presentValue(bond, ratesProvider, discountingProvider, settlementDate); RepoCurveDiscountFactors repoDf = repoCurveDf(bond, discountingProvider); double df = repoDf.discountFactor(settlementDate); PointSensitivityBuilder pvSensi = presentValueSensitivity( bond, ratesProvider, discountingProvider, settlementDate).multipliedBy(1d / (df * notional)); RepoCurveZeroRateSensitivity dfSensi = repoDf.zeroRatePointSensitivity(settlementDate).multipliedBy(-pv.getAmount() / (df * df * notional)); return pvSensi.combinedWith(dfSensi); }
public void test_currencyExposure() { MultiCurrencyAmount computed = PRICER.currencyExposure(PRODUCT, RATES_PROVIDER, ISSUER_RATES_PROVIDER, VALUATION); PointSensitivities point = PRICER.presentValueSensitivity(PRODUCT, RATES_PROVIDER, ISSUER_RATES_PROVIDER).build(); MultiCurrencyAmount expected = RATES_PROVIDER.currencyExposure(point) .plus(PRICER.presentValue(PRODUCT, RATES_PROVIDER, ISSUER_RATES_PROVIDER)); assertEquals(computed.getCurrencies().size(), 1); assertEquals(computed.getAmount(USD).getAmount(), expected.getAmount(USD).getAmount(), NOTIONAL * TOL); }
public void test_currencyExposure_exCoupon() { MultiCurrencyAmount computed = PRICER.currencyExposure(PRODUCT_EX_COUPON, RATES_PROVIDER, ISSUER_RATES_PROVIDER, VALUATION); PointSensitivities point = PRICER.presentValueSensitivity(PRODUCT_EX_COUPON, RATES_PROVIDER, ISSUER_RATES_PROVIDER).build(); MultiCurrencyAmount expected = RATES_PROVIDER.currencyExposure(point) .plus(PRICER.presentValue(PRODUCT_EX_COUPON, RATES_PROVIDER, ISSUER_RATES_PROVIDER)); assertEquals(computed.getCurrencies().size(), 1); assertEquals(computed.getAmount(USD).getAmount(), expected.getAmount(USD).getAmount(), NOTIONAL * TOL); }