CouponONCompoundedDefinition extends CouponDefinition implements InstrumentDefinitionWithData<Payment, DoubleTimeSeries<ZonedDateTime>> { @Override public CouponONCompounded toDerivative(final ZonedDateTime date) { ArgumentChecker.notNull(date, "date"); final LocalDate firstPublicationDate = _fixingPeriodDates[_index.getPublicationLag()].toLocalDate(); ArgumentChecker.isTrue(date.toLocalDate().isBefore(firstPublicationDate), "toDerivative method without time series as argument is only valid at dates where the first fixing has not yet been published."); final double paymentTime = TimeCalculatorBUS252.getTimeBetween(date, getPaymentDate(), _calendar); final double[] fixingPeriodStartTimes = new double[_fixingPeriodDates.length - 1]; final double[] fixingPeriodEndTimes = new double[_fixingPeriodDates.length - 1]; for (int i = 0; i < _fixingPeriodDates.length - 1; i++) { fixingPeriodStartTimes[i] = TimeCalculatorBUS252.getTimeBetween(date, _fixingPeriodDates[i], _calendar); fixingPeriodEndTimes[i] = TimeCalculatorBUS252.getTimeBetween(date, _fixingPeriodDates[i + 1], _calendar); } final CouponONCompounded cpn = new CouponONCompounded(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), _index, fixingPeriodStartTimes, fixingPeriodEndTimes, _fixingPeriodAccrualFactors, getNotional()); return cpn; } CouponONCompoundedDefinition(final Currency currency, final ZonedDateTime paymentDate, final ZonedDateTime accrualStartDate, final ZonedDateTime accrualEndDate,
      final double paymentYearFraction, final double notional, final IndexON index, final ZonedDateTime fixingPeriodStartDate, final ZonedDateTime fixingPeriodEndDate,
      final Calendar calendar); static CouponONCompoundedDefinition from(final IndexON index, final ZonedDateTime settlementDate, final Period tenor, final double notional, final int settlementDays,
      final BusinessDayConvention businessDayConvention, final boolean isEOM, final Calendar calendar); static CouponONCompoundedDefinition from(final IndexON index, final ZonedDateTime settlementDate, final ZonedDateTime fixingPeriodEndDate, final double notional,
      final int settlementDays, final Calendar calendar); static CouponONCompoundedDefinition from(final GeneratorSwapFixedCompoundedONCompounded generator, final ZonedDateTime settlementDate, final Period tenor, final double notional); static CouponONCompoundedDefinition from(final GeneratorSwapFixedCompoundedONCompounded generator, final ZonedDateTime settlementDate, final ZonedDateTime fixingPeriodEndDate,
      final double notional); IndexON getIndex(); Calendar getCalendar(); ZonedDateTime[] getFixingPeriodDates(); double[] getFixingPeriodAccrualFactors(); @Override CouponONCompounded toDerivative(final ZonedDateTime date); @Override Coupon toDerivative(final ZonedDateTime valZdt, final DoubleTimeSeries<ZonedDateTime> indexFixingTimeSeries); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void toDerivativeAfterPayment() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 9, 20); final double fixingRate = 0.01; final DoubleTimeSeries<ZonedDateTime> fixingTS = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2011, 9, 7), DateUtils.getUTCDate(2011, 9, 8), DateUtils.getUTCDate(2011, 9, 9), DateUtils.getUTCDate(2011, 9, 12), DateUtils.getUTCDate(2011, 9, 13), DateUtils.getUTCDate(2011, 9, 14), DateUtils.getUTCDate(2011, 9, 15) }, new double[] { fixingRate, fixingRate, fixingRate, fixingRate, fixingRate, fixingRate, fixingRate }); ON_COMPOUNDED_COUPON_DEFINITION.toDerivative(referenceDate, fixingTS); }