AnnuityCapFloorIborDefinition extends AnnuityDefinition<CapFloorIborDefinition> { public static AnnuityCapFloorIborDefinition from(final ZonedDateTime settlementDate, final ZonedDateTime maturityDate, final double notional, final IborIndex index, final boolean isPayer, final double strike, final boolean isCap, final Calendar calendar) { ArgumentChecker.notNull(index, "index"); return from(settlementDate, maturityDate, notional, index, index.getDayCount(), index.getTenor(), isPayer, strike, isCap, calendar); } AnnuityCapFloorIborDefinition(final CapFloorIborDefinition[] payments, final Calendar calendar); static AnnuityCapFloorIborDefinition from(final ZonedDateTime settlementDate, final ZonedDateTime maturityDate, final double notional, final IborIndex index, final boolean isPayer,
      final double strike, final boolean isCap, final Calendar calendar); static AnnuityCapFloorIborDefinition fromWithNoInitialCaplet(final ZonedDateTime settlementDate, final ZonedDateTime maturityDate, final double notional, final IborIndex index,
      final boolean isPayer, final double strike, final boolean isCap, final Calendar calendar); static AnnuityCapFloorIborDefinition from(final ZonedDateTime settlementDate, final ZonedDateTime maturityDate, final double notional, final IborIndex index, final DayCount dayCount,
      final Period paymentPeriod, final boolean isPayer, final double strike, final boolean isCap, final Calendar calendar);  }
@Test public void datesStandard() { final AnnuityCouponIborDefinition iborLeg = AnnuityCouponIborDefinition.from(START_DATE, MATURITY_DATE, NOTIONAL, IBOR_INDEX, IS_PAYER, CALENDAR); for (int loopcpn = 0; loopcpn < iborLeg.getNumberOfPayments(); loopcpn++) { assertEquals(iborLeg.getNthPayment(loopcpn).getAccrualStartDate(), CAP.getNthPayment(loopcpn).getAccrualStartDate()); assertEquals(iborLeg.getNthPayment(loopcpn).getAccrualEndDate(), CAP.getNthPayment(loopcpn).getAccrualEndDate()); assertEquals(iborLeg.getNthPayment(loopcpn).getPaymentYearFraction(), CAP.getNthPayment(loopcpn).getPaymentYearFraction()); assertEquals(iborLeg.getNthPayment(loopcpn).getPaymentDate(), CAP.getNthPayment(loopcpn).getPaymentDate()); assertEquals(iborLeg.getNthPayment(loopcpn).getFixingDate(), CAP.getNthPayment(loopcpn).getFixingDate()); } }
@Test public void commonStandard() { final AnnuityCouponIborDefinition iborLeg = AnnuityCouponIborDefinition.from(START_DATE, MATURITY_DATE, NOTIONAL, IBOR_INDEX, IS_PAYER, CALENDAR); for (int loopcpn = 0; loopcpn < iborLeg.getNumberOfPayments(); loopcpn++) { assertEquals(STRIKE, CAP.getNthPayment(loopcpn).getStrike()); assertEquals(IS_CAP, CAP.getNthPayment(loopcpn).isCap()); } final AnnuityCapFloorIborDefinition floor = AnnuityCapFloorIborDefinition.from(START_DATE, MATURITY_DATE, NOTIONAL, IBOR_INDEX, IS_PAYER, STRIKE, !IS_CAP, CALENDAR); for (int loopcpn = 0; loopcpn < iborLeg.getNumberOfPayments(); loopcpn++) { assertEquals(STRIKE, floor.getNthPayment(loopcpn).getStrike()); assertEquals(!IS_CAP, floor.getNthPayment(loopcpn).isCap()); } final AnnuityCapFloorIborDefinition capShort = AnnuityCapFloorIborDefinition.from(START_DATE, MATURITY_DATE, NOTIONAL, IBOR_INDEX, !IS_PAYER, STRIKE, IS_CAP, CALENDAR); for (int loopcpn = 0; loopcpn < iborLeg.getNumberOfPayments(); loopcpn++) { assertEquals(STRIKE, capShort.getNthPayment(loopcpn).getStrike()); assertEquals(-NOTIONAL * (IS_PAYER ? -1.0 : 1.0), capShort.getNthPayment(loopcpn).getNotional()); } }
@Test public void datesCustom() { final IborIndex fakeIborIndex12 = new IborIndex(CUR, LEG_PAYMENT_PERIOD, IBOR_SETTLEMENT_DAYS, LEG_DAY_COUNT, BUSINESS_DAY, IS_EOM, "Ibor"); final AnnuityCouponIborDefinition iborLeg = AnnuityCouponIborDefinition.from(START_DATE, MATURITY_DATE, NOTIONAL, fakeIborIndex12, IS_PAYER, CALENDAR); for (int loopcpn = 0; loopcpn < iborLeg.getNumberOfPayments(); loopcpn++) { assertEquals(iborLeg.getNthPayment(loopcpn).getAccrualStartDate(), CAP_12.getNthPayment(loopcpn).getAccrualStartDate()); assertEquals(iborLeg.getNthPayment(loopcpn).getAccrualEndDate(), CAP_12.getNthPayment(loopcpn).getAccrualEndDate()); assertEquals(iborLeg.getNthPayment(loopcpn).getPaymentYearFraction(), CAP_12.getNthPayment(loopcpn).getPaymentYearFraction()); assertEquals(iborLeg.getNthPayment(loopcpn).getPaymentDate(), CAP_12.getNthPayment(loopcpn).getPaymentDate()); assertEquals(iborLeg.getNthPayment(loopcpn).getFixingDate(), CAP_12.getNthPayment(loopcpn).getFixingDate()); } }
@Test public void commonCustom() { for (int loopcpn = 0; loopcpn < CAP_12.getNumberOfPayments(); loopcpn++) { assertEquals(STRIKE, CAP_12.getNthPayment(loopcpn).getStrike()); assertEquals(IS_CAP, CAP_12.getNthPayment(loopcpn).isCap()); } final AnnuityCapFloorIborDefinition floor = AnnuityCapFloorIborDefinition.from(START_DATE, MATURITY_DATE, NOTIONAL, IBOR_INDEX, LEG_DAY_COUNT, LEG_PAYMENT_PERIOD, IS_PAYER, STRIKE, !IS_CAP, CALENDAR); for (int loopcpn = 0; loopcpn < CAP_12.getNumberOfPayments(); loopcpn++) { assertEquals(STRIKE, floor.getNthPayment(loopcpn).getStrike()); assertEquals(!IS_CAP, floor.getNthPayment(loopcpn).isCap()); } }