SwapFuturesPriceDeliverableTransactionDefinition extends FuturesTransactionDefinition<SwapFuturesPriceDeliverableSecurityDefinition> implements InstrumentDefinitionWithData<SwapFuturesPriceDeliverableTransaction, Double> { @Override public SwapFuturesPriceDeliverableTransaction toDerivative(final ZonedDateTime dateTime, final Double lastMarginPrice) { final double referencePrice = referencePrice(dateTime, lastMarginPrice); final SwapFuturesPriceDeliverableSecurity underlying = getUnderlyingSecurity().toDerivative(dateTime); final SwapFuturesPriceDeliverableTransaction future = new SwapFuturesPriceDeliverableTransaction(underlying, referencePrice, getQuantity()); return future; } SwapFuturesPriceDeliverableTransactionDefinition(final SwapFuturesPriceDeliverableSecurityDefinition underlyingFuture, final long quantity,
      final ZonedDateTime tradeDate, final double tradePrice); @Override SwapFuturesPriceDeliverableTransaction toDerivative(final ZonedDateTime dateTime, final Double lastMarginPrice); @Override SwapFuturesPriceDeliverableTransaction toDerivative(final ZonedDateTime date); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor);  }
@Test public void toDerivativeOnTradeDate() { final ZonedDateTime referenceDate = TRAN_DATE; final double lastMargin = 0.99 + 1.0 / 32.0 / 100.0; final SwapFuturesPriceDeliverableSecurity underlying = SWAP_FUTURES_SECURITY_DEFINITION.toDerivative(referenceDate); final SwapFuturesPriceDeliverableTransaction derivativeExpected = new SwapFuturesPriceDeliverableTransaction(underlying, TRAN_PRICE, QUANTITY); final SwapFuturesPriceDeliverableTransaction derivativeConverted = SWAP_FUTURES_TRANSACTION_DEFINITION.toDerivative(referenceDate, lastMargin); assertEquals("DeliverableSwapFuturesTransactionDefinition: toDerivative", derivativeExpected, derivativeConverted); }
@Test public void toDerivativeAfterTradeDate() { final ZonedDateTime referenceDate = ScheduleCalculator.getAdjustedDate(TRAN_DATE, 1, NYC); final double lastMargin = 0.99080; final SwapFuturesPriceDeliverableSecurity underlying = SWAP_FUTURES_SECURITY_DEFINITION.toDerivative(referenceDate); final SwapFuturesPriceDeliverableTransaction derivativeExpected = new SwapFuturesPriceDeliverableTransaction(underlying, lastMargin, QUANTITY); final SwapFuturesPriceDeliverableTransaction derivativeConverted = SWAP_FUTURES_TRANSACTION_DEFINITION.toDerivative(referenceDate, lastMargin); assertEquals("DeliverableSwapFuturesTransactionDefinition: toDerivative", derivativeExpected, derivativeConverted); }