InterestRateFutureOptionMarginTransactionDefinition extends FuturesTransactionDefinition<InterestRateFutureOptionMarginSecurityDefinition> implements InstrumentDefinitionWithData<InterestRateFutureOptionMarginTransaction, Double> { @Override public InterestRateFutureOptionMarginTransaction toDerivative(final ZonedDateTime date) { throw new UnsupportedOperationException("The method toDerivative of InterestRateTransactionDefinition does not support the two argument method (without margin price data)."); } InterestRateFutureOptionMarginTransactionDefinition(final InterestRateFutureOptionMarginSecurityDefinition underlyingOption, final long quantity,
      final ZonedDateTime tradeDate, final double tradePrice); @Override InterestRateFutureOptionMarginTransaction toDerivative(final ZonedDateTime date); @Override InterestRateFutureOptionMarginTransaction toDerivative(final ZonedDateTime dateTime, final Double lastMarginPrice); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor);  }
@Test public void toDerivativeTradeInPast() { final InterestRateFutureOptionMarginSecurity securityConverted = OPTION_ERU2.toDerivative(REFERENCE_DATE); final double lastMarginPrice = 0.99; final InterestRateFutureOptionMarginTransaction transactionConverted = OPTION_TRANSACTION.toDerivative(REFERENCE_DATE, lastMarginPrice); final InterestRateFutureOptionMarginTransaction transaction = new InterestRateFutureOptionMarginTransaction(securityConverted, QUANTITY, lastMarginPrice); assertTrue("Conversion with trade date in the past", transactionConverted.equals(transaction)); }
@Test public void toDerivativeTradeToday() { final ZonedDateTime referenceDate = TRADE_DATE; final InterestRateFutureOptionMarginSecurity securityConverted = OPTION_ERU2.toDerivative(referenceDate); final double lastMarginPrice = 0.99; final InterestRateFutureOptionMarginTransaction transactionConverted = OPTION_TRANSACTION.toDerivative(referenceDate, lastMarginPrice); final InterestRateFutureOptionMarginTransaction transaction = new InterestRateFutureOptionMarginTransaction(securityConverted, QUANTITY, TRADE_PRICE); assertTrue("Conversion with trade date in the past", transactionConverted.equals(transaction)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void toDerivativeTradeFuture() { final ZonedDateTime referenceDate = ScheduleCalculator.getAdjustedDate(TRADE_DATE, -1, CALENDAR); final double lastMarginPrice = 0.99; OPTION_TRANSACTION.toDerivative(referenceDate, lastMarginPrice); }