InterestRateFutureOptionPremiumSecurityDefinition implements InstrumentDefinition<InterestRateFutureOptionPremiumSecurity> { @Override public InterestRateFutureOptionPremiumSecurity toDerivative(final ZonedDateTime date) { ArgumentChecker.isTrue(!date.isAfter(_expirationDate), "Date is after expiration date"); final InterestRateFutureSecurity underlyingFuture = _underlyingFuture.toDerivative(date); final double expirationTime = TimeCalculator.getTimeBetween(date, _expirationDate); return new InterestRateFutureOptionPremiumSecurity(underlyingFuture, expirationTime, _strike, _isCall); } InterestRateFutureOptionPremiumSecurityDefinition(final InterestRateFutureSecurityDefinition underlyingFuture, final ZonedDateTime expirationDate, final double strike, final boolean isCall); InterestRateFutureSecurityDefinition getUnderlyingFuture(); ZonedDateTime getExpirationDate(); boolean isCall(); double getStrike(); Currency getCurrency(); @Override InterestRateFutureOptionPremiumSecurity 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 InterestRateFutureOptionPremiumSecurity optionEDU2Converted = OPTION_EDU2_DEFINITION.toDerivative(REFERENCE_DATE); final InterestRateFutureSecurity future = EDU2_DEFINITION.toDerivative(REFERENCE_DATE); final double expirationTime = ACT_ACT.getDayCountFraction(REFERENCE_DATE, EXPIRATION_DATE); final InterestRateFutureOptionPremiumSecurity optionEDU2 = new InterestRateFutureOptionPremiumSecurity(future, expirationTime, STRIKE, IS_CALL); assertEquals("Option on future: to derivative", optionEDU2, optionEDU2Converted); }
@Test(expectedExceptions = IllegalArgumentException.class) public void dateAfterExpiration() { OPTION_EDU2_DEFINITION.toDerivative(EXPIRATION_DATE.plusDays(1)); }