@Test public void triesToCreateNewPendingOrdersWhenNoOrderIsActive() { cut.newData(EXEMPLARY_CANDLE_STICK); verify(creator).checkMarketEntry(cut); }
@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);  }