OnixS C++ CME Market Data Handler  5.4.0
API documentation
Market Data Processing Session

The SDK offers improved and enhanced market data processing session. Now the Handler allows using a TCP recovery while books are naturally refreshed or combining join-time recovery with natural refresh and so forth.

Defining Processing Behavior

A set of parameters defining a market data processing session's behavior are gathered into the OnixS::CME::MDH::AdvancedSessionSettings class. The OnixS::CME::MDH::HandlerSettings class exposes an instance of the given class through the OnixS::CME::MDH::HandlerSettings::session` member.

Settings allow defining whether market data recovery must be performed at the beginning of market data processing or in case of data loss or other processing error, and so on. Also, settings define which type of market (by price or by order or both) to recover. Finally, the settings tell the Handler whether to use the TCP recovery to request missing data before recovering the market state from snapshots.

The table below describes the primary parameters affecting market data processing:

Parameter Description Behavior Visualization
OnixS::CME::MDH::AdvancedSessionSettings::joinRecovery

Defines whether the Handler must recover either instruments or the entire market state, or nothing when it joins a trading session. For a complete list of available options see OnixS::CME::MDH::JoinRecoveryOptions::Enum items.

Note
Recovery at join-time is a single-time procedure executed by the Handler. Performing recovery, for example, due to book update failure or data loss at a later time is defined by other parameters. See OnixS::CME::MDH::AdvancedSessionSettings::gapAndErrorHandling for more information.
SessionSettings-JoinAndGap.jpg
OnixS::CME::MDH::AdvancedSessionSettings::gapAndErrorHandling

When real-time market data is processed, a failure may take place due to errors in transmitted data or due to data loss. The Handler allows controlling its behavior in such cases. With the help of the given parameter, it's possible to specify whether processing real-time market data should continue or the Handler must recover market state to have accurate order books. Also, the Handler may recover all instruments in addition to the market state to have an accurate list of traded securities.

See the OnixS::CME::MDH::GapAndErrorHandlingOptions::Enum for a complete list of available options.

Note
The given parameter does not affect join-time behavior and thus if recovery is desired at join time, the OnixS::CME::MDH::SessionSettings::joinRecovery member must be used to set a correspondent value.
OnixS::CME::MDH::AdvancedSessionSettings::instrumentRecovery

The given parameter tells the Handler how to recover security definitions. If the processing session has to perform instrument recovery due to either late join or processing failure, the given parameter affects the way security definitions are recovered.

By default, the Handler processes recovery data from the beginning of a recovery loop to have the correct set of available instruments. If the Handler joins the feed in the middle of a loop, it waits till its end. When the number of security definitions being looped is significant, it takes a while for the Handler to get all instrument definitions recovered. Also, data loss causes the Handler to process security definitions from the beginning of the next loop. As a result, client systems using the Handler may need for a faster way of recovering security definitions. For this reason, the SDK offers alternative ways of recovering instrument definitions client systems may take advantage of.

For a complete list of options, see OnixS::CME::MDH::InstrumentRecoveryOptions::Enum.

OnixS::CME::MDH::AdvancedSessionSettings::marketRecovery

The given parameter controls aspects of the Handler behavior in case of market recovery. If the processing session has to perform market state recovery due to either late join or processing failure, the given parameter allows defining a type of market to recover.

Starting with Q4 of 2016, CME MDP offers market by order (MBO) data in addition to market by price (MBP) one. Although the data for both MBO and MBP is combined on the real-time feed, recovery is separated for each type of market. As a result, the Handler has to be configured with the types of markets which must be recovered.

For a complete list of options, see OnixS::CME::MDH::MarketRecoveryOptions::Enum.

Note
Value of the given parameter must be adjusted with order books maintaining settings. For example, if a processing session is configured to recover market at the join time or due to data loss and recovery must be done for market by price only, then the accurate maintenance of MBO books is not possible. Therefore, if the Handler is configured to maintain MBO books in such case, an exception is thrown.
SessionSettings-MarketRecovery.jpg
OnixS::CME::MDH::AdvancedSessionSettings::tcpRecovery The given set of parameters controls aspects of the Handler behavior in case of TCP Recovery. If a valid instance of the OnixS::CME::MDH::TcpRecoveryService is associated by the OnixS::CME::MDH::TcpRecoverySessionSettings::service parameter, the Handler tries to recover missing incremental data before it switches recovering market state from snapshots or resumes incremental data processing depending on the value of the OnixS::CME::MDH::AdvancedSessionSettings::gapAndErrorHandling parameter.

Configuring Handler For Accurate Book Maintenance While Joining Lately

The following code snippet depicts how to configure a market data processing session to maintain order books accurately starting from the middle of a trading session (a.k.a. late join).

// An instance to be configured.
Handler handler;
// A ref to the session-related parameters.
AdvancedSessionSettings& settings = handler.settings().session();
// In case of late join, instruments and market state must be
// recovered before switching to process real-time (incremental) data.
settings.joinRecovery(JoinRecoveryOptions::InstrumentsAndMarketState);
// Accurate order book maintenance assumes performing market recovery
// each time data is lost or other processing failure occurs.
settings.gapAndErrorHandling(GapAndErrorHandlingOptions::RecoverMarketState);
// Now, spawns live market data processing.
handler.start();

Configuring Handler for Accurate MBP Book Maintenance while Joining in Preopening

The following code snippet depicts how to configure a market data processing session to maintain MBP books accurately starting from the beginning of a trading session when the market is at a blank state (thus, no initial recovery is needed to catch-up an up-to-date market state).

// An instance to be configured.
Handler handler;
// A ref to the session-related parameters.
AdvancedSessionSettings& settings = handler.settings().session();
// In case of pre-opening, instruments are transmitted via a real-time feed
// and the market state is blank. Therefore, join recovery is not needed at all.
settings.joinRecovery(JoinRecoveryOptions::InstrumentsAndMarketState);
// Accurate order book maintenance assumes performing market recovery
// each time data is lost or other processing failure occurs.
settings.gapAndErrorHandling(GapAndErrorHandlingOptions::RecoverMarketState);
// Limits market recovery to MBP only.
settings.marketRecovery(MarketRecoveryOptions::MbpOnly);
// Now, spawns live market data processing.
handler.start();

Configuring Handler to Refresh Books Naturally with Initial Recovery

The following code snippet depicts how to configure market data processing to maintain order books in the natural refresh mode and to perform a full state recovery at a join stage. The given configuration is frequently used when a server doing market data processing is collocated in the CME network, and the possibility of data loss is minimal. It gives almost the same benefits as an accurate order book maintenance. Still, it does not let real-time processing freeze due to necessity in performing market recovery in case of data loss.

// An instance to be configured.
Handler handler;
// A ref to the session-related parameters.
AdvancedSessionSettings& settings = handler.settings().session();
// This forces Handler to perform instrument and market recovery at join time.
settings.joinRecovery(JoinRecoveryOptions::InstrumentsAndMarketState);
// Natural refresh assumes continuation of real-time data
// processing even if some of transmitted data is lost.
settings.gapAndErrorHandling(GapAndErrorHandlingOptions::ContinueProcessing);
// Now, spawns live market data processing.
handler.start();

Configuring Handler To Refresh Books Naturally But Use TCP Recovery In Case Of Data Losses

The following code snippet helps to configure market data processing to maintain order books in natural refresh mode. However, in contrast to a typical case, when real-time processing is resumed immediately, in the given case, the Handler tries to recover missing data using TCP Recovery Feed.

// Settings for TCP recovery facility.
TcpRecoverySetting tcpRecoverySettings;
// Credentials are to be set as there's no defaults for
// these parameters. Other parameters have default values.
tcpRecoverySettings.username("CME");
tcpRecoverySettings.password("CME");
// Instance of TCP recovery service to be bound to the Handler.
TcpRecoveryService tcpRecovery(tcpRecoverySettings);
// An instance to be configured.
Handler handler;
// A ref to the session-related parameters.
AdvancedSessionSettings& settings = handler.settings().session();
// Natural refresh assumes continuation of real-time data
// processing even if some of transmitted data is lost.
settings.gapAndErrorHandling(GapAndErrorHandlingOptions::ContinueProcessing);
// Tells the Handler to involve TCP Recovery if data is missed.
settings.tcpRecovery().service(&tcpRecovery);
// Now, spawns live market data processing.
handler.start();