in orderbook-core/src/main/java/com/epam/deltix/orderbook/core/impl/AbstractL2MultiExchangeProcessor.java [156:192]
public Quote processL2EntryNew(final PackageHeaderInfo pck, final L2EntryNewInfo msg) {
assert pck.getPackageType() == PackageType.INCREMENTAL_UPDATE;
final QuoteSide side = msg.getSide();
final int level = msg.getLevel();
@Alphanumeric final long exchangeId = msg.getExchangeId();
final Option<MutableExchange<Quote, L2Processor<Quote>>> holder = getOrCreateExchange(exchangeId);
// Duplicate
if (!holder.hasValue() || holder.get().getProcessor().isWaitingForSnapshot()) {
return null;
}
final L2Processor<Quote> exchange = holder.get().getProcessor();
final L2MarketSide<Quote> marketSide = exchange.getMarketSide(side);
if (marketSide.isInvalidInsert(level, msg.getPrice(), msg.getSize(), exchangeId)) {
if (validationOptions.isQuoteInsert()) {
unmapQuote(exchange);
exchange.processL2EntryNew(pck, msg);
}
return null;
}
//Remove worst quote
//...maybe we should remove
if (marketSide.isFull()) {
removeQuote(marketSide.getWorstQuote(), side);
}
// We process quote as new by single exchange and then insert it to the aggregated book
final Quote quote = exchange.processL2EntryNew(pck, msg);
if (quote == null) {
return null;
}
final Quote insertQuote = insertQuote(quote, side);
return insertQuote;
}