The Handler builds and maintains books for each security by itself and exposes the results to user code if the user requests order book maintenance through 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 the application. Book atomic updates represent the same elementary quants of market data as trades and statistics do.
To get notified on book atomic updates into a book it is necessary to override OnixS::CME::MDH::SecurityListener::onBookAtomicUpdate members and register listener instance via OnixS::CME::MDH::Handler::registerSecurityListener 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::MDH::SecurityListener::onBookAtomicUpdate member and represents an elementary operation over a book.
Therefore, the OnixS::CME::MDH::SecurityListener::onBookAtomicUpdate may be invoked more frequently compare to the OnixS::CME::MDH::SecurityListener::onBookUpdate member. In fact, the OnixS::CME::MDH::SecurityListener::onBookAtomicUpdate member usually is invoked several times before a single invoke of the OnixS::CME::MDH::SecurityListener::onBookUpdate is done.
When the Handler delivers an order book via the OnixS::CME::MDH::SecurityListener::onBookUpdate callback, that book is always in a valid and up-to-date state. In contrast, the OnixS::CME::MDH::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 MDP. As a result, a book may not be in a valid state between two atomic updates.
Only when the Handler processes all atomic updates belonging to a single market event, a book becomes in a valid state. The OnixS::CME::MDH::SecurityListener::onBookUpdate callbacks are called exactly at the time when the Handler processes all atomic updates and all book appear to be valid and up-to-date.
To build an order book properly, it is necessary also to listen to Hander events. When error or data loss occurs, Handler may spawn market state recovery. Therefore, if the Handler invokes the OnixS::CME::MDH::HandlerListener::onMarketRecovery, all books for all securities in bounds of the channel must be empty. Afterwards, the Handler will provide atomic updates recovered from snapshot messages.