CurrencyAmount presentValue( ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, LocalDate referenceDate) { IssuerCurveDiscountFactors issuerDf = issuerCurveDf(bond, provider); CurrencyAmount pvNominal = nominalPricer.presentValue(bond.getNominalPayment(), issuerDf.getDiscountFactors()); CurrencyAmount pvCoupon = presentValueCoupon(bond, issuerDf, referenceDate); return pvNominal.plus(pvCoupon); }
PointSensitivityBuilder dirtyPriceSensitivity( ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, LocalDate referenceDate) { RepoCurveDiscountFactors repoDf = repoCurveDf(bond, provider); double df = repoDf.discountFactor(referenceDate); CurrencyAmount pv = presentValue(bond, provider); double notional = bond.getNotional(); PointSensitivityBuilder pvSensi = presentValueSensitivity(bond, provider).multipliedBy(1d / df / notional); RepoCurveZeroRateSensitivity dfSensi = repoDf.zeroRatePointSensitivity(referenceDate) .multipliedBy(-pv.getAmount() / df / df / notional); return pvSensi.combinedWith(dfSensi); }
/** * Calculates the present value of the fixed coupon bond trade. * <p> * The present value of the trade is the value on the valuation date. * The result is expressed using the payment currency of the bond. * <p> * Coupon payments of the underlying product are considered based on the settlement date of the trade. * * @param trade the trade * @param provider the discounting provider * @return the present value of the fixed coupon bond trade */ public CurrencyAmount presentValue(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider) { LocalDate settlementDate = settlementDate(trade, provider.getValuationDate()); CurrencyAmount pvProduct = productPricer.presentValue(trade.getProduct(), provider, settlementDate); return presentValueFromProductPresentValue(trade, provider, pvProduct); }
public void test_presentValueSensitivity() { PointSensitivityBuilder point = PRICER.presentValueSensitivity(PRODUCT, PROVIDER); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point.build()); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, p -> PRICER.presentValue(PRODUCT, p)); assertTrue(computed.equalWithTolerance(expected, 30d * NOTIONAL * EPS)); }
/** * Calculates the dirty price of the fixed coupon bond under the specified settlement date. * <p> * The fixed coupon bond is represented as {@link Security} where standard ID of the bond is stored. * * @param bond the product * @param provider the discounting provider * @param settlementDate the settlement date * @return the dirty price of the fixed coupon bond security */ public double dirtyPriceFromCurves( ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, LocalDate settlementDate) { CurrencyAmount pv = presentValue(bond, provider, settlementDate); RepoCurveDiscountFactors repoDf = repoCurveDf(bond, provider); double df = repoDf.discountFactor(settlementDate); double notional = bond.getNotional(); return pv.getAmount() / df / notional; }
public void test_presentValueProductSensitivity_noExcoupon() { PointSensitivityBuilder point = PRICER.presentValueSensitivity(PRODUCT_NO_EXCOUPON, PROVIDER); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point.build()); CurrencyParameterSensitivities expected = FD_CAL.sensitivity( PROVIDER, p -> PRICER.presentValue(PRODUCT_NO_EXCOUPON, p)); assertTrue(computed.equalWithTolerance(expected, 30d * NOTIONAL * EPS)); }
public void test_presentValue_position() { CurrencyAmount computedTrade = TRADE_PRICER.presentValue(POSITION, PROVIDER); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValue(PRODUCT, PROVIDER, VAL_DATE); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_dirtyPriceFromCurves() { double computed = PRICER.dirtyPriceFromCurves(PRODUCT, PROVIDER, REF_DATA); CurrencyAmount pv = PRICER.presentValue(PRODUCT, PROVIDER); LocalDate settlement = DATE_OFFSET.adjust(VAL_DATE, REF_DATA); double df = DSC_FACTORS_REPO.discountFactor(settlement); assertEquals(computed, pv.getAmount() / df / NOTIONAL); }
public void test_presentValue_noExcoupon() { CurrencyAmount computed = PRICER.presentValue(PRODUCT_NO_EXCOUPON, PROVIDER); CurrencyAmount expected = PRICER_NOMINAL.presentValue(PRODUCT.getNominalPayment(), DSC_FACTORS_ISSUER); int size = PRODUCT.getPeriodicPayments().size(); double pvcCupon = 0d; for (int i = 2; i < size; ++i) { FixedCouponBondPaymentPeriod payment = PRODUCT.getPeriodicPayments().get(i); pvcCupon += PRICER_COUPON.presentValue(payment, IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER)); } expected = expected.plus(pvcCupon); assertEquals(computed.getCurrency(), EUR); assertEquals(computed.getAmount(), expected.getAmount(), NOTIONAL * TOL); }
public void test_presentValue() { CurrencyAmount computed = PRICER.presentValue(PRODUCT, PROVIDER); CurrencyAmount expected = PRICER_NOMINAL.presentValue(PRODUCT.getNominalPayment(), DSC_FACTORS_ISSUER); int size = PRODUCT.getPeriodicPayments().size(); double pvCupon = 0d; for (int i = 2; i < size; ++i) { FixedCouponBondPaymentPeriod payment = PRODUCT.getPeriodicPayments().get(i); pvCupon += PRICER_COUPON.presentValue(payment, IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER)); } expected = expected.plus(pvCupon); assertEquals(computed.getCurrency(), EUR); assertEquals(computed.getAmount(), expected.getAmount(), NOTIONAL * TOL); }
public void test_presentValue_noExcoupon() { CurrencyAmount computedTrade = TRADE_PRICER.presentValue(TRADE_NO_EXCOUPON, PROVIDER); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValue(PRODUCT_NO_EXCOUPON, PROVIDER, SETTLEMENT); CurrencyAmount pvPayment = PRICER_NOMINAL.presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).plus(pvPayment).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValue() { CurrencyAmount computedTrade = TRADE_PRICER.presentValue(TRADE, PROVIDER); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValue(PRODUCT, PROVIDER, SETTLEMENT); CurrencyAmount pvPayment = PRICER_NOMINAL.presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).plus(pvPayment).getAmount(), NOTIONAL * QUANTITY * TOL); }