JayBeams  0.1
Another project to have fun coding.
message_header.hpp
Go to the documentation of this file.
1 #ifndef jb_itch5_message_header_hpp
2 #define jb_itch5_message_header_hpp
3 
4 #include <jb/itch5/timestamp.hpp>
5 
6 #include <iosfwd>
7 #include <utility>
8 
9 namespace jb {
10 namespace itch5 {
11 
12 /**
13  * Define the header common to all ITCH 5.0 messages.
14  */
16  /**
17  * The type of message. ITCH-5.0 messages are identified by their
18  * first byte, with an ASCII value assigned to each message.
19  *
20  * offset=0
21  * width=1
22  */
24 
25  /**
26  * The stock locate number.
27  *
28  * Every stock receives a unique number in an ITCH-5.0 session. For
29  * messages that are not stock specific, this value is 0.
30  *
31  * offset=1
32  * width=2
33  */
35 
36  /**
37  * The "Tracking Number", a field designed for "internal NASDAQ purposes".
38  *
39  * The ITCH-5.0 specification does not document how this field is to
40  * be interpreted.
41  *
42  * offset=3
43  * width=2
44  */
46 
47  /**
48  * The message timestamp, in nanoseconds since midnight.
49  *
50  * All messages in a ITCH-5.0 session are timestamped, in
51  * nanoseconds since midnight for whatever day the session started
52  * running. All sessions are terminated before the end of the day.
53  *
54  * offset=5
55  * width=6
56  */
58 };
59 
60 /// Specialize decoder for a jb::itch5::message_header
61 template <bool validate>
62 struct decoder<validate, message_header> {
63  /// Please see the generic documentation for jb::itch5::decoder<>::r()
64  static message_header r(std::size_t size, void const* buf, std::size_t off) {
66  x.message_type = decoder<validate, std::uint8_t>::r(size, buf, off + 0);
67  x.stock_locate = decoder<validate, std::uint16_t>::r(size, buf, off + 1);
69  x.timestamp = decoder<validate, timestamp>::r(size, buf, off + 5);
70  return x;
71  }
72 };
73 
74 /// Streaming operator for jb::itch5::message_header.
75 std::ostream& operator<<(std::ostream& os, message_header const& x);
76 
77 } // namespace itch5
78 } // namespace jb
79 
80 #endif // jb_itch5_message_header_hpp
static message_header r(std::size_t size, void const *buf, std::size_t off)
Please see the generic documentation for jb::itch5::decoder<>::r()
Define the header common to all ITCH 5.0 messages.
static T r(std::size_t size, void const *msg, std::size_t offset)
Read a single message or field.
Define the interface to decode ITCH-5.0 messages and message fields.
Definition: decoder.hpp:24
int stock_locate
The stock locate number.
Represent a ITCH-5.0 timestamp.
Definition: timestamp.hpp:17
std::ostream & operator<<(std::ostream &os, add_order_message const &x)
Streaming operator for jb::itch5::add_order_message.
int tracking_number
The "Tracking Number", a field designed for "internal NASDAQ purposes".
int message_type
The type of message.
jb::itch5::timestamp timestamp
The message timestamp, in nanoseconds since midnight.
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7