@Override protected final void applyTrade(MDEntry entry) { switch (entry.getMdUpdateAction()) { case New: case Change: _lastTradeQty = entry.getMdEntrySize(); _lastTradePrice = entry.getMdEntryPx(); _totalTradeVol += _lastTradeQty; _totalTraded += (_lastTradeQty * _lastTradePrice); break; case Delete: final int tradeQty = entry.getMdEntrySize(); final double tradePrice = entry.getMdEntryPx(); _totalTradeVol -= tradeQty; _totalTraded -= (tradeQty * tradePrice); break; case DeleteThru: case DeleteFrom: case Overlay: case Unknown: break; } }
@Override protected final void applyAsk(final MDEntry entry) { final int lvl = entry.getMdPriceLevel() - 1; switch (entry.getMdUpdateAction()) { case New: { _tmpEntry.set(entry.getMdEntrySize(), entry.getMdEntryPx()); _book.insertAsk(lvl, _tmpEntry); } break; case Change: { final double px = entry.getMdEntryPx(); if (px != Constants.UNSET_DOUBLE) { _tmpEntry.set(entry.getMdEntrySize(), px); _book.setAsk(lvl, _tmpEntry); } else { _book.setAskQty(lvl, entry.getMdEntrySize()); } } break; case Delete: { _book.deleteAsk(lvl); } break; case DeleteThru: _book.deleteThruAsk(lvl); break; case DeleteFrom: _book.deleteFromAsk(lvl); break; case Overlay: { final int qty = entry.getMdEntrySize(); if (qty != Constants.UNSET_INT) { _tmpEntry.set(qty, entry.getMdEntryPx()); _book.setAsk(lvl, _tmpEntry); } else { _book.setAskPrice(lvl, entry.getMdEntryPx()); } } break; case Unknown: break; } }
@Override protected final void applyBid(final MDEntry entry) { final int lvl = entry.getMdPriceLevel() - 1; switch (entry.getMdUpdateAction()) { case New: { _tmpEntry.set(entry.getMdEntrySize(), entry.getMdEntryPx()); _book.insertBid(lvl, _tmpEntry); } break; case Change: { // should be used ONLY for qty change, but CME use for price setting as well final double px = entry.getMdEntryPx(); if (px != Constants.UNSET_DOUBLE) { _tmpEntry.set(entry.getMdEntrySize(), px); _book.setBid(lvl, _tmpEntry); } else { _book.setBidQty(lvl, entry.getMdEntrySize()); } } break; case Delete: { _book.deleteBid(lvl); } break; case DeleteThru: _book.deleteThruBid(lvl); break; case DeleteFrom: _book.deleteFromBid(lvl); break; case Overlay: { final int qty = entry.getMdEntrySize(); if (qty != Constants.UNSET_INT) { _tmpEntry.set(qty, entry.getMdEntryPx()); _book.setBid(lvl, _tmpEntry); } else { _book.setBidPrice(lvl, entry.getMdEntryPx()); } } break; case Unknown: break; } }