FederalFundsFutureSecurityDefinition extends FuturesSecurityDefinition<FederalFundsFutureSecurity> implements InstrumentDefinitionWithData<FederalFundsFutureSecurity, DoubleTimeSeries<ZonedDateTime>> { @Override public FederalFundsFutureSecurity toDerivative(final ZonedDateTime date) { ArgumentChecker.notNull(date, "Date"); ArgumentChecker.isTrue(!date.isAfter(_fixingPeriodDates[_index.getPublicationLag()]), "Date should not be after the fixing period start date"); final double lastTradingTime = TimeCalculator.getTimeBetween(date, getLastTradingDate()); final double[] fixingPeriodTime = TimeCalculator.getTimeBetween(date, _fixingPeriodDates); return new FederalFundsFutureSecurity(_index, 0.0, fixingPeriodTime, lastTradingTime, _fixingPeriodAccrualFactor, _fixingTotalAccrualFactor, _notional, _marginAccrualFactor, _name); } FederalFundsFutureSecurityDefinition(final ZonedDateTime lastTradingDate, final IndexON index, final ZonedDateTime[] fixingPeriodDate,
      final double[] fixingPeriodAccrualFactor, final double notional, final double paymentAccrualFactor, final String name); static FederalFundsFutureSecurityDefinition from(final ZonedDateTime monthDate, final IndexON index, final double notional, final double paymentAccrualFactor,
      final String name, final Calendar calendar); static FederalFundsFutureSecurityDefinition fromFedFund(final ZonedDateTime monthDate, final IndexON index, final Calendar calendar); IndexON getIndex(); ZonedDateTime[] getFixingPeriodDate(); double[] getFixingPeriodAccrualFactor(); double getFixingTotalAccrualFactor(); double getNotional(); double getMarginAccrualFactor(); String getName(); Currency getCurrency(); @Override String toString(); @Override FederalFundsFutureSecurity toDerivative(final ZonedDateTime date); @Override FederalFundsFutureSecurity 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 int hashCode(); @Override boolean equals(Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void toDerivativeAfterStartFixing() { FUTURE_FEDFUND_DEFINITION.toDerivative(ScheduleCalculator.getAdjustedDate(FIXING_DATE[0], 2, NYC)); }
@Test public void toDerivativeFirstDaymonth() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2012, 3, 1); final DoubleTimeSeries<ZonedDateTime> fixingTS = ImmutableZonedDateTimeDoubleTimeSeries.of(DateUtils.getUTCDate(2012, 3, 1), 0.0010); final FederalFundsFutureSecurity futureFedFundExpected = FUTURE_FEDFUND_DEFINITION.toDerivative(referenceDate); final FederalFundsFutureSecurity futureFedFundConverted = FUTURE_FEDFUND_DEFINITION.toDerivative(referenceDate, fixingTS); assertEquals("Fed fund future security definition: toDerivative", futureFedFundExpected, futureFedFundConverted); }
@Test public void toDerivativeSecondDayMonthNoFixing() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2012, 3, 2); final DoubleTimeSeries<ZonedDateTime> fixingTS = ImmutableZonedDateTimeDoubleTimeSeries.of(DateUtils.getUTCDate(2012, 2, 29), 0.0010); final FederalFundsFutureSecurity futureFedFundExpected = FUTURE_FEDFUND_DEFINITION.toDerivative(referenceDate); final FederalFundsFutureSecurity futureFedFundConverted = FUTURE_FEDFUND_DEFINITION.toDerivative(referenceDate, fixingTS); assertEquals("Fed fund future security definition: toDerivative", futureFedFundExpected, futureFedFundConverted); }