InterestRateFutureOptionMarginSecurityDefinition extends FuturesSecurityDefinition<InterestRateFutureOptionMarginSecurity> { @Override public InterestRateFutureOptionMarginSecurity toDerivative(final ZonedDateTime date) { ArgumentChecker.notNull(date, "date"); final double expirationTime = TimeCalculator.getTimeBetween(date, _expirationDate); final InterestRateFutureSecurity underlyingFuture = _underlyingFuture.toDerivative(date); final InterestRateFutureOptionMarginSecurity option = new InterestRateFutureOptionMarginSecurity(underlyingFuture, expirationTime, _strike, _isCall); return option; } InterestRateFutureOptionMarginSecurityDefinition(final InterestRateFutureSecurityDefinition underlyingFuture, final ZonedDateTime expirationDate, final double strike, final boolean isCall); InterestRateFutureSecurityDefinition getUnderlyingFuture(); ZonedDateTime getExpirationDate(); boolean isCall(); double getStrike(); @Override InterestRateFutureOptionMarginSecurity toDerivative(final ZonedDateTime date); @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 double expirationTime = TimeCalculator.getTimeBetween(REFERENCE_DATE, EXPIRATION_DATE); final InterestRateFutureSecurity underlyingFuture = ERU2.toDerivative(REFERENCE_DATE); final InterestRateFutureOptionMarginSecurity security = new InterestRateFutureOptionMarginSecurity(underlyingFuture, expirationTime, STRIKE, IS_CALL); final InterestRateFutureOptionMarginSecurity convertedSecurity = OPTION_ERU2.toDerivative(REFERENCE_DATE); assertTrue("Rate future option with margining security converter", security.equals(convertedSecurity)); }