private double currentCashCouponPayment(ResolvedFixedCouponBond product, LocalDate referenceDate) { double cash = 0d; for (FixedCouponBondPaymentPeriod period : product.getPeriodicPayments()) { if (period.getPaymentDate().isEqual(referenceDate)) { cash += period.getFixedRate() * period.getNotional() * period.getYearFraction(); } } return cash; }
/** * Calculates the forecast value of a single fixed coupon payment period. * <p> * The amount is expressed in the currency of the period. * This returns the value of the period with discounting. * <p> * The payment date of the period should not be in the past. * The result of this method for payment dates in the past is undefined. * <p> * The forecast value is z-spread independent. * * @param period the period to price * @param discountFactors the discount factor provider * @return the present value of the period */ public double forecastValue(FixedCouponBondPaymentPeriod period, IssuerCurveDiscountFactors discountFactors) { if (period.getPaymentDate().isBefore(discountFactors.getValuationDate())) { return 0d; } return period.getFixedRate() * period.getNotional() * period.getYearFraction(); }
/** * Calculates the present value of a single fixed coupon payment period. * <p> * The amount is expressed in the currency of the period. * This returns the value of the period with discounting. * <p> * The payment date of the period should not be in the past. * The result of this method for payment dates in the past is undefined. * * @param period the period to price * @param discountFactors the discount factor provider * @return the present value of the period */ public double presentValue(FixedCouponBondPaymentPeriod period, IssuerCurveDiscountFactors discountFactors) { if (period.getPaymentDate().isBefore(discountFactors.getValuationDate())) { return 0d; } double df = discountFactors.discountFactor(period.getPaymentDate()); return period.getFixedRate() * period.getNotional() * period.getYearFraction() * df; }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 575402001: // currency return ((FixedCouponBondPaymentPeriod) bean).getCurrency(); case 1585636160: // notional return ((FixedCouponBondPaymentPeriod) bean).getNotional(); case -2129778896: // startDate return ((FixedCouponBondPaymentPeriod) bean).getStartDate(); case -1607727319: // endDate return ((FixedCouponBondPaymentPeriod) bean).getEndDate(); case 1457691881: // unadjustedStartDate return ((FixedCouponBondPaymentPeriod) bean).getUnadjustedStartDate(); case 31758114: // unadjustedEndDate return ((FixedCouponBondPaymentPeriod) bean).getUnadjustedEndDate(); case -878940481: // detachmentDate return ((FixedCouponBondPaymentPeriod) bean).getDetachmentDate(); case 747425396: // fixedRate return ((FixedCouponBondPaymentPeriod) bean).getFixedRate(); case -1731780257: // yearFraction return ((FixedCouponBondPaymentPeriod) bean).getYearFraction(); } return super.propertyGet(bean, propertyName, quiet); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(FixedCouponBondPaymentPeriod beanToCopy) { this.currency = beanToCopy.getCurrency(); this.notional = beanToCopy.getNotional(); this.startDate = beanToCopy.getStartDate(); this.endDate = beanToCopy.getEndDate(); this.unadjustedStartDate = beanToCopy.getUnadjustedStartDate(); this.unadjustedEndDate = beanToCopy.getUnadjustedEndDate(); this.detachmentDate = beanToCopy.getDetachmentDate(); this.fixedRate = beanToCopy.getFixedRate(); this.yearFraction = beanToCopy.getYearFraction(); }
/** * Calculates the present value sensitivity of a single fixed coupon payment period. * <p> * The present value sensitivity of the period is the sensitivity of the present value to * the underlying curves. * * @param period the period to price * @param discountFactors the discount factor provider * @return the present value curve sensitivity of the period */ public PointSensitivityBuilder presentValueSensitivity( FixedCouponBondPaymentPeriod period, IssuerCurveDiscountFactors discountFactors) { if (period.getPaymentDate().isBefore(discountFactors.getValuationDate())) { return PointSensitivityBuilder.none(); } IssuerCurveZeroRateSensitivity dscSensi = discountFactors.zeroRatePointSensitivity(period.getPaymentDate()); return dscSensi.multipliedBy(period.getFixedRate() * period.getNotional() * period.getYearFraction()); }
return period.getFixedRate() * period.getNotional() * period.getYearFraction() * df;
if (yieldConv.equals(US_STREET) || yieldConv.equals(DE_BONDS)) { FixedCouponBondPaymentPeriod payment = payments.get(payments.size() - 1); return (1d + payment.getFixedRate() * payment.getYearFraction()) / (1d + factorToNextCoupon(bond, settlementDate) * yield / ((double) bond.getFrequency().eventsPerYear()));
assertEquals(test.getPaymentDate(), END_ADJUSTED); assertEquals(test.getDetachmentDate(), DETACHMENT_DATE); assertEquals(test.getFixedRate(), FIXED_RATE); assertEquals(test.getNotional(), NOTIONAL); assertEquals(test.getYearFraction(), YEAR_FRACTION); assertEquals(test.getPaymentDate(), END_ADJUSTED); assertEquals(test.getDetachmentDate(), DETACHMENT_DATE); assertEquals(test.getFixedRate(), FIXED_RATE); assertEquals(test.getNotional(), NOTIONAL); assertEquals(test.getYearFraction(), YEAR_FRACTION);
public void test_resolve() { FixedCouponBond base = sut(); ResolvedFixedCouponBond resolved = base.resolve(REF_DATA); assertEquals(resolved.getLegalEntityId(), LEGAL_ENTITY); assertEquals(resolved.getSettlementDateOffset(), DATE_OFFSET); assertEquals(resolved.getYieldConvention(), YIELD_CONVENTION); ImmutableList<FixedCouponBondPaymentPeriod> periodicPayments = resolved.getPeriodicPayments(); int expNum = 20; assertEquals(periodicPayments.size(), expNum); LocalDate unadjustedEnd = END_DATE; Schedule unadjusted = PERIOD_SCHEDULE.createSchedule(REF_DATA).toUnadjusted(); for (int i = 0; i < expNum; ++i) { FixedCouponBondPaymentPeriod payment = periodicPayments.get(expNum - 1 - i); assertEquals(payment.getCurrency(), EUR); assertEquals(payment.getNotional(), NOTIONAL); assertEquals(payment.getFixedRate(), FIXED_RATE); assertEquals(payment.getUnadjustedEndDate(), unadjustedEnd); assertEquals(payment.getEndDate(), BUSINESS_ADJUST.adjust(unadjustedEnd, REF_DATA)); assertEquals(payment.getPaymentDate(), payment.getEndDate()); LocalDate unadjustedStart = unadjustedEnd.minusMonths(6); assertEquals(payment.getUnadjustedStartDate(), unadjustedStart); assertEquals(payment.getStartDate(), BUSINESS_ADJUST.adjust(unadjustedStart, REF_DATA)); assertEquals(payment.getYearFraction(), unadjusted.getPeriod(expNum - 1 - i).yearFraction(DAY_COUNT, unadjusted)); assertEquals(payment.getDetachmentDate(), EX_COUPON.adjust(payment.getPaymentDate(), REF_DATA)); unadjustedEnd = unadjustedStart; } Payment expectedPayment = Payment.of(CurrencyAmount.of(EUR, NOTIONAL), BUSINESS_ADJUST.adjust(END_DATE, REF_DATA)); assertEquals(resolved.getNominalPayment(), expectedPayment); }
IssuerCurveZeroRateSensitivity dscSensi = IssuerCurveZeroRateSensitivity.of(zeroSensi, discountFactors.getLegalEntityGroup()); return dscSensi.multipliedBy(period.getFixedRate() * period.getNotional() * period.getYearFraction());