18 #ifndef DATA_FEED_MESSAGES_HPP
19 #define DATA_FEED_MESSAGES_HPP
26 #include "limit_order_book/structures.hpp"
42 enum class Side : char { Sell =
'S', Buy =
'B' };
51 stream << static_cast<char>(side);
63 return (-2 *
static_cast<bool>(
static_cast<char>(side) -
'B')) + 1;
74 return not (
static_cast<char>(side) -
'B');
96 return static_cast<Side>(
'S' - side * (
'S' -
'B'));
132 stream << static_cast<char>(uid);
182 std::ostream& stream,
186 <<
"length=" <<
static_cast<int>(header.length) <<
","
187 <<
"uid='" << header.uid <<
"',"
188 <<
"sequence=" << header.sequence <<
","
189 <<
"time=" << header.time <<
")";
198 std::ostringstream stream;
202 } __attribute__ ((packed));
223 header{
sizeof(
Clear), MessageID::Clear, sequence, time} { }
232 std::ostream& stream,
235 stream <<
"Clear(" << message.
header <<
")";
244 std::ostringstream stream;
248 } __attribute__ ((packed));
301 std::ostream& stream,
304 stream <<
"AddOrder(" << message.
header <<
","
305 <<
"uid=" << message.
uid <<
","
306 <<
"price=" << message.
price <<
","
307 <<
"quantity=" << message.
quantity <<
","
308 <<
"side='" << message.
side <<
"')";
317 std::ostringstream stream;
321 } __attribute__ ((packed));
359 std::ostream& stream,
362 stream <<
"DeleteOrder(" << message.
header <<
","
363 <<
"uid=" << message.
uid <<
")";
372 std::ostringstream stream;
376 } __attribute__ ((packed));
416 header{
sizeof(
Trade), MessageID::Trade, sequence, time},
429 std::ostream& stream,
432 stream <<
"Trade(" << message.
header <<
","
433 <<
"uid=" << message.
uid <<
","
434 <<
"price=" << message.
price <<
","
435 <<
"quantity=" << message.
quantity <<
","
436 <<
"side='" << message.
side <<
"')";
445 std::ostringstream stream;
449 } __attribute__ ((packed));
479 std::ostream& stream,
482 stream <<
"StartOfSession(" << message.
header <<
")";
491 std::ostringstream stream;
495 } __attribute__ ((packed));
525 std::ostream& stream,
528 stream <<
"EndOfSession(" << message.
header <<
")";
537 std::ostringstream stream;
541 } __attribute__ ((packed));
547 #endif // DATA_FEED_MESSAGES_HPP
friend std::ostream & operator<<(std::ostream &stream, const DeleteOrder &message)
Write the data from the message to a stream.
Definition: messages.hpp:358
Trade(OrderID uid_, Price price_, Quantity quantity_, Side side_, SequenceNumber sequence=0, TimeStamp time=0)
Initialize a new trade message.
Definition: messages.hpp:408
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:316
A message that indicates a market order matches with a limit order.
Definition: messages.hpp:387
Side
the possible sides for the LimitTree
Definition: structures.hpp:32
Clock::TimeStamp TimeStamp
A forward a declaration for the Clock timestamp.
Definition: messages.hpp:33
std::ostream & operator<<(std::ostream &stream, const Side &side)
Write the order side to a stream.
Definition: messages.hpp:50
const Quantity quantity
the quantity of the trade
Definition: messages.hpp:395
const OrderID uid
the MessageID for the limit order that matched
Definition: messages.hpp:391
A message that indicates a limit order was added to the book.
Definition: messages.hpp:332
const Header header
the message header that defines the template ID and length of message
Definition: messages.hpp:389
friend std::ostream & operator<<(std::ostream &stream, const Trade &message)
Write the data from the message to a stream.
Definition: messages.hpp:428
A message that indicates the end of a trading session.
Definition: messages.hpp:506
A message that indicates to clear all orders in the order book.
Definition: messages.hpp:213
uint64_t OrderID
A type for order prices.
Definition: messages.hpp:39
uint32_t SequenceNumber
A type for sequence numbers.
Definition: messages.hpp:36
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:490
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:536
A message that indicates the start of a trading session.
Definition: messages.hpp:460
AddOrder(OrderID uid_, Price price_, Quantity quantity_, Side side_, SequenceNumber sequence=0, TimeStamp time=0)
Initialize a new add order message.
Definition: messages.hpp:280
const OrderID uid
the day specific ID for the order to delete
Definition: messages.hpp:336
const Header header
the message header that defines the template ID and length of message
Definition: messages.hpp:261
const OrderID uid
the day specific ID for the order
Definition: messages.hpp:263
Logic for sending and receiving messages on a financial data feed.
Definition: heartbeat.hpp:28
constexpr bool side_to_bool(Side side)
Convert an order side character to a boolean value.
Definition: messages.hpp:71
std::deque< Packet > PacketQueue
A type for queuing packet buffers.
Definition: messages.hpp:113
uint64_t Price
A type for order prices.
Definition: messages.hpp:103
friend std::ostream & operator<<(std::ostream &stream, const StartOfSession &message)
Write the data from the message to a stream.
Definition: messages.hpp:478
uint32_t Quantity
A type for order quantities.
Definition: messages.hpp:100
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:444
uint64_t TimeStamp
a type for timestamps
Definition: clock.hpp:28
std::ostream & operator<<(std::ostream &stream, const MessageID &uid)
Definition: messages.hpp:131
DeleteOrder(OrderID uid_, SequenceNumber sequence=0, TimeStamp time=0)
Initialize a new delete order message.
Definition: messages.hpp:344
MessageID
Message IDs for messages in the protocol.
Definition: messages.hpp:116
const Header header
the message header that defines the template ID and length of message
Definition: messages.hpp:215
constexpr LOB::Side side_to_LOB_side(Side side)
Convert a side character to a LOB side value.
Definition: messages.hpp:82
StartOfSession(SequenceNumber sequence=0, TimeStamp time=0)
Initialize a new start of session message.
Definition: messages.hpp:469
Side
The side of an order.
Definition: messages.hpp:42
const Side side
the side of the market order
Definition: messages.hpp:397
const Header header
the message header that defines the template ID and length of message
Definition: messages.hpp:508
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:371
constexpr Side bool_to_side(bool side)
Convert a boolean to an order side.
Definition: messages.hpp:91
friend std::ostream & operator<<(std::ostream &stream, const Clear &message)
Write the data from the message to a stream.
Definition: messages.hpp:231
const Price price
the price of the order
Definition: messages.hpp:265
const Header header
the message header that defines the template ID and length of message
Definition: messages.hpp:334
const Price price
the execution price for the trade
Definition: messages.hpp:393
friend std::ostream & operator<<(std::ostream &stream, const AddOrder &message)
Write the data from the message to a stream.
Definition: messages.hpp:300
const Quantity quantity
the quantity of the order
Definition: messages.hpp:267
constexpr double side_to_double(Side side)
Convert an order side character to a double.
Definition: messages.hpp:60
friend std::ostream & operator<<(std::ostream &stream, const EndOfSession &message)
Write the data from the message to a stream.
Definition: messages.hpp:524
const Header header
the message header that defines the template ID and length of message
Definition: messages.hpp:462
EndOfSession(SequenceNumber sequence=0, TimeStamp time=0)
Initialize a new end of session message.
Definition: messages.hpp:515
A message that indicates a limit order was added to the book.
Definition: messages.hpp:259
Clear(SequenceNumber sequence=0, TimeStamp time=0)
Initialize a new clear book message.
Definition: messages.hpp:222
std::array< char, 40 > Packet
Definition: messages.hpp:110
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:243
const Side side
the side of the order
Definition: messages.hpp:269