OnixS C++ Cboe CFE Multicast PITCH Market Data Handler  1.12.1
API documentation
HandlerSettings.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
25 
26 #include <sstream>
27 #include <string>
28 #include <set>
29 #include <vector>
30 
31 namespace OnixS
32 {
33  namespace CboeCFE
34  {
35  namespace MarketData
36  {
37  namespace Pitch
38  {
39  /// Service endpoint description
41  {
42  ///
44  : port (0)
45  {}
46 
47  ///
48  ServiceDescriptor (const std::string& a, unsigned int port)
49  : address (a)
50  , port (port)
51  {}
52 
53  /// Ip address
54  std::string address;
55 
56  /// Port number
57  unsigned port;
58 
59  /// Compares with another instance.
60  bool operator == (const ServiceDescriptor& other) const
61  {
62  return address == other.address && port == other.port;
63  }
64 
65  /// Compares with another instance.
66  bool operator != (const ServiceDescriptor& other) const
67  {
68  return !operator==(other);
69  }
70 
71  /// Returns true if the descriptor points to valid ip address
72  bool valid() const
73  {
74  return !address.empty() && port > 0;
75  }
76  };
77 
78  ONIXS_CBOECFE_PITCH_API std::ostream& operator << (std::ostream& stream, const ServiceDescriptor& descriptor);
79 
80  /// Feed descriptor
82  {
83  /// Service A
85 
86  /// Service B
88 
89  /// Compares with another instance.
90  bool operator == (const FeedDescriptor& other) const
91  {
92  return serviceA == other.serviceA && serviceB == other.serviceB;
93  }
94 
95  /// Compares with another instance.
96  bool operator != (const FeedDescriptor& other) const
97  {
98  return !operator==(other);
99  }
100  };
101 
102  ONIXS_CBOECFE_PITCH_API std::ostream& operator << (std::ostream& stream, const FeedDescriptor& descriptor);
103 
104  /// Describse CFE services such as grp or spin
106  {
107  ///
109 
110  ///
112  const std::string& addr, unsigned int port, const std::string& subId,
113  const std::string& name, const std::string& pass)
114  : ServiceDescriptor(addr, port)
115  , sessionSubId(subId)
116  , username(name)
117  , password(pass)
118  {}
119 
120  /// Returns true if the descriptor is valid
121  bool valid() const
122  {
123  return
125  (!sessionSubId.empty()) &&
126  (!username.empty()) &&
127  (!password.empty());
128  }
129 
130  /// Compares with another instance.
131  bool operator == (const TcpServiceDescriptor& other) const
132  {
133  return
135  (sessionSubId == other.sessionSubId) &&
136  (username == other.username);
137  }
138 
139  /// Compares with another instance.
140  bool operator != (const TcpServiceDescriptor& other) const
141  {
142  return !operator==(other);
143  }
144 
145  /// SessionSubId supplied by CFE
146  std::string sessionSubId;
147 
148  /// Username
149  std::string username;
150 
151  /// Password
152  std::string password;
153  };
154 
155  ///
156  ONIXS_CBOECFE_PITCH_API std::ostream& operator << (std::ostream& stream, const TcpServiceDescriptor& descriptor);
157 
158 
159  ///
161  {
162  /// Service A
164 
165  /// Service B
167  };
168 
169  ///
170  ONIXS_CBOECFE_PITCH_API std::ostream& operator << (std::ostream& stream, const TcpFeedDescriptor& descriptor);
171 
172 
173  /// Alias for symbol list
174  typedef std::set<std::string> Symbols;
175 
176  struct HandlerSettings;
177 
178  ONIXS_CBOECFE_PITCH_API std::ostream& operator << (std::ostream& stream, const HandlerSettings& settings);
179 
180  /// Handler configuration settings.
182  {
183  /// Constructor.
185  : licenseString("")
186  , licenseDirectory("")
187  , logDirectory("logs")
188  , logFileNamePrefix("CboeCfePitch")
189  , logSettings(LogSettings::Default)
190  , logLevel(LogLevel::Info)
191  , logFilePermissions(LogFilePermission::Default)
192  , heartbeatInterval(1)
193  , outOfOrderPacketMaxInterval(3)
194  , lostPacketWaitTime(100000)
195  , useFeedA(true)
196  , useFeedB(true)
197  , maxBooksObjectAmount(1000)
198  , maxPacketSize(1500)
199  , maxConnectingAttempts(3)
200  , minReconnectingTimeout(3)
201  , replayMaxPacketsNumber(10000)
202  , buildInternalOrderBooks(false)
203  , buildMarketByPrice(false)
204  {}
205 
206  /// License string.
207  std::string licenseString;
208 
209  /// Path to the license directory.
210  std::string licenseDirectory;
211 
212  /// Log files are stored in this directory.
213  std::string logDirectory;
214 
215  /// Template of log file name without extension.
216  std::string logFileNamePrefix ;
217 
218  /// Combine LogSettings enum values to configure the logger.
220 
221  /// Log verbosity.
222  ///
223  /// @note The default value is LogLevel::Info
225 
226  /// Log file permissions.
227  ///
228  /// @note The default value is ReadAll | WriteOwnerOnly
230 
231  /**
232  * Specifies one or more network interfaces to use while joining the multicast group; use semi-colon delimited list if more than one.
233  *
234  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
235  *
236  * @note If the value is empty or absent then the default networking interface is used.
237  */
238  std::string networkInterface;
239 
240  /**
241  * Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon delimited list if more than one.
242  *
243  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
244  *
245  * @note If the value is empty or absent then the networkInterface_ filled value is used.
246  */
247  std::string networkInterfaceA;
248 
249  /**
250  * Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon delimited list if more than one.
251  *
252  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
253  *
254  * @note If the value is empty or absent then the networkInterface_ filled value is used.
255  */
256  std::string networkInterfaceB;
257 
258  /// Specifies maximal time interval between two
259  /// network packets. If no data is received during
260  /// specified time frame, corresponding warning is raised.
261  ///
262  /// Interval is measured in seconds.
263  ///
264  /// @note The default value is '1'.
266 
267  /// Defines value of threshold used by Handler to differ
268  /// out-of-order packets from gaps.
269  ///
270  /// Due to unreliable nature of multicast, packets transmitted by exchange
271  /// may be received in the order different to original. To differ the
272  /// case when Handler received out-of-order packets from the case when
273  /// some of packets were completely lost, Handler uses given parameter.
274  /// It defines size of interval for incoming packets starting from the
275  /// last received. Packet is considered as out-of-order if its sequence
276  /// number fits into interval [seqNumberOfLastReceivedPacket,
277  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
278  /// In that case Handler waits for other packets to fulfill the incoming
279  /// sequence. If received packet has greater sequence number than
280  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
281  /// then Handler makes a decision on packets lost and gap is reported.
282  ///
283  /// @note When out-of-order packet is received, Handler makes a decision
284  /// on data loss if either waiting time is over or if newly received packet
285  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
286  /// outOfOrderPacketMaxInterval'.
287  ///
288  /// @see 'lostPacketWaitTime' parameter for more information.
289  ///
290  /// @note The default value is '3'.
292 
293  /// Indicates for how long Handler should wait for
294  /// the packet before it's considered as totally lost.
295  ///
296  /// Due to unreliable nature of multicast, data transmitted by MDP
297  /// may come in order other than original or be completely lost. When
298  /// Handler receives packet with sequence number greater than expected,
299  /// it considers received data as out-of-order. If for a certain time
300  /// interval Handler receives missing data, Handler resumes normal data
301  /// processing. However, if no data is received for predefined time frame,
302  /// Handler considers missing data as lost and raises packet gap event.
303  /// Given parameter defines size of time interval Handler waits for missing
304  /// data.
305  ///
306  /// @note When out-of-order packet is received, Handler makes a decision
307  /// on data loss if either waiting time is over or if newly received packet
308  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
309  /// outOfOrderPacketMaxInterval'.
310  ///
311  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
312  ///
313  /// Time interval is measured in microseconds (uSec).
314  ///
315  /// @note The default value is '100000' (100 milliseconds).
317 
318  /// Option to use feed A.
319  ///
320  /// @note The default value is 'true'.
321  bool useFeedA;
322 
323  /// Option to use feed B.
324  ///
325  /// @note The default value is 'true'.
326  bool useFeedB;
327 
328  /// Realtime feed
330 
331  /// Gap response feed
333 
334  /// Gap request TCP service credentials
336 
337  /// Gap request TCP service sending affinity
339 
340  /// Gap request TCP service receiving affinity
342 
343  /// Spin TCP service credentials
345 
346  /// Spin request TCP service sending affinity
348 
349  /// Spin request TCP service receiving affinity
351 
352  /**
353  * Specifies network interfaces to use while establishing tcp connection.
354  *
355  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
356  *
357  * @note If the value is empty or absent then the default networking interface is used.
358  */
360 
361  /**
362  * Specifies network interfaces to use while establishing connection to gap response multicast.
363  *
364  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
365  *
366  * @note If the value is empty or absent then the value of HandlerSettings::networkInterface is used.
367  */
369 
370  /// Defines size of pre-allocated memory for Order Book. Default value is 100
371  unsigned int maxBooksObjectAmount;
372 
373  /// Max size for network packet transmitted by Eurex.
374  unsigned short maxPacketSize;
375 
376  /// Max number of attempts to connect replay and recovery services, default value is 3
377  unsigned int maxConnectingAttempts;
378 
379  /// Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
381 
382  /// Lost packets threshold when the Handler prefers replay, should not exceed 10000
384 
385  /// Symbols for filtration
386  Symbols symbols;
387 
388  /// Build internal books
390 
391  /// Build Market By Price;
393 
394  /// Returns the string representation.
395  std::string toString() const
396  {
397  std::ostringstream out;
398  out << *this;
399  return out.str();
400  }
401  };
402 
403  }
404  }
405  }
406 }
407 
408 
409 
bool operator==(const ServiceDescriptor &other) const
Compares with another instance.
bool valid() const
Returns true if the descriptor is valid.
unsigned int minReconnectingTimeout
Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
bool operator!=(const ServiceDescriptor &other) const
Compares with another instance.
std::string logDirectory
Log files are stored in this directory.
TcpFeedDescriptor grpTcpService
Gap request TCP service credentials.
unsigned int replayMaxPacketsNumber
Lost packets threshold when the Handler prefers replay, should not exceed 10000.
TcpServiceDescriptor(const std::string &addr, unsigned int port, const std::string &subId, const std::string &name, const std::string &pass)
std::set< std::string > Symbols
Alias for symbol list.
FeedDescriptor grpMulticastFeed
Gap response feed.
std::string licenseDirectory
Path to the license directory.
ThreadAffinity grpTcpServiceSendingAffinity
Gap request TCP service sending affinity.
ONIXS_CBOECFE_PITCH_API std::ostream & operator<<(std::ostream &stream, const ServiceDescriptor &descriptor)
unsigned int maxBooksObjectAmount
Defines size of pre-allocated memory for Order Book. Default value is 100.
ThreadAffinity spinTcpServiceRecvAffinity
Spin request TCP service receiving affinity.
unsigned short maxPacketSize
Max size for network packet transmitted by Eurex.
LogSettings::Enum logSettings
Combine LogSettings enum values to configure the logger.
bool valid() const
Returns true if the descriptor points to valid ip address.
TcpFeedDescriptor spinTcpService
Spin TCP service credentials.
std::string logFileNamePrefix
Template of log file name without extension.
std::string toString() const
Returns the string representation.
unsigned int maxConnectingAttempts
Max number of attempts to connect replay and recovery services, default value is 3.
ThreadAffinity spinTcpServiceSendingAffinity
Spin request TCP service sending affinity.
Represents set of CPU indices.
Definition: Defines.h:131
FeedDescriptor realtimeMulticastFeed
Realtime feed.
ThreadAffinity grpTcpServiceRecvAffinity
Gap request TCP service receiving affinity.
Describse CFE services such as grp or spin.
std::string sessionSubId
SessionSubId supplied by CFE.
ServiceDescriptor(const std::string &a, unsigned int port)