public void processStreamEvent(StreamEvent streamEvent) {
if (streamEvent instanceof TimeStreamEvent) {
currentExchangeTime = ((TimeStreamEvent) streamEvent).getTimeStamp();
}
if (streamEvent instanceof BBOEvent) {
BBOEvent nbbo = (BBOEvent) streamEvent;
String instId = nbbo.getTradeableInstrumentId();
// weed out non-tradeable market data.
if (instId == null)
return;
LimitOrderBook lob = getOrderBook(instId);
// clear out limit order book except our own orders.
lob.weedOutForeignOrders();
if (nbbo.getBid() != null) {
LimitOrder bestBid = new LimitOrder();
bestBid.setOrderSide(OrderSide.BUY);
bestBid.setLimitPrice(nbbo.getBid());
bestBid.setQuantity(nbbo.getBidQuantity());
bestBid.setOpenQuantity(bestBid.getQuantity());
lob.addOrder(bestBid);
}
if (nbbo.getAsk() != null) {
LimitOrder bestAsk = new LimitOrder();
bestAsk.setOrderSide(OrderSide.SELL);
bestAsk.setLimitPrice(nbbo.getAsk());
bestAsk.setQuantity(nbbo.getAskQuantity());
bestAsk.setOpenQuantity(bestAsk.getQuantity());
lob.addOrder(bestAsk);
}
// rerun a match.