OnixS C++ B3 Binary UMDF Market Data Handler  1.6.3
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 
26 
27 #include <sstream>
28 #include <string>
29 #include <set>
30 #include <vector>
31 #include <limits>
32 
33 namespace OnixS
34 {
35  namespace B3
36  {
37  namespace MarketData
38  {
39  namespace UMDF
40  {
41  class FeedEngine;
42 
43  /// Multicast feed description
45  {
46  ///
48  {}
49 
50  ///
51  FeedDescriptor(const std::string& a, unsigned int port, const std::string& nif = "")
52  : address (a)
53  , port (port)
54  , networkInterface(nif)
55  {}
56 
57  /// Ip address
58  std::string address;
59 
60  /// Port number
61  unsigned port = 0;
62 
63  /// Specifies one or more network interfaces to use while joining the multicast group;
64  /// use semi-colon delimited list if more than one.
65  /// This value overrides the default one.
66  std::string networkInterface;
67 
68  /// Returns true if the descriptor points to valid ip address
69  bool valid() const
70  {
71  return !address.empty() && port > 0;
72  }
73  };
74 
75  ONIXS_B3_UMDF_MD_API std::ostream& operator<<(std::ostream& stream, const FeedDescriptor& descriptor);
76 
77  // A feed-related settings.
78  struct Feed
79  {
80  /// Feed descriptor.
82 
83  /// Feed descriptor.
85 
86  /// Feed engine to use on feed.
87  /// This value overrides the default one.
88  FeedEngine* feedEngine = nullptr;
89 
90  ///
91  Feed()
92  : feedEngine(ONIXS_B3_UMDF_MD_NULLPTR)
93  {}
94 
95  ///
96  Feed(const FeedDescriptor& aFeed, const FeedDescriptor& bFeed, FeedEngine* engine = ONIXS_B3_UMDF_MD_NULLPTR)
97  : a(aFeed)
98  , b(bFeed)
99  , feedEngine(engine)
100  {}
101  };
102 
103  ONIXS_B3_UMDF_MD_API std::ostream& operator<<(std::ostream& stream, const Feed& descriptor);
104 
105  struct HandlerSettings;
106 
107  ONIXS_B3_UMDF_MD_API std::ostream& operator<<(std::ostream& stream, const HandlerSettings& settings);
108 
109  class OrderBookPool;
110 
111  /// Handler configuration settings.
112  struct ONIXS_B3_UMDF_MD_API HandlerSettings
113  {
114  /// Logger settings.
116 
117  /// License string.
118  std::string licenseString;
119 
120  /// Path to the license directory.
121  std::string licenseDirectory;
122 
123  /// Feed engine.
124  FeedEngine* feedEngine = nullptr;
125 
126  /**
127  * Specifies one or more network interfaces to use while joining the multicast group; use semi-colon delimited list if more than one.
128  *
129  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
130  *
131  * @note If the value is empty or absent then the default networking interface is used.
132  */
133  std::string networkInterface;
134 
135  /**
136  * Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon delimited list if more than one.
137  *
138  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
139  *
140  * @note If the value is empty or absent then the networkInterface_ filled value is used.
141  */
142  std::string networkInterfaceA;
143 
144  /**
145  * Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon delimited list if more than one.
146  *
147  * On Linux the network interfaces is specified by its name, on Windows - by IP address.
148  *
149  * @note If the value is empty or absent then the networkInterface_ filled value is used.
150  */
151  std::string networkInterfaceB;
152 
153  /// Specifies maximal time interval between two
154  /// network packets. If no data is received during
155  /// specified time frame, corresponding warning is raised.
156  ///
157  /// Interval is measured in seconds.
158  UInt32 heartbeatInterval = 3;
159 
160  /// Defines value of threshold used by Handler to differ
161  /// out-of-order packets from gaps.
162  ///
163  /// Due to unreliable nature of multicast, packets transmitted by exchange
164  /// may be received in the order different to original. To differ the
165  /// case when Handler received out-of-order packets from the case when
166  /// some of packets were completely lost, Handler uses given parameter.
167  /// It defines size of interval for incoming packets starting from the
168  /// last received. Packet is considered as out-of-order if its sequence
169  /// number fits into interval [seqNumberOfLastReceivedPacket,
170  /// seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval].
171  /// In that case Handler waits for other packets to fulfill the incoming
172  /// sequence. If received packet has greater sequence number than
173  /// 'seqNumberOfLastReceivedPacket + outOfOrderPacketsMaxInterval',
174  /// then Handler makes a decision on packets lost and gap is reported.
175  ///
176  /// @note When out-of-order packet is received, Handler makes a decision
177  /// on data loss if either waiting time is over or if newly received packet
178  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
179  /// outOfOrderPacketMaxInterval'.
180  ///
181  /// @see 'lostPacketWaitTime' parameter for more information.
182  UInt32 outOfOrderPacketMaxInterval = 3;
183 
184  /// Indicates for how long Handler should wait for
185  /// the packet before it's considered as totally lost.
186  ///
187  /// Due to unreliable nature of multicast, data transmitted by MDP
188  /// may come in order other than original or be completely lost. When
189  /// Handler receives packet with sequence number greater than expected,
190  /// it considers received data as out-of-order. If for a certain time
191  /// interval Handler receives missing data, Handler resumes normal data
192  /// processing. However, if no data is received for predefined time frame,
193  /// Handler considers missing data as lost and raises packet gap event.
194  /// Given parameter defines size of time interval Handler waits for missing
195  /// data.
196  ///
197  /// @note When out-of-order packet is received, Handler makes a decision
198  /// on data loss if either waiting time is over or if newly received packet
199  /// has sequence number greater than 'seqNumberOfLastReceivedPacket +
200  /// outOfOrderPacketMaxInterval'.
201  ///
202  /// @see 'outOfOrderPacketMaxInterval' parameter for more information.
203  ///
204  /// Time interval is measured in microseconds (uSec).
205  UInt32 lostPacketWaitTime = 100000;
206 
207  /// Instrument definition multicast feed
209 
210  /// Incremental multicast feed
212 
213  /// Snapshot recovery multicast feed
215 
216  /// Max size for network packet transmitted by B3 UMDF.
217  unsigned short maxPacketSize = 1400;
218 
219  /// Build order books.
220  bool buildOrderBooks = false;
221 
222  /// A shared pool for building books.
223  /// @note If not set, it is created internally for each handler.
224  OrderBookPool* orderBookPool = nullptr;
225 
226  /// Max depth of the order book
227  static constexpr size_t FullOrderBookDepth = std::numeric_limits<Messaging::EntryPositionNo>::max();
228 
229  /// Exposed depth of the order books
230  size_t orderBookDepth = FullOrderBookDepth;
231 
232  /// Start incremental feeds after instrument recovery.
233  ///
234  /// By default incremental feeds will be started before instrument feed on
235  /// the handler starting.
236  bool startIncrementalFeedsAfterInstrumentRecovery = false;
237 
238  /// Discard queued incremental packets included in snapshots.
239  bool discardQueuedIncrementalPacketsIncludedInSnapshots = false;
240 
241  /// Returns the string representation.
242  std::string toString() const
243  {
244  std::ostringstream out;
245  out << *this;
246  return out.str();
247  }
248 
249  /// Loads channel feed settings from the given channel configuration file.
250  HandlerSettings& loadFeeds(int channelId, const std::string& channelConfigFile);
251 
252  /// Gathers channel ids from the given channel configuration file.
253  static void gatherChannelIds(std::vector<int>& channelIds, const std::string& channelConfigFile);
254  };
255  }
256  }
257  }
258 }
Feed instrumentMulticastFeed
Instrument definition multicast feed.
Feed(const FeedDescriptor &aFeed, const FeedDescriptor &bFeed, FeedEngine *engine=0)
ONIXS_B3_UMDF_MD_API std::ostream & operator<<(std::ostream &stream, const LoggerSettings &settings)
Feed snapshotMulticastFeed
Snapshot recovery multicast feed.
#define ONIXS_B3_UMDF_MD_NULLPTR
Definition: Compiler.h:134
Messaging::UInt32 UInt32
Definition: Integral.h:37
bool valid() const
Returns true if the descriptor points to valid ip address.
Feed incrementalMulticastFeed
Incremental multicast feed.
Definition: Handler.h:31
std::string networkInterface
Specifies one or more network interfaces to use while joining the multicast group; use semi-colon del...
std::string networkInterfaceB
Specifies one or more network interfaces to use while joining the multicast group B; use semi-colon d...
std::string networkInterface
Specifies one or more network interfaces to use while joining the multicast group; use semi-colon del...
Handler configuration settings.
FeedDescriptor b
Feed descriptor.
std::string networkInterfaceA
Specifies one or more network interfaces to use while joining the multicast group A; use semi-colon d...
FeedDescriptor(const std::string &a, unsigned int port, const std::string &nif="")
std::string licenseDirectory
Path to the license directory.
std::string toString() const
Returns the string representation.
A shared memory pool for building order books.
Definition: OrderBook.h:88
The Feed Engine machinery.
Definition: FeedEngine.h:106
LoggerSettings loggerSettings
Logger settings.
FeedDescriptor a
Feed descriptor.