public void test_resolve() { ResolvedFixedCouponBondTrade expected = ResolvedFixedCouponBondTrade.builder() .info(TRADE_INFO) .product(PRODUCT.resolve(REF_DATA)) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT_DATE, PRICE)) .build(); assertEquals(sut().resolve(REF_DATA), expected); }
.product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(valuation1, CLEAN_PRICE)) .build(); LegalEntityDiscountingProvider provider1 = createRatesProvider(valuation1); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_DETACHMENT.plusDays(2), CLEAN_PRICE)) .build(); CurrencyAmount computed2 = TRADE_PRICER_NO_UPFRONT.presentValueFromCleanPrice(trade2, provider1, REF_DATA, cleanPrice); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_DETACHMENT.plusDays(7), CLEAN_PRICE)) .build(); CurrencyAmount computed3 = TRADE_PRICER_NO_UPFRONT.presentValueFromCleanPrice(trade3, provider1, REF_DATA, cleanPrice); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(settlement4, CLEAN_PRICE)) .build(); LocalDate standardSettlement4 = PRODUCT.getSettlementDateOffset().adjust(TRADE_BEFORE, REF_DATA); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(settlement5, CLEAN_PRICE)) .build(); CurrencyAmount computed5 = TRADE_PRICER_NO_UPFRONT.presentValueFromCleanPrice(trade5, PROVIDER_BEFORE, REF_DATA, cleanPrice);
.product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(valuation1, CLEAN_PRICE)) .build(); LegalEntityDiscountingProvider provider1 = createRatesProvider(valuation1); .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(settlement2, CLEAN_PRICE)) .build(); CurrencyAmount computed2 = TRADE_PRICER_NO_UPFRONT.presentValueFromCleanPrice(trade2, provider1, REF_DATA, cleanPrice); .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(settlement3, CLEAN_PRICE)) .build(); CurrencyAmount computed3 = TRADE_PRICER_NO_UPFRONT.presentValueFromCleanPrice(trade3, provider1, REF_DATA, cleanPrice); .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(settlement4, CLEAN_PRICE)) .build(); LocalDate standardSettlement4 = PRODUCT_NO_EXCOUPON.getSettlementDateOffset().adjust(TRADE_BEFORE, REF_DATA); .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(settlement5, CLEAN_PRICE)) .build(); CurrencyAmount computed5 = TRADE_PRICER_NO_UPFRONT.presentValueFromCleanPrice(trade5, PROVIDER_BEFORE, REF_DATA, cleanPrice);
.product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT, CLEAN_PRICE)) .build(); PointSensitivities computedTradeAfter = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeAfter, PROVIDER_BEFORE); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BEFORE, CLEAN_PRICE)) .build(); PointSensitivities computedTradeBefore = .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_DETACHMENT, CLEAN_PRICE)) .build(); PointSensitivities computedTradeOnDetachment = .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BTWN_DETACHMENT_COUPON, CLEAN_PRICE)) .build(); PointSensitivities computedTradeBtwnDetachmentCoupon =
.product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeAfter = TRADE_PRICER_NO_UPFRONT.presentValue(tradeAfter, PROVIDER_BEFORE); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BEFORE, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeBefore = TRADE_PRICER_NO_UPFRONT.presentValue(tradeBefore, PROVIDER_BEFORE); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_DETACHMENT, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeOnDetachment = TRADE_PRICER_NO_UPFRONT.presentValue(tradeOnDetachment, PROVIDER_BEFORE); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BTWN_DETACHMENT_COUPON, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeBtwnDetachmentCoupon =
.product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT, CLEAN_PRICE)) .build(); PointSensitivities computedTradeAfter = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeAfter, PROVIDER); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BEFORE, CLEAN_PRICE)) .build(); PointSensitivities computedTradeBefore = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeBefore, PROVIDER); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_DETACHMENT, CLEAN_PRICE)) .build(); PointSensitivities computedTradeOnDetachment = .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BTWN_DETACHMENT_COUPON, CLEAN_PRICE)) .build(); PointSensitivities computedTradeBtwnDetachmentCoupon =
.product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeAfter = TRADE_PRICER_NO_UPFRONT.presentValue(tradeAfter, PROVIDER); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BEFORE, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeBefore = TRADE_PRICER_NO_UPFRONT.presentValue(tradeBefore, PROVIDER); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_DETACHMENT, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeOnDetachment = TRADE_PRICER_NO_UPFRONT.presentValue(tradeOnDetachment, PROVIDER); .product(PRODUCT) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BTWN_DETACHMENT_COUPON, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeBtwnDetachmentCoupon =
public void test_presentValueSensitivity_dateLogic_noExcoupon() { ResolvedFixedCouponBondTrade tradeAfter = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT, CLEAN_PRICE)) .build(); PointSensitivities computedTradeAfter = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeAfter, PROVIDER_BEFORE); // settle before coupon date ResolvedFixedCouponBondTrade tradeBefore = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BEFORE, CLEAN_PRICE)) .build(); PointSensitivities computedTradeBefore = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeBefore, PROVIDER_BEFORE); FixedCouponBondPaymentPeriod periodExtra = findPeriod(PRODUCT_NO_EXCOUPON, SETTLE_BEFORE, SETTLEMENT); PointSensitivities sensiExtra = COUPON_PRICER .presentValueSensitivity(periodExtra, PROVIDER_BEFORE.issuerCurveDiscountFactors(ISSUER_ID, EUR)).build(); assertTrue(computedTradeBefore.normalized().equalWithTolerance( computedTradeAfter.combinedWith(sensiExtra.multipliedBy(QUANTITY)).normalized(), NOTIONAL * QUANTITY * TOL)); // settle on coupon date ResolvedFixedCouponBondTrade tradeOnCoupon = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_COUPON, CLEAN_PRICE)) .build(); PointSensitivities computedTradeOnCoupon = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeOnCoupon, PROVIDER_BEFORE); assertTrue(computedTradeOnCoupon.equalWithTolerance(computedTradeAfter, NOTIONAL * QUANTITY * TOL)); }
public void test_presentValue_dateLogic_noExcoupon() { ResolvedFixedCouponBondTrade tradeAfter = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeAfter = TRADE_PRICER_NO_UPFRONT.presentValue(tradeAfter, PROVIDER_BEFORE); // settle before coupon date ResolvedFixedCouponBondTrade tradeBefore = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BEFORE, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeBefore = TRADE_PRICER_NO_UPFRONT.presentValue(tradeBefore, PROVIDER_BEFORE); FixedCouponBondPaymentPeriod periodExtra = findPeriod(PRODUCT_NO_EXCOUPON, SETTLE_BEFORE, SETTLEMENT); double pvExtra = COUPON_PRICER.presentValue(periodExtra, PROVIDER_BEFORE.issuerCurveDiscountFactors(ISSUER_ID, EUR)); assertEquals(computedTradeBefore.getAmount(), computedTradeAfter.plus(pvExtra * QUANTITY).getAmount(), NOTIONAL * QUANTITY * TOL); // settle on coupon date ResolvedFixedCouponBondTrade tradeOnCoupon = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_COUPON, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeOnCoupon = TRADE_PRICER_NO_UPFRONT.presentValue(tradeOnCoupon, PROVIDER_BEFORE); assertEquals(computedTradeOnCoupon.getAmount(), computedTradeAfter.getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValueSensitivity_dateLogic_pastSettle_noExcoupon() { ResolvedFixedCouponBondTrade tradeAfter = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT, CLEAN_PRICE)) .build(); PointSensitivities computedTradeAfter = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeAfter, PROVIDER); // settle before coupon date ResolvedFixedCouponBondTrade tradeBefore = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BEFORE, CLEAN_PRICE)) .build(); PointSensitivities computedTradeBefore = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeBefore, PROVIDER); assertTrue(computedTradeBefore.equalWithTolerance(computedTradeAfter, NOTIONAL * QUANTITY * TOL)); // settle on coupon date ResolvedFixedCouponBondTrade tradeOnCoupon = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_COUPON, CLEAN_PRICE)) .build(); PointSensitivities computedTradeOnCoupon = TRADE_PRICER_NO_UPFRONT.presentValueSensitivity(tradeOnCoupon, PROVIDER); assertTrue(computedTradeOnCoupon.equalWithTolerance(computedTradeAfter, NOTIONAL * QUANTITY * TOL)); }
public void test_presentValue_dateLogic_pastSettle_noExcoupon() { ResolvedFixedCouponBondTrade tradeAfter = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLEMENT, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeAfter = TRADE_PRICER_NO_UPFRONT.presentValue(tradeAfter, PROVIDER); // settle before coupon date ResolvedFixedCouponBondTrade tradeBefore = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_BEFORE, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeBefore = TRADE_PRICER_NO_UPFRONT.presentValue(tradeBefore, PROVIDER); assertEquals(computedTradeBefore.getAmount(), computedTradeAfter.getAmount(), NOTIONAL * QUANTITY * TOL); // settle on coupon date ResolvedFixedCouponBondTrade tradeOnCoupon = ResolvedFixedCouponBondTrade.builder() .product(PRODUCT_NO_EXCOUPON) .quantity(QUANTITY) .settlement(ResolvedFixedCouponBondSettlement.of(SETTLE_ON_COUPON, CLEAN_PRICE)) .build(); CurrencyAmount computedTradeOnCoupon = TRADE_PRICER_NO_UPFRONT.presentValue(tradeOnCoupon, PROVIDER); assertEquals(computedTradeOnCoupon.getAmount(), computedTradeAfter.getAmount(), NOTIONAL * QUANTITY * TOL); }
@Override public ResolvedFixedCouponBondTrade resolve(ReferenceData refData) { ResolvedFixedCouponBond resolved = getProduct().resolve(refData); LocalDate settlementDate = calculateSettlementDate(refData); return ResolvedFixedCouponBondTrade.builder() .info(info) .product(resolved) .quantity(quantity) .settlement(ResolvedFixedCouponBondSettlement.of(settlementDate, price)) .build(); }