InterestRateFutureOptionPremiumTransactionDefinition implements InstrumentDefinition<InterestRateFutureOptionPremiumTransaction> { @Override public InterestRateFutureOptionPremiumTransaction toDerivative(final ZonedDateTime date) { final InterestRateFutureOptionPremiumSecurity option = _underlyingOption.toDerivative(date); final double premiumTime = TimeCalculator.getTimeBetween(date, _premium.getPaymentDate()); if (premiumTime < 0) { return new InterestRateFutureOptionPremiumTransaction(option, _quantity, 0.0, 0.0); } return new InterestRateFutureOptionPremiumTransaction(option, _quantity, premiumTime, _tradePrice); } InterestRateFutureOptionPremiumTransactionDefinition(final InterestRateFutureOptionPremiumSecurityDefinition underlyingOption, final int quantity,
      final ZonedDateTime premiumDate, final double tradePrice); InterestRateFutureOptionPremiumSecurityDefinition getUnderlyingOption(); int getQuantity(); double getTradePrice(); PaymentFixedDefinition getPremium(); @Override InterestRateFutureOptionPremiumTransaction 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 toDerivativeBeforeSettlement() { final InterestRateFutureOptionPremiumTransaction transactionConverted = OPTION_TRANSACTION.toDerivative(REFERENCE_DATE); final InterestRateFutureOptionPremiumSecurity security = OPTION_EDU2.toDerivative(REFERENCE_DATE); final double premiumTime = TimeCalculator.getTimeBetween(REFERENCE_DATE, PREMIUM_DATE); final InterestRateFutureOptionPremiumTransaction transaction = new InterestRateFutureOptionPremiumTransaction(security, QUANTITY, premiumTime, TRADE_PRICE); assertEquals("Option on future: to derivative", transaction, transactionConverted); }
@Test public void toDerivativeOnSettlement() { final ZonedDateTime referenceDate = PREMIUM_DATE; final InterestRateFutureOptionPremiumTransaction transactionConverted = OPTION_TRANSACTION.toDerivative(referenceDate); final InterestRateFutureOptionPremiumSecurity security = OPTION_EDU2.toDerivative(referenceDate); final double premiumTime = 0.0; final InterestRateFutureOptionPremiumTransaction transaction = new InterestRateFutureOptionPremiumTransaction(security, QUANTITY, premiumTime, TRADE_PRICE); assertEquals("Option on future: to derivative", transaction, transactionConverted); }
@Test public void toDerivativeAfterSettlement() { final ZonedDateTime referenceDate = PREMIUM_DATE.plusDays(1); final InterestRateFutureOptionPremiumTransaction transactionConverted = OPTION_TRANSACTION.toDerivative(referenceDate); final InterestRateFutureOptionPremiumSecurity security = OPTION_EDU2.toDerivative(referenceDate); final double premiumTime = 0.0; final double price = 0.0; final InterestRateFutureOptionPremiumTransaction transaction = new InterestRateFutureOptionPremiumTransaction(security, QUANTITY, premiumTime, price); assertEquals("Option on future: to derivative", transaction, transactionConverted); }