private void runSimulator()

in simulator/src/main/java/com/google/cloud/App.java [122:147]


  private void runSimulator() throws Exception {
    try (EventConsumer eventConsumer = buildConsumer()) {

      OrderBookBuilder obb = new OrderBookBuilder();
      Iterator<List<OrderBookEvent>> it = buildSimulator();

      while (it.hasNext()) {
        for (OrderBookEvent orderBookEvent : it.next()) {

          // Publish the order book event
          eventConsumer.accept(orderBookEvent);

          // Modify the orderbook
          obb.processEvent(orderBookEvent);

          // Produce the latest MarketDepth
          MarketDepth marketDepth = obb.getCurrentMarketDepth(depth, true);

          // If there's anything new in the MarketDepth, then publish the market depth
          if (marketDepth != null) {
            eventConsumer.accept(marketDepth);
          }
        }
      }
    }
  }