/** * Gets the start date of the product. * <p> * This is the first coupon period date of the bond, often known as the effective date. * This date has been adjusted to be a valid business day. * * @return the start date */ public LocalDate getStartDate() { return periodicPayments.get(0).getStartDate(); }
private double factorToNextCoupon(ResolvedFixedCouponBond bond, LocalDate settlementDate) { if (bond.getPeriodicPayments().get(0).getStartDate().isAfter(settlementDate)) { return 0d; } int couponIndex = couponIndex(bond.getPeriodicPayments(), settlementDate); double factorSpot = accruedYearFraction(bond, settlementDate); double factorPeriod = bond.getPeriodicPayments().get(couponIndex).getYearFraction(); return (factorPeriod - factorSpot) / factorPeriod; }
public void test_getters() { ResolvedFixedCouponBond test = sut(); ImmutableList<FixedCouponBondPaymentPeriod> payments = test.getPeriodicPayments(); assertEquals(test.getStartDate(), payments.get(0).getStartDate()); assertEquals(test.getEndDate(), payments.get(payments.size() - 1).getEndDate()); assertEquals(test.getUnadjustedStartDate(), payments.get(0).getUnadjustedStartDate()); assertEquals(test.getUnadjustedEndDate(), payments.get(payments.size() - 1).getUnadjustedEndDate()); assertEquals(test.hasExCouponPeriod(), true); }
private void explainBasics(FixedCouponBondPaymentPeriod period, ExplainMapBuilder builder, Currency currency, LocalDate paymentDate) { builder.put(ExplainKey.ENTRY_TYPE, "FixedCouponBondPaymentPeriod"); builder.put(ExplainKey.PAYMENT_DATE, paymentDate); builder.put(ExplainKey.PAYMENT_CURRENCY, currency); builder.put(ExplainKey.START_DATE, period.getStartDate()); builder.put(ExplainKey.UNADJUSTED_START_DATE, period.getUnadjustedStartDate()); builder.put(ExplainKey.END_DATE, period.getEndDate()); builder.put(ExplainKey.UNADJUSTED_END_DATE, period.getUnadjustedEndDate()); builder.put(ExplainKey.ACCRUAL_YEAR_FRACTION, period.getYearFraction()); builder.put(ExplainKey.DAYS, (int) DAYS.between(period.getStartDate(), period.getEndDate())); }
@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(); }
assertEquals(test.getCurrency(), USD); assertEquals(test.getUnadjustedStartDate(), START); assertEquals(test.getStartDate(), START_ADJUSTED); assertEquals(test.getUnadjustedEndDate(), END); assertEquals(test.getEndDate(), END_ADJUSTED); assertEquals(test.getCurrency(), USD); assertEquals(test.getUnadjustedStartDate(), START); assertEquals(test.getStartDate(), START_ADJUSTED); assertEquals(test.getUnadjustedEndDate(), END); assertEquals(test.getEndDate(), END_ADJUSTED);
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); }