EquityIndexFutureOptionDefinition implements InstrumentDefinition<EquityIndexFutureOption> { @Override public EquityIndexFutureOption toDerivative(final ZonedDateTime date) { ArgumentChecker.notNull(date, "date"); ArgumentChecker.inOrderOrEqual(date.toLocalDate(), _expiryDate.toLocalDate(), "valuation date", "expiry"); double timeToExpiry = TimeCalculator.getTimeBetween(date, getExpiryDate()); if (timeToExpiry == 0) { timeToExpiry = 0.0015; } double timeToFutureFixing = TimeCalculator.getTimeBetween(date, _underlying.getExpiryDate()); if (timeToFutureFixing == 0) { timeToFutureFixing = 0.0015; } double timeToFutureDelivery = TimeCalculator.getTimeBetween(date, _underlying.getSettlementDate()); if (timeToFutureDelivery == 0) { timeToFutureDelivery = 0.0015; } final double futureStrike = _underlying.getStrikePrice(); final Currency currency = _underlying.getCurrency(); final double unitValue = _underlying.getUnitAmount(); final EquityIndexFuture underlying = new EquityIndexFuture(timeToFutureFixing, timeToFutureDelivery, futureStrike, currency, unitValue); return new EquityIndexFutureOption(timeToExpiry, underlying, _strike, _exerciseType, _isCall, _pointValue, _referencePrice); } EquityIndexFutureOptionDefinition(final ZonedDateTime expiryDate, final IndexFutureDefinition underlying, final double strike, final ExerciseDecisionType exerciseType,
      final boolean isCall, final double pointValue, double referencePrice); ZonedDateTime getExpiryDate(); IndexFutureDefinition getUnderlying(); double getStrike(); ExerciseDecisionType getExerciseType(); boolean isCall(); double getPointValue(); double getReferencePrice(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override EquityIndexFutureOption toDerivative(final ZonedDateTime date); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullValuationDate() { AMERICAN_PUT.toDerivative(null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testValuationAfterExpiry() { AMERICAN_PUT.toDerivative(EXPIRY.plusDays(1)); }
@Test public void testToDerivative() { final ZonedDateTime valuationDate = EXPIRY.minusDays(10); final EquityIndexFutureOption derivative = AMERICAN_PUT.toDerivative(valuationDate); assertEquals(STRIKE, derivative.getStrike()); assertEquals(10. / 365, derivative.getExpiry()); assertEquals(13. / 365, derivative.getUnderlying().getTimeToSettlement()); assertEquals(POINT_VALUE, derivative.getPointValue()); assertEquals(IS_CALL, derivative.isCall()); assertEquals(CCY, derivative.getUnderlying().getCurrency()); assertEquals(EXERCISE, derivative.getExerciseType()); }