CppTrader  1.0.4.0
C++ Trader
itch_handler.inl
Go to the documentation of this file.
1 
9 namespace CppTrader {
10 namespace ITCH {
11 
12 template <class TOutputStream>
13 inline TOutputStream& operator<<(TOutputStream& stream, const SystemEventMessage& message)
14 {
15  stream << "SystemEventMessage(Type=" << CppCommon::WriteChar(message.Type)
16  << "; StockLocate=" << message.StockLocate
17  << "; TrackingNumber=" << message.TrackingNumber
18  << "; Timestamp=" << message.Timestamp
19  << "; EventCode=" << CppCommon::WriteChar(message.EventCode)
20  << ")";
21  return stream;
22 }
23 
24 template <class TOutputStream>
25 inline TOutputStream& operator<<(TOutputStream& stream, const StockDirectoryMessage& message)
26 {
27  stream << "StockDirectoryMessage(Type=" << CppCommon::WriteChar(message.Type)
28  << "; StockLocate=" << message.StockLocate
29  << "; TrackingNumber=" << message.TrackingNumber
30  << "; Timestamp=" << message.Timestamp
31  << "; Stock=" << CppCommon::WriteString(message.Stock)
32  << "; MarketCategory=" << CppCommon::WriteChar(message.MarketCategory)
33  << "; FinancialStatusIndicator=" << CppCommon::WriteChar(message.FinancialStatusIndicator)
34  << "; RoundLotSize=" << message.RoundLotSize
35  << "; RoundLotsOnly=" << CppCommon::WriteChar(message.RoundLotsOnly)
36  << "; IssueClassification=" << CppCommon::WriteChar(message.IssueClassification)
37  << "; IssueSubType=" << CppCommon::WriteString(message.IssueSubType)
38  << "; Authenticity=" << CppCommon::WriteChar(message.Authenticity)
39  << "; ShortSaleThresholdIndicator=" << CppCommon::WriteChar(message.ShortSaleThresholdIndicator)
40  << "; IPOFlag=" << CppCommon::WriteChar(message.IPOFlag)
41  << "; LULDReferencePriceTier=" << CppCommon::WriteChar(message.LULDReferencePriceTier)
42  << "; ETPFlag=" << CppCommon::WriteChar(message.ETPFlag)
43  << "; ETPLeverageFactor=" << message.ETPLeverageFactor
44  << "; InverseIndicator=" << CppCommon::WriteChar(message.InverseIndicator)
45  << ")";
46  return stream;
47 }
48 
49 template <class TOutputStream>
50 inline TOutputStream& operator<<(TOutputStream& stream, const StockTradingActionMessage& message)
51 {
52  stream << "StockTradingActionMessage(Type=" << CppCommon::WriteChar(message.Type)
53  << "; StockLocate=" << message.StockLocate
54  << "; TrackingNumber=" << message.TrackingNumber
55  << "; Timestamp=" << message.Timestamp
56  << "; Stock=" << CppCommon::WriteString(message.Stock)
57  << "; TradingState=" << CppCommon::WriteChar(message.TradingState)
58  << "; Reserved=" << CppCommon::WriteChar(message.Reserved)
59  << "; Reason=" << CppCommon::WriteChar(message.Reason)
60  << ")";
61  return stream;
62 }
63 
64 template <class TOutputStream>
65 inline TOutputStream& operator<<(TOutputStream& stream, const RegSHOMessage& message)
66 {
67  stream << "RegSHOMessage(Type=" << CppCommon::WriteChar(message.Type)
68  << "; StockLocate=" << message.StockLocate
69  << "; TrackingNumber=" << message.TrackingNumber
70  << "; Timestamp=" << message.Timestamp
71  << "; Stock=" << CppCommon::WriteString(message.Stock)
72  << "; RegSHOAction=" << CppCommon::WriteChar(message.RegSHOAction)
73  << ")";
74  return stream;
75 }
76 
77 template <class TOutputStream>
78 inline TOutputStream& operator<<(TOutputStream& stream, const MarketParticipantPositionMessage& message)
79 {
80  stream << "MarketParticipantPositionMessage(Type=" << CppCommon::WriteChar(message.Type)
81  << "; StockLocate=" << message.StockLocate
82  << "; TrackingNumber=" << message.TrackingNumber
83  << "; Timestamp=" << message.Timestamp
84  << "; MPID=" << CppCommon::WriteString(message.MPID)
85  << "; Stock=" << CppCommon::WriteString(message.Stock)
86  << "; PrimaryMarketMaker=" << CppCommon::WriteChar(message.PrimaryMarketMaker)
87  << "; MarketMakerMode=" << CppCommon::WriteChar(message.MarketMakerMode)
88  << "; MarketParticipantState=" << CppCommon::WriteChar(message.MarketParticipantState)
89  << ")";
90  return stream;
91 }
92 
93 template <class TOutputStream>
94 inline TOutputStream& operator<<(TOutputStream& stream, const MWCBDeclineMessage& message)
95 {
96  stream << "MWCBDeclineMessage(Type=" << CppCommon::WriteChar(message.Type)
97  << "; StockLocate=" << message.StockLocate
98  << "; TrackingNumber=" << message.TrackingNumber
99  << "; Timestamp=" << message.Timestamp
100  << "; Level1=" << message.Level1
101  << "; Level2=" << message.Level2
102  << "; Level3=" << message.Level3
103  << ")";
104  return stream;
105 }
106 
107 template <class TOutputStream>
108 inline TOutputStream& operator<<(TOutputStream& stream, const MWCBStatusMessage& message)
109 {
110  stream << "MWCBStatusMessage(Type=" << CppCommon::WriteChar(message.Type)
111  << "; StockLocate=" << message.StockLocate
112  << "; TrackingNumber=" << message.TrackingNumber
113  << "; Timestamp=" << message.Timestamp
114  << "; BreachedLevel=" << message.BreachedLevel
115  << ")";
116  return stream;
117 }
118 
119 template <class TOutputStream>
120 inline TOutputStream& operator<<(TOutputStream& stream, const IPOQuotingMessage& message)
121 {
122  stream << "IPOQuotingMessage(Type=" << CppCommon::WriteChar(message.Type)
123  << "; StockLocate=" << message.StockLocate
124  << "; TrackingNumber=" << message.TrackingNumber
125  << "; Timestamp=" << message.Timestamp
126  << "; Stock=" << CppCommon::WriteString(message.Stock)
127  << "; IPOReleaseTime=" << message.IPOReleaseTime
128  << "; IPOReleaseQualifier=" << message.IPOReleaseQualifier
129  << "; IPOPrice=" << message.IPOPrice
130  << ")";
131  return stream;
132 }
133 
134 template <class TOutputStream>
135 inline TOutputStream& operator<<(TOutputStream& stream, const AddOrderMessage& message)
136 {
137  stream << "AddOrderMessage(Type=" << CppCommon::WriteChar(message.Type)
138  << "; StockLocate=" << message.StockLocate
139  << "; TrackingNumber=" << message.TrackingNumber
140  << "; Timestamp=" << message.Timestamp
141  << "; OrderReferenceNumber=" << message.OrderReferenceNumber
142  << "; BuySellIndicator=" << CppCommon::WriteChar(message.BuySellIndicator)
143  << "; Shares=" << message.Shares
144  << "; Stock=" << CppCommon::WriteString(message.Stock)
145  << "; Price=" << message.Price
146  << ")";
147  return stream;
148 }
149 
150 template <class TOutputStream>
151 inline TOutputStream& operator<<(TOutputStream& stream, const AddOrderMPIDMessage& message)
152 {
153  stream << "AddOrderMPIDMessage(Type=" << CppCommon::WriteChar(message.Type)
154  << "; StockLocate=" << message.StockLocate
155  << "; TrackingNumber=" << message.TrackingNumber
156  << "; Timestamp=" << message.Timestamp
157  << "; OrderReferenceNumber=" << message.OrderReferenceNumber
158  << "; BuySellIndicator=" << CppCommon::WriteChar(message.BuySellIndicator)
159  << "; Shares=" << message.Shares
160  << "; Stock=" << CppCommon::WriteString(message.Stock)
161  << "; Price=" << message.Price
162  << "; Attribution=" << CppCommon::WriteChar(message.Attribution)
163  << ")";
164  return stream;
165 }
166 
167 template <class TOutputStream>
168 inline TOutputStream& operator<<(TOutputStream& stream, const OrderExecutedMessage& message)
169 {
170  stream << "OrderExecutedMessage(Type=" << CppCommon::WriteChar(message.Type)
171  << "; StockLocate=" << message.StockLocate
172  << "; TrackingNumber=" << message.TrackingNumber
173  << "; Timestamp=" << message.Timestamp
174  << "; OrderReferenceNumber=" << message.OrderReferenceNumber
175  << "; ExecutedShares=" << message.ExecutedShares
176  << "; MatchNumber=" << message.MatchNumber
177  << ")";
178  return stream;
179 }
180 
181 template <class TOutputStream>
182 inline TOutputStream& operator<<(TOutputStream& stream, const OrderExecutedWithPriceMessage& message)
183 {
184  stream << "OrderExecutedWithPriceMessage(Type=" << CppCommon::WriteChar(message.Type)
185  << "; StockLocate=" << message.StockLocate
186  << "; TrackingNumber=" << message.TrackingNumber
187  << "; Timestamp=" << message.Timestamp
188  << "; OrderReferenceNumber=" << message.OrderReferenceNumber
189  << "; ExecutedShares=" << message.ExecutedShares
190  << "; MatchNumber=" << message.MatchNumber
191  << "; Printable=" << CppCommon::WriteChar(message.Printable)
192  << "; ExecutionPrice=" << message.ExecutionPrice
193  << ")";
194  return stream;
195 }
196 
197 template <class TOutputStream>
198 inline TOutputStream& operator<<(TOutputStream& stream, const OrderCancelMessage& message)
199 {
200  stream << "OrderCancelMessage(Type=" << CppCommon::WriteChar(message.Type)
201  << "; StockLocate=" << message.StockLocate
202  << "; TrackingNumber=" << message.TrackingNumber
203  << "; Timestamp=" << message.Timestamp
204  << "; OrderReferenceNumber=" << message.OrderReferenceNumber
205  << "; CanceledShares=" << message.CanceledShares
206  << ")";
207  return stream;
208 }
209 
210 template <class TOutputStream>
211 inline TOutputStream& operator<<(TOutputStream& stream, const OrderDeleteMessage& message)
212 {
213  stream << "OrderDeleteMessage(Type=" << CppCommon::WriteChar(message.Type)
214  << "; StockLocate=" << message.StockLocate
215  << "; TrackingNumber=" << message.TrackingNumber
216  << "; Timestamp=" << message.Timestamp
217  << "; OrderReferenceNumber=" << message.OrderReferenceNumber
218  << ")";
219  return stream;
220 }
221 
222 template <class TOutputStream>
223 inline TOutputStream& operator<<(TOutputStream& stream, const OrderReplaceMessage& message)
224 {
225  stream << "OrderReplaceMessage(Type=" << CppCommon::WriteChar(message.Type)
226  << "; StockLocate=" << message.StockLocate
227  << "; TrackingNumber=" << message.TrackingNumber
228  << "; Timestamp=" << message.Timestamp
229  << "; OriginalOrderReferenceNumber=" << message.OriginalOrderReferenceNumber
230  << "; NewOrderReferenceNumber=" << message.NewOrderReferenceNumber
231  << "; Shares=" << message.Shares
232  << "; Price=" << message.Price
233  << ")";
234  return stream;
235 }
236 
237 template <class TOutputStream>
238 inline TOutputStream& operator<<(TOutputStream& stream, const TradeMessage& message)
239 {
240  stream << "TradeMessage(Type=" << CppCommon::WriteChar(message.Type)
241  << "; StockLocate=" << message.StockLocate
242  << "; TrackingNumber=" << message.TrackingNumber
243  << "; Timestamp=" << message.Timestamp
244  << "; OrderReferenceNumber=" << message.OrderReferenceNumber
245  << "; BuySellIndicator=" << CppCommon::WriteChar(message.BuySellIndicator)
246  << "; Shares=" << message.Shares
247  << "; Stock=" << CppCommon::WriteString(message.Stock)
248  << "; Price=" << message.Price
249  << "; MatchNumber=" << message.MatchNumber
250  << ")";
251  return stream;
252 }
253 
254 template <class TOutputStream>
255 inline TOutputStream& operator<<(TOutputStream& stream, const CrossTradeMessage& message)
256 {
257  stream << "CrossTradeMessage(Type=" << CppCommon::WriteChar(message.Type)
258  << "; StockLocate=" << message.StockLocate
259  << "; TrackingNumber=" << message.TrackingNumber
260  << "; Timestamp=" << message.Timestamp
261  << "; Shares=" << message.Shares
262  << "; Stock=" << CppCommon::WriteString(message.Stock)
263  << "; CrossPrice=" << message.CrossPrice
264  << "; MatchNumber=" << message.MatchNumber
265  << "; CrossType=" << CppCommon::WriteChar(message.CrossType)
266  << ")";
267  return stream;
268 }
269 
270 template <class TOutputStream>
271 inline TOutputStream& operator<<(TOutputStream& stream, const BrokenTradeMessage& message)
272 {
273  stream << "BrokenTradeMessage(Type=" << CppCommon::WriteChar(message.Type)
274  << "; StockLocate=" << message.StockLocate
275  << "; TrackingNumber=" << message.TrackingNumber
276  << "; Timestamp=" << message.Timestamp
277  << "; MatchNumber=" << message.MatchNumber
278  << ")";
279  return stream;
280 }
281 
282 template <class TOutputStream>
283 inline TOutputStream& operator<<(TOutputStream& stream, const NOIIMessage& message)
284 {
285  stream << "NOIIMessage(Type=" << CppCommon::WriteChar(message.Type)
286  << "; StockLocate=" << message.StockLocate
287  << "; TrackingNumber=" << message.TrackingNumber
288  << "; Timestamp=" << message.Timestamp
289  << "; PairedShares=" << message.PairedShares
290  << "; ImbalanceShares=" << message.ImbalanceShares
291  << "; ImbalanceDirection=" << CppCommon::WriteChar(message.ImbalanceDirection)
292  << "; Stock=" << CppCommon::WriteString(message.Stock)
293  << "; FarPrice=" << message.FarPrice
294  << "; NearPrice=" << message.NearPrice
295  << "; CurrentReferencePrice=" << message.CurrentReferencePrice
296  << "; CrossType=" << CppCommon::WriteChar(message.CrossType)
297  << "; PriceVariationIndicator=" << CppCommon::WriteChar(message.PriceVariationIndicator)
298  << ")";
299  return stream;
300 }
301 
302 template <class TOutputStream>
303 inline TOutputStream& operator<<(TOutputStream& stream, const RPIIMessage& message)
304 {
305  stream << "RPIIMessage(Type=" << CppCommon::WriteChar(message.Type)
306  << "; StockLocate=" << message.StockLocate
307  << "; TrackingNumber=" << message.TrackingNumber
308  << "; Timestamp=" << message.Timestamp
309  << "; Stock=" << CppCommon::WriteString(message.Stock)
310  << "; InterestFlag=" << CppCommon::WriteChar(message.InterestFlag)
311  << ")";
312  return stream;
313 }
314 
315 template <class TOutputStream>
316 inline TOutputStream& operator<<(TOutputStream& stream, const LULDAuctionCollarMessage& message)
317 {
318  stream << "LULDAuctionCollarMessage(Type=" << CppCommon::WriteChar(message.Type)
319  << "; StockLocate=" << message.StockLocate
320  << "; TrackingNumber=" << message.TrackingNumber
321  << "; Timestamp=" << message.Timestamp
322  << "; Stock=" << CppCommon::WriteString(message.Stock)
323  << "; AuctionCollarReferencePrice=" << message.AuctionCollarReferencePrice
324  << "; UpperAuctionCollarPrice=" << message.UpperAuctionCollarPrice
325  << "; LowerAuctionCollarPrice=" << message.LowerAuctionCollarPrice
326  << "; AuctionCollarExtension=" << message.AuctionCollarExtension
327  << ")";
328  return stream;
329 }
330 
331 template <class TOutputStream>
332 inline TOutputStream& operator<<(TOutputStream& stream, const UnknownMessage& message)
333 {
334  stream << "UnknownMessage(Type=" << CppCommon::WriteChar(message.Type) << ")";
335  return stream;
336 }
337 
338 template <size_t N>
339 inline size_t ITCHHandler::ReadString(const void* buffer, char (&str)[N])
340 {
341  std::memcpy(str, buffer, N);
342 
343  return N;
344 }
345 
346 inline size_t ITCHHandler::ReadTimestamp(const void* buffer, uint64_t& value)
347 {
348  if (CppCommon::Endian::IsBigEndian())
349  {
350  ((uint8_t*)&value)[0] = 0;
351  ((uint8_t*)&value)[1] = 0;
352  ((uint8_t*)&value)[2] = 0;
353  ((uint8_t*)&value)[3] = 0;
354  ((uint8_t*)&value)[4] = 0;
355  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[0];
356  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[1];
357  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[2];
358  }
359  else
360  {
361  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[2];
362  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
363  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[0];
364  ((uint8_t*)&value)[3] = 0;
365  ((uint8_t*)&value)[4] = 0;
366  ((uint8_t*)&value)[5] = 0;
367  ((uint8_t*)&value)[6] = 0;
368  ((uint8_t*)&value)[7] = 0;
369 
370  }
371 
372  return 6;
373 }
374 
375 } // namespace ITCH
376 } // namespace CppTrader
TOutputStream & operator<<(TOutputStream &stream, const SystemEventMessage &message)
C++ Trader project definitions.
Definition: errors.h:16
Add Order with MPID Attribution Message.
Definition: itch_handler.h:174
IPO Quoting Period Update Message.
Definition: itch_handler.h:141
Limit Up – Limit Down (LULD) Auction Collar Message.
Definition: itch_handler.h:350
MWCB Decline Level Message.
Definition: itch_handler.h:113
Market Participant Position Message.
Definition: itch_handler.h:96
Net Order Imbalance Indicator (NOII) Message.
Definition: itch_handler.h:315
Order Executed With Price Message.
Definition: itch_handler.h:207
Retail Price Improvement Indicator (RPII) Message.
Definition: itch_handler.h:336
Reg SHO Short Sale Price Test Restricted Indicator Message.
Definition: itch_handler.h:82
Stock Trading Action Message.
Definition: itch_handler.h:66