OnixS C++ SGX Titan ITCH Market Data Handler  1.2.2
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 
22 #include <sstream>
23 #include <string>
24 #include <set>
25 #include <vector>
26 
30 
31 
32 ONIXS_SGXTITAN_ITCH_NAMESPACE_BEGIN
33 
34 /// Service endpoint description
36 {
38  : port (0)
39  {}
40 
41  ServiceDescriptor (const std::string& a, unsigned p)
42  : address (a), port (p)
43  {}
44 
46  : address (descriptor.address), port (descriptor.port)
47  {}
48 
49  /// Ip address
50  std::string address;
51 
52  /// Port number
53  unsigned port;
54 
55  /// Compares with another instance.
56  bool operator == (const ServiceDescriptor& other) const
57  {
58  return address == other.address && port == other.port;
59  }
60 
61  /// Compares with another instance.
62  bool operator != (const ServiceDescriptor& other) const
63  {
64  return address != other.address || port != other.port;
65  }
66 
67  /// Returns true if the descriptor points to valid ip address
68  bool valid() const
69  {
70  return !address.empty() && port > 0;
71  }
72 };
73 
74 ONIXS_SGXTITAN_ITCH_API std::ostream& operator << (std::ostream& stream, const ServiceDescriptor& descriptor);
75 
76 /// Feed descriptor
78 {
79  /// Service A
81 
82  /// Service B
84 
85  /// Compares with another instance.
86  bool operator == (const FeedDescriptor& other) const
87  {
88  return serviceA == other.serviceA && serviceB == other.serviceB;
89  }
90 
91  /// Compares with another instance.
92  bool operator != (const FeedDescriptor& other) const
93  {
94  return serviceA != other.serviceA || serviceB != other.serviceB;
95  }
96 };
97 
98 ONIXS_SGXTITAN_ITCH_API std::ostream& operator << (std::ostream& stream, const FeedDescriptor& descriptor);
99 
100 /// Alias for symbol list
101 typedef std::set<std::string> Symbols;
102 
103 struct HandlerSettings;
104 
105 ONIXS_SGXTITAN_ITCH_API std::ostream& operator << (std::ostream& stream, const HandlerSettings& settings);
106 
107 /// Handler configuration settings.
109 {
110  /// Constructor.
112  : licenseDirectory("")
113  , logDirectory("logs")
114  , logFileNamePrefix("SgxTitanItch")
115  , logSettings(LogSettings::Default)
116  , logLevel(LogLevel::Info)
117  , logFilePermissions(LogFilePermission::Default)
118  , heartbeatInterval(1)
119  , outOfOrderPacketMaxInterval(3)
120  , lostPacketWaitTime(100000)
121  , useFeedA(true)
122  , useFeedB(true)
123  , maxRetransmissionResponseTime(30)
124  , maxBooksObjectAmount(1000)
125  , buildInternalOrderBooks(false)
126  , maxPacketSize(1500)
127  , maxConnectingAttempts(3)
128  , minReconnectingTimeout(3)
129  , retransmissionMaxPacketNumber(10000)
130  {}
131 
132  /// Path to the license directory.
133  std::string licenseDirectory;
134 
135  /// Log files are stored in this directory.
136  std::string logDirectory;
137 
138  /// Template of log file name without extension.
139  std::string logFileNamePrefix ;
140 
141  /// Combine LogSettings enum values to configure the logger.
143 
144  /// Log verbosity.
145  ///
146  /// @note The default value is LogLevel::Info
148 
149  /// Log file permissions.
150  ///
151  /// @note The default value is ReadAll | WriteOwnerOnly
153 
154  /**
155  * Specifies one or more network interfaces to use while joining the multicast group; use semi-colon delimited list if more than one.
156  *
157  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
158  *
159  * @note If the value is empty or absent then the default networking interface is used.
160  */
161  std::string networkInterface;
162 
163  /**
164  * Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon delimited list if more than one.
165  *
166  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
167  *
168  * @note If the value is empty or absent then the networkInterface_ filled value is used.
169  */
170  std::string networkInterfaceA;
171 
172  /**
173  * Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon delimited list if more than one.
174  *
175  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
176  *
177  * @note If the value is empty or absent then the networkInterface_ filled value is used.
178  */
179  std::string networkInterfaceB;
180 
181  /// Specifies maximal time interval between two
182  /// network packets. If no data is received during
183  /// specified time frame, corresponding warning is raised.
184  ///
185  /// Interval is measured in seconds.
186  ///
187  /// @note The default value is '1'.
189 
190  /// Defines value of threshold used by Handler to differ
191  /// out-of-order packets from gaps.
192  ///
193  /// Due to unreliable nature of multicast, packets transmitted by exchange
194  /// may be received in the order different to original. To differ the
195  /// case when Handler received out-of-order packets from the case when
196  /// some of packets were completely lost, Handler uses given parameter.
197  /// It defines size of interval for incoming packets starting from the
198  /// last received. Packet is considered as out-of-order if its sequence
199  /// number fits into interval [seqNumberOfLastReceivedPacket,
200  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
201  /// In that case Handler waits for other packets to fulfill the incoming
202  /// sequence. If received packet has greater sequence number than
203  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
204  /// then Handler makes a decision on packets lost and gap is reported.
205  ///
206  /// @note When out-of-order packet is received, Handler makes a decision
207  /// on data loss if either waiting time is over or if newly received packet
208  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
209  /// outOfOrderPacketMaxInterval'.
210  ///
211  /// @see 'lostPacketWaitTime' parameter for more information.
212  ///
213  /// @note The default value is '3'.
215 
216  /// Indicates for how long Handler should wait for
217  /// the packet before it's considered as totally lost.
218  ///
219  /// Due to unreliable nature of multicast, data transmitted by MDP
220  /// may come in order other than original or be completely lost. When
221  /// Handler receives packet with sequence number greater than expected,
222  /// it considers received data as out-of-order. If for a certain time
223  /// interval Handler receives missing data, Handler resumes normal data
224  /// processing. However, if no data is received for predefined time frame,
225  /// Handler considers missing data as lost and raises packet gap event.
226  /// Given parameter defines size of time interval Handler waits for missing
227  /// data.
228  ///
229  /// @note When out-of-order packet is received, Handler makes a decision
230  /// on data loss if either waiting time is over or if newly received packet
231  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
232  /// outOfOrderPacketMaxInterval'.
233  ///
234  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
235  ///
236  /// Time interval is measured in microseconds (usec).
237  ///
238  /// @note The default value is '100000' (100 milliseconds).
240 
241  /// Option to use feed A.
242  ///
243  /// @note The default value is 'true'.
244  bool useFeedA;
245 
246  /// Option to use feed B.
247  ///
248  /// @note The default value is 'true'.
249  bool useFeedB;
250 
251  /// ITCH Live feed
253 
254  ///Retransmission feed
256 
257  /// Maximum timeout to wait retransmission responses (sec), default value is 30 sec.
259 
260  /// Defines size of prea-llocated memory for Order Book. Default value is 1000
261  unsigned int maxBooksObjectAmount;
262 
263  /// Build internal books
265 
266  /// Max size for network packet transmitted.
267  unsigned short maxPacketSize;
268 
269  /// GLIMPSE feed
271 
272  /// Specifies network interfaces to use while establishing tcp connection.
273  ///
274  /// On Linux the network interfaces is specified by its name, on Windows - by IP address.
275  ///
276  /// @note If the value is empty or absent then the default networking interface is used.
277  ///
279 
280  /// Username assigned for GLIMPSE
281  std::string glimpseUsername;
282 
283  /// Password assigned for GLIMPSE
284  std::string glimpsePassword;
285 
286  /// Max number of attempts to connect replay and recovery services, default value is 3
287  unsigned int maxConnectingAttempts;
288 
289  /// Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
291 
292  /// Lost packets threshold when the Handler prefers retransmission
294 
295  /// Returns the string representation.
296  std::string toString() const
297  {
298  std::ostringstream out;
299  out << *this;
300  return out.str();
301  }
302 };
303 
304 ONIXS_SGXTITAN_ITCH_NAMESPACE_END
ServiceDescriptor(const std::string &a, unsigned p)
std::set< std::string > Symbols
Alias for symbol list.
std::string licenseDirectory
Path to the license directory.
unsigned int maxRetransmissionResponseTime
Maximum timeout to wait retransmission responses (sec), default value is 30 sec.
unsigned int maxConnectingAttempts
Max number of attempts to connect replay and recovery services, default value is 3.
std::string glimpsePassword
Password assigned for GLIMPSE.
std::string glimpseUsername
Username assigned for GLIMPSE.
unsigned int minReconnectingTimeout
Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
std::string logFileNamePrefix
Template of log file name without extension.
unsigned short maxPacketSize
Max size for network packet transmitted.
ServiceDescriptor(const ServiceDescriptor &descriptor)
std::string toString() const
Returns the string representation.
LogSettings::Enum logSettings
Combine LogSettings enum values to configure the logger.
bool valid() const
Returns true if the descriptor points to valid ip address.
std::string logDirectory
Log files are stored in this directory.
bool operator!=(const Price &left, const Price &right)
Definition: Price.h:93
bool operator==(const Price &left, const Price &right)
Definition: Price.h:84
unsigned int maxBooksObjectAmount
Defines size of prea-llocated memory for Order Book. Default value is 1000.
FeedDescriptor retransmissionFeed
Retransmission feed.
unsigned int retransmissionMaxPacketNumber
Lost packets threshold when the Handler prefers retransmission.
ONIXS_SGXTITAN_ITCH_API std::ostream & operator<<(std::ostream &stream, const HandlerSettings &settings)