@Test public void closesTradesWhenTakeProfitIsBetweenOpenAndClosePrice() { testOrder.setCloseConditions(testCloseConditions.setTakeProfit(new Price(100))); openPendingOrder(); testCandleStick.setOpen(new Price(90)).setClose(new Price(110)); cut.newData(testCandleStick.toImmutableFullMarketData()); verify(orderEventListener).orderClosed(testTime, new Price(100)); }
@Override public void newData(final C candleStick) { final Iterator<Order> it = orders.iterator(); while (it.hasNext()) { final Order order = it.next(); if (order.opened) { if (order.type == BUY) { checkClosingBuyOrder(order, candleStick, it); } else { checkClosingSellOrder(order, candleStick, it); } } else { if (order.type == BUY) { checkOpeningBuyOrder(order, candleStick); } else { checkOpeningSellOrder(order, candleStick); } } } }
SimulatedBroker implements Broker<BasicPendingOrder>, MarketDataListener<C> { @Override public void newData(final C candleStick) { final Iterator<Order> it = orders.iterator(); while (it.hasNext()) { final Order order = it.next(); if (order.opened) { if (order.type == BUY) { checkClosingBuyOrder(order, candleStick, it); } else { checkClosingSellOrder(order, candleStick, it); } } else { if (order.type == BUY) { checkOpeningBuyOrder(order, candleStick); } else { checkOpeningSellOrder(order, candleStick); } } } } }
SimulatedBroker implements Broker<BasicPendingOrder>, MarketDataListener<C> { @Override public void newData(final C candleStick) { final Iterator<Order> it = orders.iterator(); while (it.hasNext()) { final Order order = it.next(); if (order.opened) { if (order.type == BUY) { checkClosingBuyOrder(order, candleStick, it); } else { checkClosingSellOrder(order, candleStick, it); } } else { if (order.type == BUY) { checkOpeningBuyOrder(order, candleStick); } else { checkOpeningSellOrder(order, candleStick); } } } }  }
SimulatedBroker implements Broker<BasicPendingOrder>, MarketDataListener<C> { @Override public void newData(final C candleStick) { final Iterator<Order> it = orders.iterator(); while (it.hasNext()) { final Order order = it.next(); if (order.opened) { if (order.type == BUY) { checkClosingBuyOrder(order, candleStick, it); } else { checkClosingSellOrder(order, candleStick, it); } } else { if (order.type == BUY) { checkOpeningBuyOrder(order, candleStick); } else { checkOpeningSellOrder(order, candleStick); } } } }  @Override OrderManagement sendOrder(final BasicPendingOrder order,
            final OrderEventListener eventListener); @Override void newData(final C candleStick); }
SimulatedBroker implements Broker<BasicPendingOrder>, MarketDataListener<C> { @Override public void newData(final C candleStick) { final Iterator<Order> it = orders.iterator(); while (it.hasNext()) { final Order order = it.next(); if (order.opened) { if (order.type == BUY) { checkClosingBuyOrder(order, candleStick, it); } else { checkClosingSellOrder(order, candleStick, it); } } else { if (order.type == BUY) { checkOpeningBuyOrder(order, candleStick); } else { checkOpeningSellOrder(order, candleStick); } } } }  @Override OrderManagement sendOrder(final BasicPendingOrder order,
            final OrderEventListener eventListener); @Override void newData(final C candleStick);  }