@Test public void managesNewPendingOrderWhenPendingOrderChanged() { when(orderManager.manageOrder(exemplaryOrder1, cut)).thenReturn(Optional.of(exemplaryOrder2)); cut.newData(EXEMPLARY_CANDLE_STICK); cut.newData(EXEMPLARY_CANDLE_STICK); cut.newData(EXEMPLARY_CANDLE_STICK); final InOrder inOrder = inOrder(creator, orderManager); inOrder.verify(creator).checkMarketEntry(cut); inOrder.verify(orderManager).manageOrder(exemplaryOrder1, cut); inOrder.verify(orderManager).manageOrder(exemplaryOrder2, cut); verifyNoMoreInteractions(creator, orderManager, tradeManager); }
@Override public void newData(final C candleStick) { strategy.update(candleStick); switch (currentState) { case TRY_CREATE: currentOrder = creator.checkMarketEntry(this); if (currentOrder.isPresent()) { currentState = State.MANAGE_ORDER; } break; case MANAGE_ORDER: currentOrder = orderManager.manageOrder(currentOrder.get(), this); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; case MANAGE_TRADE: currentOrder = tradeManager.manageTrade(currentOrder.get()); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; default: throw new IllegalStateException("Unhandled state " + currentState); } }
StrategyExpertAdvisor implements ExpertAdvisor<C>, OrderEventListener { @Override public void newData(final C candleStick) { strategy.update(candleStick); switch (currentState) { case TRY_CREATE: currentOrder = creator.checkMarketEntry(this); if (currentOrder.isPresent()) { currentState = State.MANAGE_ORDER; } break; case MANAGE_ORDER: currentOrder = orderManager.manageOrder(currentOrder.get(), this); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; case MANAGE_TRADE: currentOrder = tradeManager.manageTrade(currentOrder.get()); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; default: throw new IllegalStateException("Unhandled state " + currentState); } } }
StrategyExpertAdvisor implements ExpertAdvisor<C>, OrderEventListener { @Override public void newData(final C candleStick) { strategy.update(candleStick); switch (currentState) { case TRY_CREATE: currentOrder = creator.checkMarketEntry(this); if (currentOrder.isPresent()) { currentState = State.MANAGE_ORDER; } break; case MANAGE_ORDER: currentOrder = orderManager.manageOrder(currentOrder.get(), this); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; case MANAGE_TRADE: currentOrder = tradeManager.manageTrade(currentOrder.get()); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; default: throw new IllegalStateException("Unhandled state " + currentState); } } StrategyExpertAdvisor(final TradingStrategy<C> strategy, final Broker<BasicPendingOrder> broker);   StrategyExpertAdvisor(final TradingStrategy<C> strategy, final PendingOrderCreator creator,
            final PendingOrderManager orderManager, final TradeManager tradeManager); }
StrategyExpertAdvisor implements ExpertAdvisor<C>, OrderEventListener { @Override public void newData(final C candleStick) { strategy.update(candleStick); switch (currentState) { case TRY_CREATE: currentOrder = creator.checkMarketEntry(this); if (currentOrder.isPresent()) { currentState = State.MANAGE_ORDER; } break; case MANAGE_ORDER: currentOrder = orderManager.manageOrder(currentOrder.get(), this); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; case MANAGE_TRADE: currentOrder = tradeManager.manageTrade(currentOrder.get()); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; default: throw new IllegalStateException("Unhandled state " + currentState); } } StrategyExpertAdvisor(final TradingStrategy<C> strategy, final Broker<BasicPendingOrder> broker);   StrategyExpertAdvisor(final TradingStrategy<C> strategy, final PendingOrderCreator creator,
            final PendingOrderManager orderManager, final TradeManager tradeManager); @Override void newData(final C candleStick); @Override void orderRejected(final Failed failure); @Override void orderOpened(final Instant time, final Price price); @Override void orderClosed(final Instant time, final Price price); }
StrategyExpertAdvisor implements ExpertAdvisor<C>, OrderEventListener { @Override public void newData(final C candleStick) { strategy.update(candleStick); switch (currentState) { case TRY_CREATE: currentOrder = creator.checkMarketEntry(this); if (currentOrder.isPresent()) { currentState = State.MANAGE_ORDER; } break; case MANAGE_ORDER: currentOrder = orderManager.manageOrder(currentOrder.get(), this); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; case MANAGE_TRADE: currentOrder = tradeManager.manageTrade(currentOrder.get()); if (!currentOrder.isPresent()) { currentState = State.TRY_CREATE; } break; default: throw new IllegalStateException("Unhandled state " + currentState); } } StrategyExpertAdvisor(final TradingStrategy<C> strategy, final Broker<BasicPendingOrder> broker);   StrategyExpertAdvisor(final TradingStrategy<C> strategy, final PendingOrderCreator creator,
            final PendingOrderManager orderManager, final TradeManager tradeManager); @Override void newData(final C candleStick); @Override void orderRejected(final Failed failure); @Override void orderOpened(final Instant time, final Price price); @Override void orderClosed(final Instant time, final Price price);  }