@Test public void doesNotChangeOrderWhenPricesDontChange() { final Optional<Order> manageBuyOrder = cut.manageOrder(exemplaryBuyOrder, eventListener); assertThat(manageBuyOrder).contains(exemplaryBuyOrder); verifyNoMoreInteractions(broker); }
public Optional<Order> manageOrder(final Order order, final OrderEventListener eventListener) { if (strategy.getTrend().isPresent()) { final MarketDirection trend = strategy.getTrend().get(); if (trend == UP && order.getPendingOrder().getType() == SELL) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } else if (trend == DOWN && order.getPendingOrder().getType() == BUY) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } } if (stopLooseDifferent(order.getPendingOrder()) || entryPriceDifferent(order.getPendingOrder())) { order.getOrderManagement().closeOrCancelOrder(); return openUpdatedPendingOrder(order.getPendingOrder(), eventListener); } return Optional.of(order); }
PendingOrderManager { public Optional<Order> manageOrder(final Order order, final OrderEventListener eventListener) { if (strategy.getTrend().isPresent()) { final MarketDirection trend = strategy.getTrend().get(); if (trend == UP && order.getPendingOrder().getType() == SELL) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } else if (trend == DOWN && order.getPendingOrder().getType() == BUY) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } } if (stopLooseDifferent(order.getPendingOrder()) || entryPriceDifferent(order.getPendingOrder())) { order.getOrderManagement().closeOrCancelOrder(); return openUpdatedPendingOrder(order.getPendingOrder(), eventListener); } return Optional.of(order); } }
PendingOrderManager { public Optional<Order> manageOrder(final Order order, final OrderEventListener eventListener) { if (strategy.getTrend().isPresent()) { final MarketDirection trend = strategy.getTrend().get(); if (trend == UP && order.getPendingOrder().getType() == SELL) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } else if (trend == DOWN && order.getPendingOrder().getType() == BUY) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } } if (stopLooseDifferent(order.getPendingOrder()) || entryPriceDifferent(order.getPendingOrder())) { order.getOrderManagement().closeOrCancelOrder(); return openUpdatedPendingOrder(order.getPendingOrder(), eventListener); } return Optional.of(order); } PendingOrderManager(final TradingStrategy<?> strategy, final Broker<BasicPendingOrder> broker); }
PendingOrderManager { public Optional<Order> manageOrder(final Order order, final OrderEventListener eventListener) { if (strategy.getTrend().isPresent()) { final MarketDirection trend = strategy.getTrend().get(); if (trend == UP && order.getPendingOrder().getType() == SELL) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } else if (trend == DOWN && order.getPendingOrder().getType() == BUY) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } } if (stopLooseDifferent(order.getPendingOrder()) || entryPriceDifferent(order.getPendingOrder())) { order.getOrderManagement().closeOrCancelOrder(); return openUpdatedPendingOrder(order.getPendingOrder(), eventListener); } return Optional.of(order); } PendingOrderManager(final TradingStrategy<?> strategy, final Broker<BasicPendingOrder> broker); Optional<Order> manageOrder(final Order order, final OrderEventListener eventListener); }
PendingOrderManager { public Optional<Order> manageOrder(final Order order, final OrderEventListener eventListener) { if (strategy.getTrend().isPresent()) { final MarketDirection trend = strategy.getTrend().get(); if (trend == UP && order.getPendingOrder().getType() == SELL) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } else if (trend == DOWN && order.getPendingOrder().getType() == BUY) { order.getOrderManagement().closeOrCancelOrder(); return Optional.empty(); } } if (stopLooseDifferent(order.getPendingOrder()) || entryPriceDifferent(order.getPendingOrder())) { order.getOrderManagement().closeOrCancelOrder(); return openUpdatedPendingOrder(order.getPendingOrder(), eventListener); } return Optional.of(order); } PendingOrderManager(final TradingStrategy<?> strategy, final Broker<BasicPendingOrder> broker); Optional<Order> manageOrder(final Order order, final OrderEventListener eventListener);  }