BondFutureDefinition implements InstrumentDefinitionWithData<BondFuture, Double> { @Override public BondFuture toDerivative(final ZonedDateTime date) { throw new UnsupportedOperationException("The method toDerivative of " + getClass().getSimpleName() + " does not support the two argument method (without margin price data)."); } BondFutureDefinition(final ZonedDateTime tradingLastDate, final ZonedDateTime noticeFirstDate, final ZonedDateTime noticeLastDate, final double notional,
      final BondFixedSecurityDefinition[] deliveryBasket, final double[] conversionFactor); ZonedDateTime getTradingLastDate(); ZonedDateTime getNoticeFirstDate(); ZonedDateTime getNoticeLastDate(); ZonedDateTime getDeliveryFirstDate(); ZonedDateTime getDeliveryLastDate(); int getSettlementDays(); double getNotional(); BondFixedSecurityDefinition[] getDeliveryBasket(); double[] getConversionFactor(); Currency getCurrency(); @Override BondFuture toDerivative(final ZonedDateTime date); @Override BondFuture toDerivative(final ZonedDateTime valDate, final Double referencePrice); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void toDerivative() { final ZonedDateTime firstDeliveryDate = ScheduleCalculator.getAdjustedDate(FIRST_NOTICE_DATE, SETTLEMENT_DAYS, CALENDAR); final ZonedDateTime lastDeliveryDate = ScheduleCalculator.getAdjustedDate(LAST_NOTICE_DATE, SETTLEMENT_DAYS, CALENDAR); final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 6, 17); final DayCount actAct = DayCounts.ACT_ACT_ISDA; final double lastTradingTime = actAct.getDayCountFraction(referenceDate, LAST_TRADING_DATE); final double firstNoticeTime = actAct.getDayCountFraction(referenceDate, FIRST_NOTICE_DATE); final double lastNoticeTime = actAct.getDayCountFraction(referenceDate, LAST_NOTICE_DATE); final double firstDeliveryTime = actAct.getDayCountFraction(referenceDate, firstDeliveryDate); final double lastDeliveryTime = actAct.getDayCountFraction(referenceDate, lastDeliveryDate); final BondFixedSecurity[] basket = new BondFixedSecurity[NB_BOND]; for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) { basket[loopbasket] = BASKET_DEFINITION[loopbasket].toDerivative(referenceDate, lastDeliveryDate); } final BondFuture futureConverted = FUTURE_DEFINITION.toDerivative(referenceDate, REF_PRICE); final BondFuture futureExpected = new BondFuture(lastTradingTime, firstNoticeTime, lastNoticeTime, firstDeliveryTime, lastDeliveryTime, NOTIONAL, basket, CONVERSION_FACTOR, REF_PRICE); assertEquals("Bond future security definition: future conversion", futureExpected, futureConverted); }