JayBeams  0.1
Another project to have fun coding.
inside_levels_update.hpp
Go to the documentation of this file.
1 #ifndef jb_mktdata_inside_levels_update_hpp
2 #define jb_mktdata_inside_levels_update_hpp
3 
5 #include <jb/mktdata/feed_id.hpp>
9 
10 namespace jb {
11 namespace mktdata {
12 
13 /**
14  * A message representing the top N levels of a market.
15  *
16  * Many applications need more information than is provided in a Level
17  * I (aka top of book) feed, but are easier to implement and support
18  * if they do not have the complexity of a Level II or Level III feed,
19  * where one needs to deal with stateful message streams.
20  *
21  * This feed is a compromise, it is stateless, so simple to process,
22  * but it provides only the top N levels (typically 1, 4 or 8), so
23  * less information rich than a Level II or Level III feed. The
24  * assumption is that most of the information is in the top N levels
25  * anyway, so the loss is minimal.
26  *
27  * It also tradesoff simplicity for heavier message payloads, which
28  * might be a problem in some applications.
29  *
30  * @tparam N the number of levels to support.
31  */
32 template <std::size_t N>
34  static constexpr std::uint16_t mtype =
35  u'I' << 8 | detail::levels_name<N>::name;
36 
37  /// The message type, each message in JayBeams receives a unique
38  /// identifier
39  boost::endian::little_uint16_buf_t message_type;
40 
41  /**
42  * The message size.
43  *
44  * While the size of the message is implicit in the C++ structure
45  * used to represent them, we include the message size
46  */
47  boost::endian::little_uint16_buf_t message_size;
48 
49  /// The sequence number created by the feed handler
50  boost::endian::little_uint32_buf_t sequence_number;
51 
52  /// The market this data refers to
54 
55  /// The name of the feed handler used to parse and generate this
56  /// data
58 
59  /// The feedhandler (the software system that processes the feed and
60  /// generated this message), timestamps the message just before
61  /// sending it out.
63 
64  /// The source of the data within that feed, some feeds arbitrage
65  /// between multiple sources for the same data.
67 
68  /// Typically exchange feeds provide a timestamp (with feed-specific
69  /// semantics) for the event in the exchange that generated a
70  /// message. This field contains that timestamp.
72 
73  /// Typically each feed provides a timestamp (with feed-specific
74  /// semantics) for the message, this may be different from the
75  /// exchange timestamp.
77 
78  /// The id of the security
80 
81  /// The bid quantities, in shares, can be 0 if the level does not
82  /// exist or is not provided by the exchange. The bid levels are in
83  /// descending order of price.
84  boost::endian::little_uint32_buf_t bid_qty[N];
85 
86  /**
87  * Bid prices, in descending order.
88  *
89  * For the US markets, JayBeams uses prices in multiples of $0.0001.
90  * Since the US markets do not allow quotes in smaller intervals
91  * this is has no loss of accuracy. The maximum quote value in the
92  * US markets is $200,000, so at the prescribed granularity this
93  * fits in a 32-bit integer.
94  * TODO() - we need to define how this works in other markets,
95  * it is likely that this would require 64-bit integers for Japan
96  * for example.
97  */
98  boost::endian::little_uint32_buf_t bid_px[N];
99 
100  /// Offer quantities, in ascending order of prices
101  boost::endian::little_uint32_buf_t offer_qty[N];
102 
103  /**
104  * Offer prices, in ascending order.
105  *
106  * For the US markets, JayBeams uses prices in multiples of $0.0001.
107  * Since the US markets do not allow quotes in smaller intervals
108  * this is has no loss of accuracy. The maximum quote value in the
109  * US markets is $200,000, so at the prescribed granularity this
110  * fits in a 32-bit integer.
111  * TODO() - we need to define how this works in other markets,
112  * it is likely that this would require 64-bit integers for Japan
113  * for example.
114  * TODO() - likely this should be a message, like jb::mktdata::timestamp.
115  */
116  boost::endian::little_uint32_buf_t offer_px[N];
117 
118  //@{
119  /**
120  * Annotations
121  *
122  * These annotations are optional, they may not appear in a
123  * production feed to minimize message size and processing time. On
124  * a development instance these will be populated with the human
125  * readable representation of several fields.
126  * The receiver can detect whether these fields are present using
127  * the message_size field at the beginning.
128  */
130  /// The ISO-10383 market code
131  boost::endian::little_uint8_buf_t mic[market_id::mic_size];
132  /// The name of the feed
133  boost::endian::little_uint8_buf_t feed_name[feed_id::feed_name_size];
134  /// The name of the data source
135  boost::endian::little_uint8_buf_t source_name[feed_id::feed_name_size];
136  /// The JayBeams normalized ticker for the security
137  boost::endian::little_uint8_buf_t
139  /// The ticker as it appears in the feed
140  boost::endian::little_uint8_buf_t security_feed[security_id::feed_size];
141  };
142  /// The annotations field
144  //@}
145 };
146 
147 } // namespace mktdata
148 } // namespace jb
149 
150 #endif // jb_mktdata_inside_levels_update_hpp
Define the message name for a inside feed with N levels.
Definition: levels_name.hpp:21
boost::endian::little_uint8_buf_t feed_name[feed_id::feed_name_size]
The name of the feed.
static constexpr std::uint16_t mtype
timestamp feed_ts
Typically each feed provides a timestamp (with feed-specific semantics) for the message, this may be different from the exchange timestamp.
security_id security
The id of the security.
boost::endian::little_uint8_buf_t source_name[feed_id::feed_name_size]
The name of the data source.
static constexpr std::size_t mic_size
The space required to send a "Market Code Identifier" (often "MIC code", as "PIN number").
Definition: market_id.hpp:23
market_id market
The market this data refers to.
Security identifiers in JayBeam messages.
Definition: security_id.hpp:26
boost::endian::little_uint16_buf_t message_size
The message size.
Timestamp in JayBeam messages.
Definition: timestamp.hpp:16
A message representing the top N levels of a market.
Market identifier in JayBeam messages.
Definition: market_id.hpp:20
static constexpr std::size_t normalized_size
The maximum size for normalized security tickers in JayBeams.
Definition: security_id.hpp:42
Identifiers for market feeds.
Definition: feed_id.hpp:18
timestamp feedhandler_ts
The feedhandler (the software system that processes the feed and generated this message), timestamps the message just before sending it out.
boost::endian::little_uint8_buf_t security_feed[security_id::feed_size]
The ticker as it appears in the feed.
boost::endian::little_uint32_buf_t bid_px[N]
Bid prices, in descending order.
feed_id feed
The name of the feed handler used to parse and generate this data.
timestamp exchange_ts
Typically exchange feeds provide a timestamp (with feed-specific semantics) for the event in the exch...
feed_id source
The source of the data within that feed, some feeds arbitrage between multiple sources for the same d...
boost::endian::little_uint8_buf_t mic[market_id::mic_size]
The ISO-10383 market code.
boost::endian::little_uint32_buf_t bid_qty[N]
The bid quantities, in shares, can be 0 if the level does not exist or is not provided by the exchang...
boost::endian::little_uint32_buf_t sequence_number
The sequence number created by the feed handler.
boost::endian::little_uint32_buf_t offer_px[N]
Offer prices, in ascending order.
annotations_type annotations
The annotations field.
boost::endian::little_uint16_buf_t message_type
The message type, each message in JayBeams receives a unique identifier.
static constexpr std::size_t feed_name_size
The size for a feed name, in bytes.
Definition: feed_id.hpp:23
boost::endian::little_uint8_buf_t security_normalized[security_id::normalized_size]
The JayBeams normalized ticker for the security.
boost::endian::little_uint32_buf_t offer_qty[N]
Offer quantities, in ascending order of prices.
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7
static constexpr std::size_t feed_size
The maximum expected size for security tickers in JayBeams.
Definition: security_id.hpp:49