EODTradingStrategy implements Level1QuoteListener, OrderEventListener, BrokerErrorListener { public void start(String propFile) { initProps(propFile); ibClient = InteractiveBrokersClient.getInstance(ibHost, ibPort, ibClientId); logger.info( "Connecting to IB client at:" + ibHost + ":" + ibPort + " with clientID: " + ibClientId); reportGenerator = getReportGenerator(strategyDirectory); ibClient.addOrderStatusListener(this); ibClient.addOrderStatusListener(reportGenerator); ibClient.connect(); List<TradeOrder> openOrders = ibClient.getOpenOrders(); logger.debug("Found " + openOrders.size() + " open orders"); ordersPlaced = checkOpenOrders(openOrders, longShortPairMap); logger.info("Checking if orders have already been placed today: " + ordersPlaced ); logger.info( "Strategy will place orders after: " + timeToPlaceOrders.toString()); longShortPairMap.keySet().stream().map((ticker) -> { ibClient.subscribeLevel1(ticker, this); logger.info("Subscribing to: " + ticker); return ticker; }).forEach((ticker) -> { logger.info("Subscribing to: " + longShortPairMap.get(ticker)); ibClient.subscribeLevel1(longShortPairMap.get(ticker), this); }); }  void start(String propFile); synchronized void placeMOCOrders(Ticker longTicker, Ticker shortTicker, ZonedDateTime lastReportedTime); @Override void orderEvent(OrderEvent event); @Override void quoteRecieved(ILevel1Quote quote); ZonedDateTime getNextBusinessDay(ZonedDateTime date); @Override void brokerErrorFired(BrokerError error); static void main(String[] args);  }
@Test public void testStart() { TradeOrder order = new TradeOrder("123", longTicker, 100, TradeDirection.SELL); List<TradeOrder> openOrders = new ArrayList<>(); openOrders.add(order); when(mockIbClient.getOpenOrders()).thenReturn(openOrders); doReturn(true).when(strategy).checkOpenOrders(openOrders, strategy.longShortPairMap); strategy.start(propFile); verify(mockIbClient).addOrderStatusListener(mockReportGenerator); verify(mockIbClient).subscribeLevel1(eq(new StockTicker("QQQ")), any(Level1QuoteListener.class)); verify(mockIbClient).subscribeLevel1(eq(new StockTicker("SPY")), any(Level1QuoteListener.class)); verify(mockIbClient).subscribeLevel1(eq(new StockTicker("DIA")), any(Level1QuoteListener.class)); verify(mockIbClient).subscribeLevel1(eq(new StockTicker("IWM")), any(Level1QuoteListener.class)); }