@Test public void partialAskFill() { book.enter(1, Side.SELL, 1000, 100); book.enter(2, Side.BUY, 1000, 50); book.enter(3, Side.BUY, 1000, 50); book.enter(4, Side.BUY, 1000, 50); Event ask = new Add(1, Side.SELL, 1000, 100); Event firstMatch = new Match(1, 2, Side.BUY, 1000, 50, 50); Event secondMatch = new Match(1, 3, Side.BUY, 1000, 50, 0); Event bid = new Add(4, Side.BUY, 1000, 50); assertEquals(asList(ask, firstMatch, secondMatch, bid), events.collect()); }
public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; if (side == Side.BUY) buy(orderId, price, size); else sell(orderId, price, size); }
OrderBook { public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; if (side == Side.BUY) buy(orderId, price, size); else sell(orderId, price, size); } }
OrderBook { public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; if (side == Side.BUY) buy(orderId, price, size); else sell(orderId, price, size); } OrderBook(OrderBookListener listener); }
OrderBook { public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; if (side == Side.BUY) buy(orderId, price, size); else sell(orderId, price, size); } OrderBook(OrderBookListener listener); void enter(long orderId, Side side, long price, long size); void cancel(long orderId, long size); }
OrderBook { public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; if (side == Side.BUY) buy(orderId, price, size); else sell(orderId, price, size); } OrderBook(OrderBookListener listener); void enter(long orderId, Side side, long price, long size); void cancel(long orderId, long size);  }