OnixS C++ CME Market Data Handler  4.8.0.10
API documentation
Pages/ProcessingSession.md
Go to the documentation of this file.
1 \addtogroup processing-session
2 
3 \brief Uncovers parameters affecting behavior of the Handler
4 while processing market data transmitted by MDP.
5 
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.
11 
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.
15 
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.
20 
21 
22 \section processing-session-settings Defining Processing Behavior
23 
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.
27 
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.
32 
33 The table below describes primary parameters affecting market data processing:
34 
35 <table>
36  <tr>
37  <th>Parameter</th>
38  <th>Description</th>
39  <th>Behavior Visualization</th>
40  </tr>
41  <tr>
42  <td>
43  OnixS::CME::MDH::SessionSettings::joinRecovery
44  </td>
45  <td>
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.
50 
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
55  more information.
56  </td>
57  <td rowspan=2>
58  ![](@ref SessionSettings-JoinAndGap.jpg)
59  </td>
60  </tr>
61  <tr>
62  <td>
63  OnixS::CME::MDH::SessionSettings::gapAndErrorHandling
64  </td>
65  <td>
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.
75 
76  See the OnixS::CME::MDH::GapAndErrorHandlingOptions::Enum
77  for a complete list of available options.
78 
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.
83  </td>
84  </tr>
85  <tr>
86  <td>
87  OnixS::CME::MDH::SessionSettings::marketRecovery
88  </td>
89  <td valign=top>
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.
94 
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.
100 
101  For a complete list of options, see OnixS::CME::MDH::MarketRecoveryOptions::Enum.
102 
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.
110  </td>
111  <td>
112  ![](@ref SessionSettings-MarketRecovery.jpg)
113  </td>
114  </tr>
115 </table>
116 
117 \subsection accurate-latejoin-session-example Configuring Handler For Accurate Book Maintenance While Joining Lately
118 
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).
122 
123 ~~~{.cpp}
124 
125 // Processing session settings.
126 SessionSettings settings;
127 
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);
131 
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);
135 
136 // Now, spawns live market data processing.
137 handler.start(settings);
138 
139 ~~~
140 
141 \subsection accurate-preopening-mbp-session-example Configuring Handler for Accurate MBP Book Maintenance while Joining in Preopening
142 
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
147 market state.
148 
149 ~~~{.cpp}
150 
151 // Processing session settings.
152 SessionSettings settings;
153 
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);
157 
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);
161 
162 // Limits market recovery to MBP only.
163 settings.marketRecovery(MarketRecoveryOptions::MbpOnly);
164 
165 // Now, spawns live market data processing.
166 handler.start(settings);
167 
168 ~~~
169 
170 \subsection natural-refresh-with-initial-recovery-session-example Configuring Handler to Refresh Books Naturally with Initial Recovery
171 
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.
179 
180 ~~~{.cpp}
181 
182 // Processing session settings.
183 SessionSettings settings;
184 
185 // This forces Handler to perform instrument and market recovery at join time.
186 settings.joinRecovery(JoinRecoveryOptions::InstrumentsAndMarketState);
187 
188 // Natural refresh assumes continuation of real-time data
189 // processing even if some of transmitted data is lost.
190 settings.gapAndErrorHandling(GapAndErrorHandlingOptions::ContinueProcessing);
191 
192 // Now, spawns live market data processing.
193 handler.start(settings);
194 
195 ~~~
196 
197 \subsection natural-refresh-with-tcp-recovery-session-example Configuring Handler To Refresh Books Naturally But Use TCP Recovery In Case Of Data Losses
198 
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.
203 
204 ~~~{.cpp}
205 
206 // Processing session settings.
207 SessionSettings settings;
208 
209 // Natural refresh assumes continuation of real-time data
210 // processing even if some of transmitted data is lost.
211 settings.gapAndErrorHandling(GapAndErrorHandlingOptions::ContinueProcessing);
212 
213 // Settings for TCP recovery facility.
214 TcpRecoverySetting tcpRecoverySettings;
215 
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");
220 
221 // Instance of TCP recovery service to be bound to the Handler.
222 TcpRecoveryService tcpRecovery(tcpRecoverySettings);
223 handler.bindTcpRecovery(tcpRecovery);
224 
225 // Now, spawns live market data processing.
226 handler.start(settings);
227 
228 ~~~
229 
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.