1 \addtogroup processing-session
3 \brief Uncovers parameters affecting behavior of the Handler
4 while processing market data transmitted by MDP.
6 \details Previously, the Handler offered a predefined set of
7 market data processing patterns. The given processing patterns
8 covered the most frequently used cases of market data processing
9 like late join with an accurate order book maintenance or order
10 book natural refresh using only real-time feeds.
12 However, if the users wanted to have more customization for a
13 processing session like using a TCP Recovery facility in case of
14 a natural refresh, there was no solution for the case.
16 Starting with version 4, the SDK offers improved and enhanced
17 market data processing session. Now the Handler allows to use
18 a TCP recovery while books are naturally refreshed or to combine
19 join-time recovery with natural refresh and so forth.
22 \section processing-session-settings Defining Processing Behavior
24 A set of parameters, gathered into the the OnixS::CME::MDH::SessionSettings class,
25 now defines behavior of a processing session. The OnixS::CME::MDH::Handler::start
26 member requires an instance of the OnixS::CME::MDH::SessionSettings as a parameter.
28 Settings allow defining whether market data recovery must be done
29 at the beginning of market data processing or in case of data loss
30 or other processing error, and so on. Also, settings allow defining
31 which type of market (by price or by order or both) to recover.
33 The table below describes primary parameters affecting market data processing:
39 <th>Behavior Visualization</th>
43 OnixS::CME::MDH::SessionSettings::joinRecovery
46 Defines whether the Handler must recover either
47 instruments or the entire market state, or nothing when
48 it joins a trading session. For a complete list of available
49 options see OnixS::CME::MDH::JoinRecoveryOptions::Enum items.
51 \note Recovery at join-time is a single-time procedure executed
52 by the Handler. Performing recovery, for example, due to book update
53 failure or data loss at a later time is defined by other parameters.
54 See OnixS::CME::MDH::SessionSettings::gapAndErrorHandling for
58 
63 OnixS::CME::MDH::SessionSettings::gapAndErrorHandling
66 When real-time market data is processed, a failure may
67 take place due to errors in transmitted data or due to
68 data loss. The Handler allows controlling its behavior
69 in such cases. With the help of the given parameter,
70 it's possible to specify whether processing real-time
71 market data should continue or the Handler must recover
72 market state to have accurate order books. Also, the Handler
73 may recover all instruments in addition to the market state
74 to have an accurate list of traded securities.
76 See the OnixS::CME::MDH::GapAndErrorHandlingOptions::Enum
77 for a complete list of available options.
79 \note The given parameter does not affect join-time
80 behavior and thus if recovery is desired at join time,
81 the OnixS::CME::MDH::SessionSettings::joinRecovery member
82 must be used to set a correspondent value.
87 OnixS::CME::MDH::SessionSettings::marketRecovery
90 The given parameter controls aspects of the Handler behavior
91 in case of market recovery. If processing session has to perform
92 market state recovery due to either late join or processing failure,
93 the given parameter allows defining a type of market to recover.
95 Starting with Q4 of 2016, CME MDP offers market by order (MBO) data
96 in addition to market by price (MBP) one. Although the data for both
97 MBO and MBP is combined on the real-time feed, recovery is separated
98 for each type of market. As a result, the Handler has to be configured
99 with the types of markets which must be recovered.
101 For a complete list of options, see OnixS::CME::MDH::MarketRecoveryOptions::Enum.
103 \note Value of the given parameter must be adjusted with order
104 books maintaining settings. For example, if a processing session
105 is configured to recover market at the join time or due to data
106 loss and recovery must be done for market by price only, then the
107 accurate maintenance of MBO books is not possible. Therefore, the
108 if the Handler is configured to maintain MBO books in such case,
109 an exception is thrown.
112 
117 \subsection accurate-latejoin-session-example Configuring Handler For Accurate Book Maintenance While Joining Lately
119 The following code snippet depicts how to configure market data
120 processing session to maintain order books accurately starting
121 from the middle of a trading session (a.k.a. late join).
125 // Processing session settings.
126 SessionSettings settings;
128 // In case of late join, instruments and market state must be
129 // recovered before switching to process real-time (incremental) data.
130 settings.joinRecovery(JoinRecoveryOptions::InstrumentsAndMarketState);
132 // Accurate order book maintenance assumes performing market recovery
133 // each time data is lost or other processing failure occurs.
134 settings.gapAndErrorHandling(GapAndErrorHandlingOptions::RecoverMarketState);
136 // Now, spawns live market data processing.
137 handler.start(settings);
141 \subsection accurate-preopening-mbp-session-example Configuring Handler for Accurate MBP Book Maintenance while Joining in Preopening
143 The following code snippet depicts how to configure a market data
144 processing session to maintain MBP books accurately starting
145 from the beginning of a trading session when market is at a blank
146 state, and no initial recovery is needed to catch-up an up-to-date
151 // Processing session settings.
152 SessionSettings settings;
154 // In case of preopening, instruments are transmitted via real-time feed
155 // and market state is blank. Therefore, join recovery is not needed at all.
156 settings.joinRecovery(JoinRecoveryOptions::InstrumentsAndMarketState);
158 // Accurate order book maintenance assumes performing market recovery
159 // each time data is lost or other processing failure occurs.
160 settings.gapAndErrorHandling(GapAndErrorHandlingOptions::RecoverMarketState);
162 // Limits market recovery to MBP only.
163 settings.marketRecovery(MarketRecoveryOptions::MbpOnly);
165 // Now, spawns live market data processing.
166 handler.start(settings);
170 \subsection natural-refresh-with-initial-recovery-session-example Configuring Handler to Refresh Books Naturally with Initial Recovery
172 The following code snippet depicts how to configure market data processing
173 to maintain order books in the natural refresh mode and to perform a full
174 state recovery at a join stage. The given configuration is frequently used
175 in cases, when a server doing market data processing is collocated in the CME
176 network and a possibility of data loss is minimal. It gives almost same benefits
177 as an accurate order book maintenance, but in case of data loss, it does not let
178 real-time processing to freeze due to necessity in performing market recovery.
182 // Processing session settings.
183 SessionSettings settings;
185 // This forces Handler to perform instrument and market recovery at join time.
186 settings.joinRecovery(JoinRecoveryOptions::InstrumentsAndMarketState);
188 // Natural refresh assumes continuation of real-time data
189 // processing even if some of transmitted data is lost.
190 settings.gapAndErrorHandling(GapAndErrorHandlingOptions::ContinueProcessing);
192 // Now, spawns live market data processing.
193 handler.start(settings);
197 \subsection natural-refresh-with-tcp-recovery-session-example Configuring Handler To Refresh Books Naturally But Use TCP Recovery In Case Of Data Losses
199 The following code snippet helps to configure market data processing to maintain
200 order books in natural refresh mode. However, in contrast to a regular case, when
201 real-time processing is resumed immediately, in the given case the Handler tries
202 to recover missing data using TCP Recovery Feed.
206 // Processing session settings.
207 SessionSettings settings;
209 // Natural refresh assumes continuation of real-time data
210 // processing even if some of transmitted data is lost.
211 settings.gapAndErrorHandling(GapAndErrorHandlingOptions::ContinueProcessing);
213 // Settings for TCP recovery facility.
214 TcpRecoverySetting tcpRecoverySettings;
216 // Credentials are to be set as there's no defaults for
217 // these parameters. Other parameters have default values.
218 tcpRecoverySettings.username("CME");
219 tcpRecoverySettings.password("CME");
221 // Instance of TCP recovery service to be bound to the Handler.
222 TcpRecoveryService tcpRecovery(tcpRecoverySettings);
223 handler.bindTcpRecovery(tcpRecovery);
225 // Now, spawns live market data processing.
226 handler.start(settings);
230 \see OnixS::CME::MDH::AccurateLateJoinSession, OnixS::CME::MDH::AccurateLateJoinMboSession,
231 OnixS::CME::MDH::AccurateLateJoinMbpSession, OnixS::CME::MDH::AccurateLateJoinSession,
232 OnixS::CME::MDH::AccuratePreopeningSession, OnixS::CME::MDH::AccuratePreopeningMboSession,
233 OnixS::CME::MDH::AccuratePreopeningMbpSession, OnixS::CME::MDH::NaturalRefreshSession.