ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
messages.cpp
Go to the documentation of this file.
1#include "itch/messages.hpp"
2
3namespace itch {
4
5auto print_impl(std::ostream& out, const SystemEventMessage& msg) -> void {
6 out << "System Event:\n"
7 << " Timestamp: " << msg.timestamp << "\n"
8 << " Event Code: " << msg.event_code;
9}
10
11auto print_impl(std::ostream& out, const StockDirectoryMessage& msg) -> void {
12 out << "Stock Directory:\n"
13 << " Timestamp: " << msg.timestamp << "\n"
14 << " Stock: " << to_string(msg.stock, STOCK_LEN);
15}
16
17auto print_impl(std::ostream& out, const StockTradingActionMessage& msg) -> void {
18 out << "Stock Trading Action:\n"
19 << " Timestamp: " << msg.timestamp << "\n"
20 << " Stock: " << to_string(msg.stock, STOCK_LEN) << "\n"
21 << " State: " << msg.trading_state;
22}
23
24auto print_impl(std::ostream& out, const RegSHOMessage& msg) -> void {
25 out << "Reg SHO Message:\n"
26 << " Timestamp: " << msg.timestamp << "\n"
27 << " Stock: " << to_string(msg.stock, STOCK_LEN);
28}
29
30auto print_impl(std::ostream& out, const MarketParticipantPositionMessage& msg) -> void {
31 out << "Market Participant Position:\n"
32 << " Timestamp: " << msg.timestamp << "\n"
33 << " MPID: " << to_string(msg.mpid, 4) << "\n"
34 << " Stock: " << to_string(msg.stock, STOCK_LEN);
35}
36
37auto print_impl(std::ostream& out, const MWCBDeclineLevelMessage& msg) -> void {
38 out << "MWCB Decline Level:\n"
39 << " Timestamp: " << msg.timestamp << "\n"
40 << " Level 1: " << static_cast<double>(msg.level1) / MWCB_PRICE_DIVISOR;
41}
42
43auto print_impl(std::ostream& out, const MWCBStatusMessage& msg) -> void {
44 out << "MWCB Status:\n"
45 << " Timestamp: " << msg.timestamp << "\n"
46 << " Level: " << msg.breached_level;
47}
48
49auto print_impl(std::ostream& out, const IPOQuotingPeriodUpdateMessage& msg) -> void {
50 out << "IPO Quoting Period Update:\n"
51 << " Timestamp: " << msg.timestamp << "\n"
52 << " Stock: " << to_string(msg.stock, STOCK_LEN);
53}
54
55auto print_impl(std::ostream& out, const LULDAuctionCollarMessage& msg) -> void {
56 out << "LULD Auction Collar:\n"
57 << " Timestamp: " << msg.timestamp << "\n"
58 << " Stock: " << to_string(msg.stock, STOCK_LEN);
59}
60
61auto print_impl(std::ostream& out, const OperationalHaltMessage& msg) -> void {
62 out << "Operational Halt:\n"
63 << " Timestamp: " << msg.timestamp << "\n"
64 << " Stock: " << to_string(msg.stock, STOCK_LEN);
65}
66
67auto print_impl(std::ostream& out, const AddOrderMessage& msg) -> void {
68 out << "Add Order:\n"
69 << " Timestamp: " << msg.timestamp << "\n"
70 << " Stock: " << to_string(msg.stock, STOCK_LEN) << "\n"
71 << " Side: " << msg.buy_sell_indicator << "\n"
72 << " Shares: " << msg.shares << "\n"
73 << " Price: " << msg.price / PRICE_DIVISOR;
74}
75
76auto print_impl(std::ostream& out, const AddOrderMPIDAttributionMessage& msg) -> void {
77 out << "Add Order (MPID):\n"
78 << " Timestamp: " << msg.timestamp << "\n"
79 << " Stock: " << to_string(msg.stock, STOCK_LEN) << "\n"
80 << " MPID: " << to_string(msg.attribution, 4) << "\n"
81 << " Side: " << msg.buy_sell_indicator << "\n"
82 << " Shares: " << msg.shares << "\n"
83 << " Price: " << msg.price / PRICE_DIVISOR;
84}
85
86auto print_impl(std::ostream& out, const OrderExecutedMessage& msg) -> void {
87 out << "Order Executed:\n"
88 << " Timestamp: " << msg.timestamp << "\n"
89 << " Ref#: " << msg.order_reference_number << "\n"
90 << " Shares: " << msg.executed_shares;
91}
92
93auto print_impl(std::ostream& out, const OrderExecutedWithPriceMessage& msg) -> void {
94 out << "Order Executed w/ Price:\n"
95 << " Timestamp: " << msg.timestamp << "\n"
96 << " Ref#: " << msg.order_reference_number << "\n"
97 << " Price: " << msg.execution_price / PRICE_DIVISOR;
98}
99
100auto print_impl(std::ostream& out, const OrderCancelMessage& msg) -> void {
101 out << "Order Cancel:\n"
102 << " Timestamp: " << msg.timestamp << "\n"
103 << " Ref#: " << msg.order_reference_number << "\n"
104 << " Cancelled Shares: " << msg.cancelled_shares;
105}
106
107auto print_impl(std::ostream& out, const OrderDeleteMessage& msg) -> void {
108 out << "Order Delete:\n"
109 << " Timestamp: " << msg.timestamp << "\n"
110 << " Ref#: " << msg.order_reference_number;
111}
112
113auto print_impl(std::ostream& out, const OrderReplaceMessage& msg) -> void {
114 out << "Order Replace:\n"
115 << " Timestamp: " << msg.timestamp << "\n"
116 << " Original Ref#: " << msg.original_order_reference_number << "\n"
117 << " New Ref#: " << msg.new_order_reference_number << "\n"
118 << " Shares: " << msg.shares << "\n"
119 << " Price: " << msg.price / PRICE_DIVISOR;
120}
121
122auto print_impl(std::ostream& out, const NonCrossTradeMessage& msg) -> void {
123 out << "Non-Cross Trade:\n"
124 << " Timestamp: " << msg.timestamp << "\n"
125 << " Stock: " << to_string(msg.stock, STOCK_LEN) << "\n"
126 << " Side: " << msg.buy_sell_indicator << "\n"
127 << " Shares: " << msg.shares << "\n"
128 << " Price: " << msg.price / PRICE_DIVISOR;
129}
130
131auto print_impl(std::ostream& out, const CrossTradeMessage& msg) -> void {
132 out << "Cross Trade:\n"
133 << " Timestamp: " << msg.timestamp << "\n"
134 << " Stock: " << to_string(msg.stock, STOCK_LEN) << "\n"
135 << " Shares: " << msg.shares << "\n"
136 << " Cross Price: " << msg.cross_price / PRICE_DIVISOR << "\n"
137 << " Match#: " << msg.match_number << "\n"
138 << " Cross Type: " << msg.cross_type;
139}
140
141auto print_impl(std::ostream& out, const BrokenTradeMessage& msg) -> void {
142 out << "Broken Trade:\n"
143 << " Timestamp: " << msg.timestamp << "\n"
144 << " Match#: " << msg.match_number;
145}
146
147auto print_impl(std::ostream& out, const NOIIMessage& msg) -> void {
148 out << "NOII Message:\n"
149 << " Timestamp: " << msg.timestamp << "\n"
150 << " Stock: " << to_string(msg.stock, STOCK_LEN) << "\n"
151 << " Paired Shares: " << msg.paired_shares << "\n"
152 << " Imbalance Shares: " << msg.imbalance_shares << "\n"
153 << " Imbalance Direction: " << msg.imbalance_direction << "\n"
154 << " Far Price: " << msg.far_price / PRICE_DIVISOR << "\n"
155 << " Near Price: " << msg.near_price / PRICE_DIVISOR << "\n"
156 << " Reference Price: " << msg.current_reference_price / PRICE_DIVISOR << "\n"
157 << " Cross Type: " << msg.cross_type << "\n"
158 << " Price Variation Indicator: " << msg.price_variation_indicator;
159}
160
161auto print_impl(std::ostream& out, const RetailPriceImprovementIndicatorMessage& msg) -> void {
162 out << "RPII Message:\n"
163 << " Timestamp: " << msg.timestamp << "\n"
164 << " Stock: " << to_string(msg.stock, STOCK_LEN);
165}
166
167auto print_impl(std::ostream& out, const DLCRMessage& msg) -> void {
168 out << "DLCR Message:\n"
169 << " Timestamp: " << msg.timestamp << "\n"
170 << " Stock: " << to_string(msg.stock, STOCK_LEN);
171}
172
173auto print_message(std::ostream& out, const Message& msg) -> void {
174 std::visit([&out](auto&& arg) { print_impl(out, arg); }, msg);
175}
176
177auto operator<<(std::ostream& out, const Message& msg) -> std::ostream& {
178 print_message(out, msg);
179 return out;
180}
181
182} // namespace itch
Defines every ITCH 5.0 message struct, the Message variant, and the stream-printing helpers used to f...
constexpr int STOCK_LEN
Definition messages.hpp:485
constexpr double PRICE_DIVISOR
Definition messages.hpp:486
std::variant< SystemEventMessage, StockDirectoryMessage, StockTradingActionMessage, RegSHOMessage, MarketParticipantPositionMessage, MWCBDeclineLevelMessage, MWCBStatusMessage, IPOQuotingPeriodUpdateMessage, LULDAuctionCollarMessage, OperationalHaltMessage, AddOrderMessage, AddOrderMPIDAttributionMessage, OrderExecutedMessage, OrderExecutedWithPriceMessage, OrderCancelMessage, OrderDeleteMessage, OrderReplaceMessage, NonCrossTradeMessage, CrossTradeMessage, BrokenTradeMessage, NOIIMessage, RetailPriceImprovementIndicatorMessage, DLCRMessage > Message
A variant able to hold any one of the ITCH 5.0 message structs.
Definition messages.hpp:483
auto print_message(std::ostream &out, const Message &msg) -> void
Dispatches to the print_impl overload matching the active alternative of msg and writes its formatted...
Definition messages.cpp:173
auto operator<<(std::ostream &out, const Message &msg) -> std::ostream &
Streams a formatted representation of msg to out.
Definition messages.cpp:177
auto to_string(const char *source, size_t size) -> std::string
Converts a fixed-width character array to a string, trimming trailing spaces and NUL characters.
Definition messages.hpp:495
constexpr double MWCB_PRICE_DIVISOR
Definition messages.hpp:487
auto print_impl(std::ostream &out, const SystemEventMessage &msg) -> void
Per-message-type stream formatter family, used internally by print_message to dispatch to the correct...
Definition messages.cpp:5
Add Order, With MPID Attribution (F): like Add Order, but attributed to a market participant.
Definition messages.hpp:229
Add Order, No MPID Attribution (A): a new displayable order has been accepted and placed on the book.
Definition messages.hpp:211
Broken Trade (B): a previously disseminated execution has been broken and should be removed from any ...
Definition messages.hpp:370
Cross Trade (Q): the result of a cross (opening, closing, halt/IPO cross) for a security.
Definition messages.hpp:352
Direct Listing with Capital Raise Price Discovery (O): price-discovery data for a Direct Listing with...
Definition messages.hpp:424
IPO Quoting Period Update (K): the anticipated IPO quotation release time and price for a security.
Definition messages.hpp:159
LULD Auction Collar (J): the auction collar thresholds for a security in a Limit-Up Limit-Down tradin...
Definition messages.hpp:175
MWCB Decline Level (V): the Market-Wide Circuit Breaker breach points for the day.
Definition messages.hpp:130
MWCB Status (W): notification that a Market-Wide Circuit Breaker level has been breached.
Definition messages.hpp:145
Market Participant Position (L): a market participant's (market maker's) status in a security.
Definition messages.hpp:109
Net Order Imbalance Indicator (I): the imbalance and price-discovery data disseminated during the ope...
Definition messages.hpp:385
Trade, Non-Cross (P): an execution of a non-displayable order.
Definition messages.hpp:333
Operational Halt (h): an operational halt or resumption for a security on a specific market center.
Definition messages.hpp:194
Order Cancel (X): a partial cancellation reduced the shares of a resting order.
Definition messages.hpp:285
Order Delete (D): a resting order was cancelled in its entirety and removed from the book.
Definition messages.hpp:299
Order Executed (E): a resting order was executed in whole or in part at its display price.
Definition messages.hpp:249
Order Executed With Price (C): a resting order was executed at a price different from its display pri...
Definition messages.hpp:266
Order Replace (U): a resting order was replaced with a new order at a new reference number,...
Definition messages.hpp:314
Reg SHO Short Sale Price Test Restriction (Y): the Reg SHO short-sale restriction state for a securit...
Definition messages.hpp:94
Retail Price Improvement Indicator (N): the presence of retail price improvement interest on the bid,...
Definition messages.hpp:408
Stock Directory (R): the trading and listing reference data for a security, disseminated at the start...
Definition messages.hpp:49
Stock Trading Action (H): a change in the trading status of a security (halted, paused,...
Definition messages.hpp:77
System Event (S): signals a market or data-feed handler event.
Definition messages.hpp:33