The Handler maintains books for each security by itself and exposes the results through callbacks if the user requested order book maintenance by modifying the Handler settings.
Sometimes there's a need to build and maintain books by own if, for example, a custom book structure is used by an application.
Book atomic updates represent the same elementary quants of market data as trades and statistics do.
The Handler notifies on atomic updates into a book through the OnixS::CME::ConflatedUDP::SecurityListener::onBookAtomicUpdate members. The listener instance can be registered using the OnixS::CME::ConflatedUDP::HandlerListeners::security member.
An event exposes detailed information of elementary operations on bids or offers.
A book atomic update is delivered to client code via the OnixS::CME::ConflatedUDP::SecurityListener::onBookAtomicUpdate member and represents an elementary operation over a book. Therefore, the OnixS::CME::ConflatedUDP::SecurityListener::onBookAtomicUpdate may be invoked more frequently compared to the OnixS::CME::ConflatedUDP::SecurityListener::onBookUpdate member. The OnixS::CME::ConflatedUDP::SecurityListener::onBookAtomicUpdate member usually is invoked several times before a single invoke of the OnixS::CME::ConflatedUDP::SecurityListener::onBookUpdate is done.
When the Handler delivers an order book via the OnixS::CME::ConflatedUDP::SecurityListener::onBookUpdate callback, that book is always in a valid and up-to-date state. In contrast, the OnixS::CME::ConflatedUDP::SecurityListener::onBookAtomicUpdate is a notification on an elementary action over a book. Usually, there're multiple atomic updates inside a single snapshot or incremental refresh transmitted by the MDP. As a result, a book may not be in a valid state between two atomic updates.
When the Handler processes all atomic updates belonging to a single market event, a book becomes in a valid state. The OnixS::CME::ConflatedUDP::SecurityListener::onBookUpdate callbacks are called precisely when the Handler processes all atomic updates, and all books appear to be valid and up-to-date.
To build an order book properly, it is necessary also to listen to the Hander events. When an error or data loss occurs, the Handler may spawn market state recovery. Therefore, if the Handler invokes the OnixS::CME::ConflatedUDP::HandlerListener::onMarketRecovery member, all books for all securities belonging to the channel must be empty. Afterward, the Handler will provide atomic updates recovered from snapshot messages.