AnnuityCouponArithmeticAverageONSpreadDefinition extends AnnuityCouponDefinition<CouponONArithmeticAverageSpreadDefinition> { public static AnnuityCouponArithmeticAverageONSpreadDefinition from(final ZonedDateTime settlementDate, final ZonedDateTime endFixingPeriodDate, final double notional, final double spread, final boolean isPayer, final Period paymentPeriod, final IndexON indexON, final int paymentLag, final BusinessDayConvention businessDayConvention, final boolean isEOM, final Calendar indexCalendar) { return from(settlementDate, endFixingPeriodDate, notional, spread, isPayer, paymentPeriod, indexON, paymentLag, businessDayConvention, isEOM, indexCalendar, StubType.SHORT_START); } AnnuityCouponArithmeticAverageONSpreadDefinition(final CouponONArithmeticAverageSpreadDefinition[] payments, final Calendar calendar); static AnnuityCouponArithmeticAverageONSpreadDefinition from(final ZonedDateTime settlementDate, final ZonedDateTime endFixingPeriodDate, final double notional, final double spread,
      final boolean isPayer, final Period paymentPeriod, final IndexON indexON, final int paymentLag, final BusinessDayConvention businessDayConvention, final boolean isEOM,
      final Calendar indexCalendar); static AnnuityCouponArithmeticAverageONSpreadDefinition from(final ZonedDateTime settlementDate, final ZonedDateTime endFixingPeriodDate, final double notional, final double spread,
      final boolean isPayer, final Period paymentPeriod, final IndexON indexON, final int paymentLag, final BusinessDayConvention businessDayConvention, final boolean isEOM,
      final Calendar indexCalendar, final StubType stub); @Override Annuity<? extends Coupon> toDerivative(final ZonedDateTime valZdt, final DoubleTimeSeries<ZonedDateTime> indexFixingTS);  }
@Test public void from() { final ZonedDateTime maturity = EFFECTIVE_DATE.plus(LEG_TENOR); final AnnuityDefinition<CouponONArithmeticAverageSpreadDefinition> leg = AnnuityCouponArithmeticAverageONSpreadDefinition.from(EFFECTIVE_DATE, maturity, NOTIONAL, SPREAD, true, PAY_TENOR, FEDFUND, PAY_LAG, BUSINESS_DAY, true, CALENDAR, StubType.SHORT_START); final int nbCoupon = leg.getNumberOfPayments(); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition", nbCoupon, 40); for (int loopc = 0; loopc < nbCoupon; loopc++) { assertTrue("AnnuityCouponArithmeticAverageONSpreadDefinition: Payer", leg.getNthPayment(loopc).getNotional() < 0); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition: Notional", leg.getNthPayment(loopc).getNotional(), -NOTIONAL, TOLERANCE_NOTIONAL); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition: Spread", leg.getNthPayment(loopc).getSpread(), SPREAD, TOLERANCE_RATE); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition: Pay lag", leg.getNthPayment(loopc).getPaymentDate(), ScheduleCalculator.getAdjustedDate(leg.getNthPayment(loopc).getAccrualEndDate(), PAY_LAG, CALENDAR)); } }
@Test public void fromStub() { final ZonedDateTime maturity = EFFECTIVE_DATE.plus(LEG_TENOR).plusMonths(1); final AnnuityDefinition<CouponONArithmeticAverageSpreadDefinition> legShortStart = AnnuityCouponArithmeticAverageONSpreadDefinition.from(EFFECTIVE_DATE, maturity, NOTIONAL, SPREAD, true, PAY_TENOR, FEDFUND, PAY_LAG, BUSINESS_DAY, true, CALENDAR, StubType.SHORT_START); final AnnuityDefinition<CouponONArithmeticAverageSpreadDefinition> legShortStart2 = AnnuityCouponArithmeticAverageONSpreadDefinition.from(EFFECTIVE_DATE, maturity, NOTIONAL, SPREAD, true, PAY_TENOR, FEDFUND, PAY_LAG, BUSINESS_DAY, true, CALENDAR); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition: Default", legShortStart, legShortStart2); final int nbCouponShortStart = legShortStart.getNumberOfPayments(); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition", 41, nbCouponShortStart); assertTrue("AnnuityCouponArithmeticAverageONSpreadDefinition: Short start", legShortStart.getNthPayment(0).getAccrualStartDate().getMonth().plus(1) == legShortStart.getNthPayment(0).getAccrualEndDate().getMonth()); final AnnuityDefinition<CouponONArithmeticAverageSpreadDefinition> legShortEnd = AnnuityCouponArithmeticAverageONSpreadDefinition.from(EFFECTIVE_DATE, maturity, NOTIONAL, SPREAD, true, PAY_TENOR, FEDFUND, PAY_LAG, BUSINESS_DAY, true, CALENDAR, StubType.SHORT_END); final int nbCouponShortEnd = legShortEnd.getNumberOfPayments(); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition", 41, nbCouponShortEnd); assertTrue("AnnuityCouponArithmeticAverageONSpreadDefinition: Short end", legShortEnd.getNthPayment(nbCouponShortEnd - 1).getAccrualStartDate().getMonth().plus(1) == legShortEnd.getNthPayment(nbCouponShortEnd - 1).getAccrualEndDate().getMonth()); final AnnuityDefinition<CouponONArithmeticAverageSpreadDefinition> legLongStart = AnnuityCouponArithmeticAverageONSpreadDefinition.from(EFFECTIVE_DATE, maturity, NOTIONAL, SPREAD, true, PAY_TENOR, FEDFUND, PAY_LAG, BUSINESS_DAY, true, CALENDAR, StubType.LONG_START); final int nbCouponLongStart = legLongStart.getNumberOfPayments(); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition", 40, nbCouponLongStart); assertTrue("AnnuityCouponArithmeticAverageONSpreadDefinition: Short start", legLongStart.getNthPayment(0).getAccrualStartDate().getMonth().plus(4) == legLongStart.getNthPayment(0).getAccrualEndDate().getMonth()); final AnnuityDefinition<CouponONArithmeticAverageSpreadDefinition> legLongEnd = AnnuityCouponArithmeticAverageONSpreadDefinition.from(EFFECTIVE_DATE, maturity, NOTIONAL, SPREAD, true, PAY_TENOR, FEDFUND, PAY_LAG, BUSINESS_DAY, true, CALENDAR, StubType.LONG_END); final int nbCouponLongEnd = legLongEnd.getNumberOfPayments(); assertEquals("AnnuityCouponArithmeticAverageONSpreadDefinition", 40, nbCouponLongEnd); assertTrue("AnnuityCouponArithmeticAverageONSpreadDefinition: Short end", legLongEnd.getNthPayment(nbCouponLongEnd - 1).getAccrualStartDate().getMonth().plus(4) == legLongEnd.getNthPayment(nbCouponLongEnd - 1).getAccrualEndDate().getMonth()); }