OnixS C++ Fenics UST BIMP Market Data Handler  1.1.0
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 FenicsUST
34  {
35  namespace MarketData
36  {
37  namespace Bimp
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_FENICSUST_BIMP_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_FENICSUST_BIMP_API std::ostream& operator << (std::ostream& stream, const FeedDescriptor& descriptor);
103 
104  /// Describes BIMP tcp service
106  {
107  ///
109 
110  ///
112  const std::string& addr, unsigned int port,
113  const std::string& name, const std::string& pass, const std::string& ni = "")
114  : ServiceDescriptor(addr, port)
115  , username(name)
116  , password(pass)
117  , networkInterface(ni)
118  {}
119 
120  /// Returns true if the descriptor is valid
121  bool valid() const
122  {
123  return
125  (!username.empty()) &&
126  (!password.empty());
127  }
128 
129  /// Compares with another instance.
130  bool operator == (const TcpServiceDescriptor& other) const
131  {
132  return
134  (username == other.username);
135  }
136 
137  /// Compares with another instance.
138  bool operator != (const TcpServiceDescriptor& other) const
139  {
140  return !operator==(other);
141  }
142 
143  /// Username
144  std::string username;
145 
146  /// Password
147  std::string password;
148 
149  /**
150  * Specifies network interfaces to use while establishing tcp connection.
151  *
152  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
153  *
154  * @note If the value is empty then HandlerSettings::networkInterfaceForTcpServices is used.
155  */
156  std::string networkInterface;
157  };
158 
159  ///
160  ONIXS_FENICSUST_BIMP_API std::ostream& operator << (std::ostream& stream, const TcpServiceDescriptor& descriptor);
161 
162 
163  ///
165  {
166  /// Service A
168 
169  /// Service B
171  };
172 
173  ///
174  ONIXS_FENICSUST_BIMP_API std::ostream& operator << (std::ostream& stream, const TcpFeedDescriptor& descriptor);
175 
176 
177  /// Alias for symbol list
178  typedef std::set<std::string> Symbols;
179 
180  struct HandlerSettings;
181 
182  ONIXS_FENICSUST_BIMP_API std::ostream& operator << (std::ostream& stream, const HandlerSettings& settings);
183 
184  /// Handler configuration settings.
186  {
187  /// Constructor.
189  : licenseString()
190  , licenseDirectory()
191  , logDirectory("logs")
192  , logFileNamePrefix("FenicsUstBimp")
193  , logSettings(LogSettings::Default)
194  , logLevel(LogLevel::Info)
195  , logFilePermissions(LogFilePermission::Default)
196  , heartbeatInterval(1)
197  , outOfOrderPacketMaxInterval(3)
198  , lostPacketWaitTime(100000)
199  , useFeedA(true)
200  , useFeedB(true)
201  , maxBooksObjectAmount(1000)
202  , maxPacketSize(1500)
203  , maxConnectingAttempts(3)
204  , minReconnectingTimeout(3)
205  , replayMaxPacketsNumber(10000)
206  , buildInternalOrderBooks(false)
207  {}
208 
209  /// License string.
210  std::string licenseString;
211 
212  /// Path to the license directory.
213  std::string licenseDirectory;
214 
215  /// Log files are stored in this directory.
216  std::string logDirectory;
217 
218  /// Template of log file name without extension.
219  std::string logFileNamePrefix ;
220 
221  /// Combine LogSettings enum values to configure the logger.
223 
224  /// Log verbosity.
225  ///
226  /// @note The default value is LogLevel::Info
228 
229  /// Log file permissions.
230  ///
231  /// @note The default value is ReadAll | WriteOwnerOnly
233 
234  /**
235  * Specifies one or more network interfaces to use while joining the multicast group; use semi-colon delimited list if more than one.
236  *
237  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
238  *
239  * @note If the value is empty or absent then the default networking interface is used.
240  */
241  std::string networkInterface;
242 
243  /**
244  * Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon delimited list if more than one.
245  *
246  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
247  *
248  * @note If the value is empty or absent then the networkInterface_ filled value is used.
249  */
250  std::string networkInterfaceA;
251 
252  /**
253  * Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon delimited list if more than one.
254  *
255  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
256  *
257  * @note If the value is empty or absent then the networkInterface_ filled value is used.
258  */
259  std::string networkInterfaceB;
260 
261  /// Specifies maximal time interval between two
262  /// network packets. If no data is received during
263  /// specified time frame, corresponding warning is raised.
264  ///
265  /// Interval is measured in seconds.
266  ///
267  /// @note The default value is '1'.
269 
270  /// Defines value of threshold used by Handler to differ
271  /// out-of-order packets from gaps.
272  ///
273  /// Due to unreliable nature of multicast, packets transmitted by exchange
274  /// may be received in the order different to original. To differ the
275  /// case when Handler received out-of-order packets from the case when
276  /// some of packets were completely lost, Handler uses given parameter.
277  /// It defines size of interval for incoming packets starting from the
278  /// last received. Packet is considered as out-of-order if its sequence
279  /// number fits into interval [seqNumberOfLastReceivedPacket,
280  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
281  /// In that case Handler waits for other packets to fulfill the incoming
282  /// sequence. If received packet has greater sequence number than
283  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
284  /// then Handler makes a decision on packets lost and gap is reported.
285  ///
286  /// @note When out-of-order packet is received, Handler makes a decision
287  /// on data loss if either waiting time is over or if newly received packet
288  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
289  /// outOfOrderPacketMaxInterval'.
290  ///
291  /// @see 'lostPacketWaitTime' parameter for more information.
292  ///
293  /// @note The default value is '3'.
295 
296  /// Indicates for how long Handler should wait for
297  /// the packet before it's considered as totally lost.
298  ///
299  /// Due to unreliable nature of multicast, data transmitted by MDP
300  /// may come in order other than original or be completely lost. When
301  /// Handler receives packet with sequence number greater than expected,
302  /// it considers received data as out-of-order. If for a certain time
303  /// interval Handler receives missing data, Handler resumes normal data
304  /// processing. However, if no data is received for predefined time frame,
305  /// Handler considers missing data as lost and raises packet gap event.
306  /// Given parameter defines size of time interval Handler waits for missing
307  /// data.
308  ///
309  /// @note When out-of-order packet is received, Handler makes a decision
310  /// on data loss if either waiting time is over or if newly received packet
311  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
312  /// outOfOrderPacketMaxInterval'.
313  ///
314  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
315  ///
316  /// Time interval is measured in microseconds (uSec).
317  ///
318  /// @note The default value is '100000' (100 milliseconds).
320 
321  /// Option to use feed A.
322  ///
323  /// @note The default value is 'true'.
324  bool useFeedA;
325 
326  /// Option to use feed B.
327  ///
328  /// @note The default value is 'true'.
329  bool useFeedB;
330 
331  /// Realtime feed
333 
334  /// Gap response feed
336 
337  /// Spin TCP service credentials
339 
340  /// Spin request TCP service sending affinity
342 
343  /// Spin request TCP service receiving affinity
345 
346  /**
347  * Specifies network interfaces to use while establishing tcp connection.
348  *
349  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
350  *
351  * @note If the value is empty or absent then the default networking interface is used.
352  */
354 
355  /// Defines size of pre-allocated memory for Order Book. Default value is 100
356  unsigned int maxBooksObjectAmount;
357 
358  /// Max size for network packet transmitted by Eurex.
359  unsigned short maxPacketSize;
360 
361  /// Max number of attempts to connect replay and recovery services, default value is 3
362  unsigned int maxConnectingAttempts;
363 
364  /// Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
366 
367  /// Lost packets threshold when the Handler prefers replay, should not exceed 10000
369 
370  ///Symbols for filtration
371  Symbols symbols;
372 
373  /// Build internal books
375 
376  /// Returns the string representation.
377  std::string toString() const
378  {
379  std::ostringstream out;
380  out << *this;
381  return out.str();
382  }
383  };
384 
385  }
386  }
387  }
388 }
ThreadAffinity snapshotServiceSendingAffinity
Spin request TCP service sending affinity.
bool valid() const
Returns true if the descriptor points to valid ip address.
unsigned int maxConnectingAttempts
Max number of attempts to connect replay and recovery services, default value is 3.
ThreadAffinity snapshotServiceRecvAffinity
Spin request TCP service receiving affinity.
unsigned int replayMaxPacketsNumber
Lost packets threshold when the Handler prefers replay, should not exceed 10000.
FeedDescriptor reRequestFeed
Gap response feed.
unsigned short maxPacketSize
Max size for network packet transmitted by Eurex.
ONIXS_FENICSUST_BIMP_API std::ostream & operator<<(std::ostream &stream, const ServiceDescriptor &descriptor)
TcpFeedDescriptor snapshotService
Spin TCP service credentials.
TcpServiceDescriptor(const std::string &addr, unsigned int port, const std::string &name, const std::string &pass, const std::string &ni="")
Represents set of CPU indices.
Definition: Defines.h:110
std::string toString() const
Returns the string representation.
unsigned int maxBooksObjectAmount
Defines size of pre-allocated memory for Order Book. Default value is 100.
LogSettings::Enum logSettings
Combine LogSettings enum values to configure the logger.
bool valid() const
Returns true if the descriptor is valid.
std::string logDirectory
Log files are stored in this directory.
bool operator!=(const ServiceDescriptor &other) const
Compares with another instance.
bool operator==(const ServiceDescriptor &other) const
Compares with another instance.
std::string licenseDirectory
Path to the license directory.
unsigned int minReconnectingTimeout
Minimum timeout value between attempts to connect replay and recovery services (sec), default value is 3 sec.
ServiceDescriptor(const std::string &a, unsigned int port)
std::set< std::string > Symbols
Alias for symbol list.
std::string logFileNamePrefix
Template of log file name without extension.