@Override public LocalDate getPaymentDate() { return getEndDate(); }
/** * Gets the end date of the product. * <p> * This is the last coupon period date of the bond, often known as the maturity date. * This date has been adjusted to be a valid business day. * * @return the end date */ public LocalDate getEndDate() { return periodicPayments.get(periodicPayments.size() - 1).getEndDate(); }
public void test_accruedInterest_jpw() { double accPositive = PRODUCT_JPW.accruedInterest(LocalDate.of(2016, 3, 9)); CapitalIndexedBondPaymentPeriod period = PRODUCT_JPW.getPeriodicPayments().get(4); double yc = PRODUCT_JPW.getDayCount().relativeYearFraction(period.getStartDate(), period.getEndDate()); double expected = CPN_VALUE_JPW * 2d * yc * NTNL; // accrual of total period based on ACT/365F assertEquals(accPositive, expected, NTNL * NOTIONAL); double accZero = PRODUCT_JPW.accruedInterest(LocalDate.of(2016, 3, 10)); assertEquals(accZero, 0d); }
public void test_accruedInterest_jpi() { double accPositive = PRODUCT_JPI.accruedInterest(LocalDate.of(2016, 3, 9)); CapitalIndexedBondPaymentPeriod period = PRODUCT_JPI.getPeriodicPayments().get(1); double yc = PRODUCT_JPI.getDayCount().relativeYearFraction(period.getStartDate(), period.getEndDate()); double expected = CPN_VALUE_JPI * 2d * yc * NTNL; // accrual of total period based on ACT/365F assertEquals(accPositive, expected, TOL * NTNL); double accZero = PRODUCT_JPI.accruedInterest(LocalDate.of(2016, 3, 10)); assertEquals(accZero, 0d); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 575402001: // currency return ((CapitalIndexedBondPaymentPeriod) bean).getCurrency(); case 1585636160: // notional return ((CapitalIndexedBondPaymentPeriod) bean).getNotional(); case 1842278244: // realCoupon return ((CapitalIndexedBondPaymentPeriod) bean).getRealCoupon(); case -2129778896: // startDate return ((CapitalIndexedBondPaymentPeriod) bean).getStartDate(); case -1607727319: // endDate return ((CapitalIndexedBondPaymentPeriod) bean).getEndDate(); case 1457691881: // unadjustedStartDate return ((CapitalIndexedBondPaymentPeriod) bean).getUnadjustedStartDate(); case 31758114: // unadjustedEndDate return ((CapitalIndexedBondPaymentPeriod) bean).getUnadjustedEndDate(); case -878940481: // detachmentDate return ((CapitalIndexedBondPaymentPeriod) bean).getDetachmentDate(); case 625350855: // rateComputation return ((CapitalIndexedBondPaymentPeriod) bean).getRateComputation(); } return super.propertyGet(bean, propertyName, quiet); }
/** * Calculates the forecast value of a single payment period. * * @param period the period to price * @param ratesProvider the rates provider, used to determine price index values * @return the forecast value of the period */ public double forecastValue(CapitalIndexedBondPaymentPeriod period, RatesProvider ratesProvider) { if (period.getPaymentDate().isBefore(ratesProvider.getValuationDate())) { return 0d; } double rate = rateComputationFn.rate( period.getRateComputation(), period.getStartDate(), period.getEndDate(), ratesProvider); return period.getNotional() * period.getRealCoupon() * (rate + 1d); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(CapitalIndexedBondPaymentPeriod beanToCopy) { this.currency = beanToCopy.getCurrency(); this.notional = beanToCopy.getNotional(); this.realCoupon = beanToCopy.getRealCoupon(); this.startDate = beanToCopy.getStartDate(); this.endDate = beanToCopy.getEndDate(); this.unadjustedStartDate = beanToCopy.getUnadjustedStartDate(); this.unadjustedEndDate = beanToCopy.getUnadjustedEndDate(); this.detachmentDate = beanToCopy.getDetachmentDate(); this.rateComputation = beanToCopy.getRateComputation(); }
public void test_builder() { ResolvedCapitalIndexedBond test = sut(); assertEquals(test.getCurrency(), USD); assertEquals(test.getDayCount(), ACT_ACT_ISDA); assertEquals(test.getStartDate(), PERIODIC[0].getStartDate()); assertEquals(test.getEndDate(), PERIODIC[3].getEndDate()); assertEquals(test.getUnadjustedStartDate(), PERIODIC[0].getUnadjustedStartDate()); assertEquals(test.getUnadjustedEndDate(), PERIODIC[3].getUnadjustedEndDate()); assertEquals(test.getLegalEntityId(), LEGAL_ENTITY); assertEquals(test.getNominalPayment(), NOMINAL); assertEquals(test.getNotional(), NOTIONAL); assertEquals(test.getPeriodicPayments().toArray(), PERIODIC); assertEquals(test.getSettlementDateOffset(), SETTLE_OFFSET); assertEquals(test.getYieldConvention(), US_IL_REAL); assertEquals(test.hasExCouponPeriod(), false); assertEquals(test.getFirstIndexValue(), RATE_CALC.getFirstIndexValue().getAsDouble()); assertEquals(test.findPeriod(PERIODIC[0].getUnadjustedStartDate()), Optional.of(test.getPeriodicPayments().get(0))); assertEquals(test.findPeriod(LocalDate.MIN), Optional.empty()); assertEquals(test.findPeriodIndex(PERIODIC[0].getUnadjustedStartDate()), OptionalInt.of(0)); assertEquals(test.findPeriodIndex(PERIODIC[1].getUnadjustedStartDate()), OptionalInt.of(1)); assertEquals(test.findPeriodIndex(LocalDate.MIN), OptionalInt.empty()); assertEquals( test.calculateSettlementDateFromValuation(date(2015, 6, 30), REF_DATA), SETTLE_OFFSET.adjust(date(2015, 6, 30), REF_DATA)); }
public void test_builder_min() { CapitalIndexedBondPaymentPeriod test = CapitalIndexedBondPaymentPeriod.builder() .currency(USD) .notional(NOTIONAL) .startDate(START) .endDate(END) .rateComputation(COMPUTE_MONTH) .realCoupon(REAL_COUPON) .build(); assertEquals(test.getCurrency(), USD); assertEquals(test.getNotional(), NOTIONAL); assertEquals(test.getDetachmentDate(), END); assertEquals(test.getStartDate(), START); assertEquals(test.getEndDate(), END); assertEquals(test.getUnadjustedStartDate(), START); assertEquals(test.getUnadjustedEndDate(), END); assertEquals(test.getRateComputation(), COMPUTE_MONTH); assertEquals(test.getRealCoupon(), REAL_COUPON); }
public void test_builder_full() { CapitalIndexedBondPaymentPeriod test = CapitalIndexedBondPaymentPeriod.builder() .currency(USD) .notional(NOTIONAL) .detachmentDate(DETACHMENT) .startDate(START) .endDate(END) .unadjustedStartDate(START_UNADJ) .unadjustedEndDate(END_UNADJ) .rateComputation(COMPUTE_INTERP) .realCoupon(REAL_COUPON) .build(); assertEquals(test.getCurrency(), USD); assertEquals(test.getNotional(), NOTIONAL); assertEquals(test.getDetachmentDate(), DETACHMENT); assertEquals(test.getStartDate(), START); assertEquals(test.getEndDate(), END); assertEquals(test.getUnadjustedStartDate(), START_UNADJ); assertEquals(test.getUnadjustedEndDate(), END_UNADJ); assertEquals(test.getRateComputation(), COMPUTE_INTERP); assertEquals(test.getRealCoupon(), REAL_COUPON); }
/** * Calculates the forecast value sensitivity of a single payment period. * <p> * The forecast value sensitivity of the period is the sensitivity of the present value to * the underlying curves. * * @param period the period to price * @param ratesProvider the rates provider, used to determine price index values * @return the forecast value sensitivity of the period */ public PointSensitivityBuilder forecastValueSensitivity( CapitalIndexedBondPaymentPeriod period, RatesProvider ratesProvider) { if (period.getPaymentDate().isBefore(ratesProvider.getValuationDate())) { return PointSensitivityBuilder.none(); } PointSensitivityBuilder rateSensi = rateComputationFn.rateSensitivity( period.getRateComputation(), period.getStartDate(), period.getEndDate(), ratesProvider); return rateSensi.multipliedBy(period.getNotional() * period.getRealCoupon()); }
/** * Calculates the present value sensitivity of a single 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 ratesProvider the rates provider, used to determine price index values * @param issuerDiscountFactors the discount factor provider * @return the present value curve sensitivity of the period */ public PointSensitivityBuilder presentValueSensitivity( CapitalIndexedBondPaymentPeriod period, RatesProvider ratesProvider, IssuerCurveDiscountFactors issuerDiscountFactors) { if (period.getPaymentDate().isBefore(ratesProvider.getValuationDate())) { return PointSensitivityBuilder.none(); } double rate = rateComputationFn.rate( period.getRateComputation(), period.getStartDate(), period.getEndDate(), ratesProvider); PointSensitivityBuilder rateSensi = rateComputationFn.rateSensitivity( period.getRateComputation(), period.getStartDate(), period.getEndDate(), ratesProvider); double df = issuerDiscountFactors.discountFactor(period.getPaymentDate()); PointSensitivityBuilder dfSensi = issuerDiscountFactors.zeroRatePointSensitivity(period.getPaymentDate()); double factor = period.getNotional() * period.getRealCoupon(); return rateSensi.multipliedBy(df * factor).combinedWith(dfSensi.multipliedBy((rate + 1d) * factor)); }
period.getRateComputation(), period.getStartDate(), period.getEndDate(), ratesProvider); PointSensitivityBuilder rateSensi = rateComputationFn.rateSensitivity( period.getRateComputation(), period.getStartDate(), period.getEndDate(), ratesProvider); double df = issuerDiscountFactors.getDiscountFactors() .discountFactorWithSpread(period.getPaymentDate(), zSpread, compoundedRateType, periodsPerYear);
public void test_builder_fail() { CapitalIndexedBondPaymentPeriod period = CapitalIndexedBondPaymentPeriod.builder() .startDate(PERIODIC[2].getStartDate()) .endDate(PERIODIC[2].getEndDate()) .currency(GBP) .notional(NOTIONAL) .rateComputation(PERIODIC[2].getRateComputation()) .realCoupon(COUPON) .build(); assertThrowsIllegalArg(() -> ResolvedCapitalIndexedBond.builder() .dayCount(ACT_ACT_ISDA) .legalEntityId(LEGAL_ENTITY) .nominalPayment(NOMINAL) .periodicPayments(PERIODIC[0], PERIODIC[1], period, PERIODIC[3]) .settlementDateOffset(SETTLE_OFFSET) .yieldConvention(US_IL_REAL) .build()); }
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.DAYS, (int) DAYS.between(period.getUnadjustedStartDate(), period.getUnadjustedEndDate()));
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.DAYS, (int) DAYS.between(period.getUnadjustedStartDate(), period.getUnadjustedEndDate()));