OnixS C++ CME Market Data Handler  4.8.0.10
API documentation
Maintaining Books by Natural Refresh

In the regular case, the Handler keeps checking incoming packets transmitted by MDP for gaps and uses recovery facilities like TCP Recovery and snapshot feeds to keep order books in the up-to-date state. When market data loss occurs, the Handler spawns market recovery using the market recovery feed. While recovering market, the real-time market data is cached, and thus, market data processing looks like suspended.

Natural refresh of order books supposes processing of real-time (incremental) market data without involving market recovery. As a result, the Handler processes the real-time market data as soon as it is received from the feeds. As a drawback, order books may not be fully recovered, and thus, some price levels may be absent.

Identifying Book State and Missed Price Levels

When recovery facilities are used, order books exposed by the Handler are always fully reconstructed and in τς up-to-date state. When books are naturally refreshed, a part of price level information may be absent.

To differ whether order book is fully recovered or just partly reconstructed, OnixS::CME::MDH::MboBook and OnixS::CME::MDH::MbpBook classes expose OnixS::CME::MDH::MboBook::state and OnixS::CME::MDH::MbpBook::state members correspondently. Returned value identifies whether book is fully reconstructed (OnixS::CME::MDH::BookStates::Latest) or naturally refreshed (OnixS::CME::MDH::BookStates::NaturallyRefreshed).

When an order book is naturally refreshed, some price levels may be absent. Price level data types (OnixS::CME::MDH::DirectPriceLevel, OnixS::CME::MDH::ImpliedPriceLevel) expose members (OnixS::CME::MDH::DirectPriceLevel::exist(), OnixS::CME::MDH::ImpliedPriceLevel::exist()) to check whether actual data is available for particular bid or ask.

Note
Data availability for particular bid or ask is not applicable for MBO book. OnixS::CME::MDH::Order as the entry of MBO book does not provide any member similar to OnixS::CME::MDH::DirectPriceLevel::exist(). Missing orders just aren't available in a book without any space reservation.

Example

The following code depicts how to run the Handler in natural refresh mode:

// 1. Establishing primary settings.
HandlerSettings settings;
settings.channel(310);
settings.
feeds().
connectivityConfigurationFile("config.xml");
// 2. Constructing handler instance.
Handler handler(settings);
// 3. Spawning natural refresh session.
handler.start(NaturalRefreshSession());

In other words, natural refresh defines the behavior of the Handler in case of data loss and other issues while processing real-time data. Since this major release, the Handler provides the ability to combine natural refresh with other facilities like performing initial instrument and market recovery as well as TCP recovery to request lost data.

The following example depicts how the Handler and its processing session can be configured to combine natural refresh with an initial late join recovery.

// Establishing primary settings.
HandlerSettings settings;
settings.channel(310);
settings.
feeds().
connectivityConfigurationFile("config.xml");
// Constructing handler instance.
Handler handler(settings);
// Configuring session.
SessionSettings sessionSettings;
// This will force Handler to perform initial recovery
// as it's done during late join - instruments will be
// recovered and market state afterwards.
sessionSettings.
joinRecovery(
JoinRecovery::
InstrumentsAndMarketState);
// Forbids market state recovery in case of data
// loss or processing error. Books will be naturally
// refreshed in case of issue.
sessionSettings.
gapAndErrorHandling(
GapAndErrorHandling::ContinueProcessing);
// Spawns market data processing
// according to chosen session settings.
handler.start(sessionSettings);