CBOE Emulator  1.0
messages.hpp
1 // Structures for order entry messages.
2 // Copyright 2020 Christian Kauten
3 //
4 // Author: Christian Kauten (kautenja@auburn.edu)
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef ORDER_ENTRY_MESSAGES_HPP
19 #define ORDER_ENTRY_MESSAGES_HPP
20 
21 #include <array>
22 #include <deque>
23 #include <iostream>
24 #include <sstream>
25 #include <string>
26 #include "limit_order_book/structures.hpp"
27 #include "clock.hpp"
28 
30 namespace OrderEntry {
31 
34 
36 typedef uint32_t SequenceNumber;
37 
39 typedef std::array<char, 4> Username;
40 
46 Username make_username(std::string username) {
47  if (username.length() != sizeof(Username))
48  throw "username must have " + std::to_string(sizeof(Username)) + " characters!";
49  Username arr;
50  std::copy(&username[0], &username[0] + sizeof(Username), arr.data());
51  return arr;
52 }
53 
55 typedef std::array<char, 12> Password;
56 
62 Password make_password(std::string password) {
63  if (password.length() != sizeof(Password))
64  throw "password must have " + std::to_string(sizeof(Password)) + " characters!";
65  Password arr;
66  std::copy(&password[0], &password[0] + sizeof(Password), arr.data());
67  return arr;
68 }
69 
71 enum class Side : char { Sell = 'S', Buy = 'B' };
72 
79 inline std::ostream& operator<<(std::ostream& stream, const Side& side) {
80  stream << static_cast<char>(side);
81  return stream;
82 }
83 
89 inline constexpr double side_to_double(Side side) {
90  // B is ASCII 66
91  // S is ASCII 83
92  // B comes before S in ASCII, if we remove B and have 0, i.e., false, then
93  // the side is buy.
94  return (-2 * static_cast<bool>(static_cast<char>(side) - 'B')) + 1;
95 }
96 
102 inline constexpr bool side_to_bool(Side side) {
103  // B is ASCII 66
104  // S is ASCII 83
105  // B comes before S in ASCII, if we remove B and have 0, i.e., false, then
106  // the side is buy.
107  return not (static_cast<char>(side) - 'B');
108 }
109 
115 inline constexpr LOB::Side side_to_LOB_side(Side side) {
116  return static_cast<LOB::Side>(side_to_bool(side));
117 }
118 
124 inline constexpr Side bool_to_side(bool side) {
125  // B is ASCII 66
126  // S is ASCII 83
127  // start with ASCII S, which is larger than ASCII B, if side is true remove
128  // the difference between ASCII S and B to get ASCII B
129  return static_cast<Side>('S' - side * ('S' - 'B'));
130 }
131 
133 typedef uint32_t Quantity;
134 
136 typedef uint64_t Price;
137 
139 typedef uint64_t OrderID;
140 
142 namespace Messages {
143 
146 typedef std::array<char, 40> Packet;
147 
149 typedef std::deque<Packet> PacketQueue;
150 
152 enum class MessageID : char {
153  LoginRequest = 'L',
154  LoginResponse = 'l',
155  LogoutRequest = 'O',
156  LogoutResponse = 'o',
157  OrderRequest = 'N',
158  OrderResponse = 'n',
159  CancelRequest = 'C',
160  CancelResponse = 'c',
161  ReplaceRequest = 'R', // cancel and replace, but faster (one message)
162  ReplaceResponse = 'r',
163  // ModifyRequest = 'M', // modify without cancel (decrement order amount)
164  // ModifyResponse = 'm',
165  PurgeRequest = 'P', // cancel all orders
166  PurgeResponse = 'p',
167  TradeResponse = 't'
168 };
169 
176 inline std::ostream& operator<<(std::ostream& stream, const MessageID& uid) {
177  stream << static_cast<char>(uid);
178  return stream;
179 }
180 
181 // ---------------------------------------------------------------------------
182 // MARK: Header
183 // ---------------------------------------------------------------------------
184 
190 struct Header {
192  const uint16_t length;
194  const MessageID uid;
196  const uint8_t padding = 0;
199 
206  Header(uint16_t length_, MessageID uid_, SequenceNumber sequence_ = 0) :
207  length(length_),
208  uid(uid_),
209  sequence(sequence_) { }
210 
217  inline friend std::ostream& operator<<(
218  std::ostream& stream,
219  const Header& header
220  ) {
221  stream << "Header("
222  << "length=" << header.length << ","
223  << "uid='" << header.uid << "',"
224  << "sequence=" << header.sequence << ")";
225  return stream;
226  }
227 
232  inline std::string to_string() const {
233  std::ostringstream stream;
234  stream << this;
235  return stream.str();
236  }
237 } __attribute__ ((packed));
238 
239 // ---------------------------------------------------------------------------
240 // MARK: LoginRequest
241 // ---------------------------------------------------------------------------
242 
248 struct LoginRequest {
250  const Header header;
255 
262  LoginRequest(SequenceNumber sequence, Username username_, Password password_) :
263  header{sizeof(LoginRequest), MessageID::LoginRequest, sequence},
264  username(username_),
265  password(password_) { }
266 
268  inline std::string username_string() const {
269  return std::string(std::begin(username), std::end(username));
270  }
271 
273  inline std::string password_string() const {
274  return std::string(std::begin(password), std::end(password));
275  }
276 
283  inline friend std::ostream& operator<<(
284  std::ostream& stream,
285  const LoginRequest& message
286  ) {
287  stream << "LoginRequest(header=" << message.header << ",username=\"";
288  stream.write(message.username.data(), 4);
289  stream << "\",password=\"";
290  stream.write(message.password.data(), 12);
291  stream << "\")";
292  return stream;
293  }
294 
299  inline std::string to_string() const {
300  std::ostringstream stream;
301  stream << this;
302  return stream.str();
303  }
304 } __attribute__ ((packed));
305 
306 // ---------------------------------------------------------------------------
307 // MARK: LoginResponse
308 // ---------------------------------------------------------------------------
309 
311 enum class LoginResponseStatus : char {
312  Accepted = 'A', // the login request was accepted
313  NotAuthorized = 'N', // the credentials are incorrect
314  AlreadyAuthorized = 'C', // the user is already authorized
315  SessionInUse = 'B', // the user is logged in already
316 };
317 
324 inline std::ostream& operator<<(std::ostream& stream, const LoginResponseStatus& status) {
325  stream << static_cast<char>(status);
326  return stream;
327 }
328 
336  const Header header;
339 
346  header{sizeof(LoginResponse), MessageID::LoginResponse, sequence},
347  status(status_) { }
348 
355  inline friend std::ostream& operator<<(
356  std::ostream& stream,
357  const LoginResponse& message
358  ) {
359  stream << "LoginResponse("
360  << "header=" << message.header << ","
361  << "status='" << message.status << "')";
362  return stream;
363  }
364 
369  inline std::string to_string() const {
370  std::ostringstream stream;
371  stream << this;
372  return stream.str();
373  }
374 } __attribute__ ((packed));
375 
376 // ---------------------------------------------------------------------------
377 // MARK: LogoutRequest
378 // ---------------------------------------------------------------------------
379 
387  const Header header;
388 
393  explicit LogoutRequest(SequenceNumber sequence) :
394  header{sizeof(LogoutRequest), MessageID::LogoutRequest, sequence} { }
395 
402  inline friend std::ostream& operator<<(
403  std::ostream& stream,
404  const LogoutRequest& message
405  ) {
406  stream << "LogoutRequest(header=" << message.header << ")";
407  return stream;
408  }
409 
414  inline std::string to_string() const {
415  std::ostringstream stream;
416  stream << this;
417  return stream.str();
418  }
419 } __attribute__ ((packed));
420 
421 // ---------------------------------------------------------------------------
422 // MARK: LogoutResponse
423 // ---------------------------------------------------------------------------
424 
426 enum class LogoutReason : char {
427  UserRequested = 'U', // the user requested to logout
428  EndOfDay = 'E', // the trading day is ending, orders are canceled
429  Administrative = 'A', // administrative reason
430  ProtocolViolation = '!' // the client violated the application protocol
431 };
432 
439 inline std::ostream& operator<<(std::ostream& stream, const LogoutReason& reason) {
440  stream << static_cast<char>(reason);
441  return stream;
442 }
443 
451  const Header header;
454 
461  header{sizeof(LogoutResponse), MessageID::LogoutResponse, sequence},
462  reason(reason_) { }
463 
470  inline friend std::ostream& operator<<(
471  std::ostream& stream,
472  const LogoutResponse& message
473  ) {
474  stream << "LogoutResponse(header=" << message.header << ","
475  << "reason='" << message.reason << "')";
476  return stream;
477  }
478 
483  inline std::string to_string() const {
484  std::ostringstream stream;
485  stream << this;
486  return stream.str();
487  }
488 } __attribute__ ((packed));
489 
490 // ---------------------------------------------------------------------------
491 // MARK: OrderRequest
492 // ---------------------------------------------------------------------------
493 
495 static constexpr Price ORDER_PRICE_MARKET = 0;
496 
502 struct OrderRequest {
504  const Header header;
506  const Price price;
510  const Side side;
511 
520  SequenceNumber sequence,
521  Price price_,
522  Quantity quantity_,
523  Side side_
524  ) :
525  header{sizeof(OrderRequest), MessageID::OrderRequest, sequence},
526  price(price_),
527  quantity(quantity_),
528  side(side_) { }
529 
536  inline friend std::ostream& operator<<(
537  std::ostream& stream,
538  const OrderRequest& message
539  ) {
540  stream << "OrderRequest(header=" << message.header << ","
541  << "price=" << message.price << ","
542  << "quantity=" << message.quantity << ","
543  << "side='" << message.side << "')";
544  return stream;
545  }
546 
551  inline std::string to_string() const {
552  std::ostringstream stream;
553  stream << this;
554  return stream.str();
555  }
556 } __attribute__ ((packed));
557 
558 // ---------------------------------------------------------------------------
559 // MARK: OrderResponse
560 // ---------------------------------------------------------------------------
561 
563 static constexpr OrderID ORDER_ID_MARKET = 0;
565 static constexpr OrderID ORDER_ID_REJECTED = 0;
567 enum class OrderStatus : char { Accepted = 'A', Rejected = 'R' };
568 
575 inline std::ostream& operator<<(std::ostream& stream, const OrderStatus& status) {
576  stream << static_cast<char>(status);
577  return stream;
578 }
579 
587  const Header header;
592 
600  SequenceNumber sequence,
601  OrderID order_id_,
602  OrderStatus status_
603  ) :
604  header{sizeof(OrderResponse), MessageID::OrderResponse, sequence},
605  order_id(order_id_),
606  status(status_) { }
607 
614  inline friend std::ostream& operator<<(
615  std::ostream& stream,
616  const OrderResponse& message
617  ) {
618  stream << "OrderResponse(header=" << message.header << ","
619  << "order_id=" << message.order_id << ","
620  << "status='" << message.status << "')";
621  return stream;
622  }
623 
628  inline std::string to_string() const {
629  std::ostringstream stream;
630  stream << this;
631  return stream.str();
632  }
633 } __attribute__ ((packed));
634 
635 // ---------------------------------------------------------------------------
636 // MARK: CancelRequest
637 // ---------------------------------------------------------------------------
638 
646  const Header header;
649 
655  CancelRequest(SequenceNumber sequence, OrderID order_id_) :
656  header{sizeof(CancelRequest), MessageID::CancelRequest, sequence},
657  order_id(order_id_) { }
658 
665  inline friend std::ostream& operator<<(
666  std::ostream& stream,
667  const CancelRequest& message
668  ) {
669  stream << "CancelRequest(header=" << message.header << ","
670  << "order_id=" << message.order_id << ")";
671  return stream;
672  }
673 
678  inline std::string to_string() const {
679  std::ostringstream stream;
680  stream << this;
681  return stream.str();
682  }
683 } __attribute__ ((packed));
684 
685 // ---------------------------------------------------------------------------
686 // MARK: CancelResponse
687 // ---------------------------------------------------------------------------
688 
690 enum class CancelStatus : char { Accepted = 'A', Rejected = 'R' };
691 
698 inline std::ostream& operator<<(std::ostream& stream, const CancelStatus& status) {
699  stream << static_cast<char>(status);
700  return stream;
701 }
702 
710  const Header header;
715 
723  SequenceNumber sequence,
724  OrderID order_id_,
725  CancelStatus status_
726  ) :
727  header{sizeof(CancelResponse), MessageID::CancelResponse, sequence},
728  order_id(order_id_),
729  status(status_) { }
730 
737  inline friend std::ostream& operator<<(
738  std::ostream& stream,
739  const CancelResponse& message
740  ) {
741  stream << "CancelResponse(header=" << message.header << ","
742  << "order_id=" << message.order_id << ","
743  << "status='" << message.status << "')";
744  return stream;
745  }
746 
751  inline std::string to_string() const {
752  std::ostringstream stream;
753  stream << this;
754  return stream.str();
755  }
756 } __attribute__ ((packed));
757 
758 // ---------------------------------------------------------------------------
759 // MARK: ReplaceRequest
760 // ---------------------------------------------------------------------------
761 
769  const Header header;
773  const Price price;
777  const Side side;
778 
788  SequenceNumber sequence,
789  OrderID order_id_,
790  Price price_,
791  Quantity quantity_,
792  Side side_
793  ) :
794  header{sizeof(ReplaceRequest), MessageID::ReplaceRequest, sequence},
795  order_id(order_id_),
796  price(price_),
797  quantity(quantity_),
798  side(side_) { }
799 
806  inline friend std::ostream& operator<<(
807  std::ostream& stream,
808  const ReplaceRequest& message
809  ) {
810  stream << "ReplaceRequest(header=" << message.header << ","
811  << "order_id=" << message.order_id << ","
812  << "price=" << message.price << ","
813  << "quantity=" << message.quantity << ","
814  << "side='" << message.side << "')";
815  return stream;
816  }
817 
822  inline std::string to_string() const {
823  std::ostringstream stream;
824  stream << this;
825  return stream.str();
826  }
827 } __attribute__ ((packed));
828 
829 // ---------------------------------------------------------------------------
830 // MARK: ReplaceResponse
831 // ---------------------------------------------------------------------------
832 
834 enum class ReplaceStatus : char { Accepted = 'A', Rejected = 'R' };
835 
842 inline std::ostream& operator<<(std::ostream& stream, const ReplaceStatus& status) {
843  stream << static_cast<char>(status);
844  return stream;
845 }
846 
854  const Header header;
861 
870  SequenceNumber sequence,
871  OrderID canceled_,
872  OrderID new_order_id_,
873  ReplaceStatus status_
874  ) :
875  header{sizeof(ReplaceResponse), MessageID::ReplaceResponse, sequence},
876  canceled(canceled_),
877  new_order_id(new_order_id_),
878  status(status_) { }
879 
886  inline friend std::ostream& operator<<(
887  std::ostream& stream,
888  const ReplaceResponse& message
889  ) {
890  stream << "ReplaceResponse(header=" << message.header << ","
891  << "canceled=" << message.canceled << ","
892  << "new_order_id=" << message.new_order_id << ","
893  << "status='" << message.status << "')";
894  return stream;
895  }
896 
901  inline std::string to_string() const {
902  std::ostringstream stream;
903  stream << this;
904  return stream.str();
905  }
906 } __attribute__ ((packed));
907 
908 // ---------------------------------------------------------------------------
909 // MARK: PurgeRequest
910 // ---------------------------------------------------------------------------
911 
917 struct PurgeRequest {
919  const Header header;
920 
925  explicit PurgeRequest(SequenceNumber sequence) :
926  header{sizeof(PurgeRequest), MessageID::PurgeRequest, sequence} { }
927 
934  inline friend std::ostream& operator<<(
935  std::ostream& stream,
936  const PurgeRequest& message
937  ) {
938  stream << "PurgeRequest(header=" << message.header << ")";
939  return stream;
940  }
941 
946  inline std::string to_string() const {
947  std::ostringstream stream;
948  stream << this;
949  return stream.str();
950  }
951 } __attribute__ ((packed));
952 
953 // ---------------------------------------------------------------------------
954 // MARK: PurgeResponse
955 // ---------------------------------------------------------------------------
956 
958 enum class PurgeStatus : char { Accepted = 'A', Rejected = 'R' };
959 
966 inline std::ostream& operator<<(std::ostream& stream, const PurgeStatus& status) {
967  stream << static_cast<char>(status);
968  return stream;
969 }
970 
978  const Header header;
981 
988  header{sizeof(PurgeResponse), MessageID::PurgeResponse, sequence},
989  status(status_) { }
990 
997  inline friend std::ostream& operator<<(
998  std::ostream& stream,
999  const PurgeResponse& message
1000  ) {
1001  stream << "PurgeResponse(header=" << message.header << ","
1002  << "status='" << message.status << "')";
1003  return stream;
1004  }
1005 
1010  inline std::string to_string() const {
1011  std::ostringstream stream;
1012  stream << this;
1013  return stream.str();
1014  }
1015 } __attribute__ ((packed));
1016 
1017 // ---------------------------------------------------------------------------
1018 // MARK: TradeResponse
1019 // ---------------------------------------------------------------------------
1020 
1032  const Price price;
1038  const Side side;
1039 
1050  SequenceNumber sequence,
1051  OrderID order_id_,
1052  Price price_,
1053  Quantity quantity_,
1054  Quantity leaves_quantity_,
1055  Side side_
1056  ) :
1057  header{sizeof(TradeResponse), MessageID::TradeResponse, sequence},
1058  order_id(order_id_),
1059  price(price_),
1060  quantity(quantity_),
1061  leaves_quantity(leaves_quantity_),
1062  side(side_) { }
1063 
1070  inline friend std::ostream& operator<<(
1071  std::ostream& stream,
1072  const TradeResponse& message
1073  ) {
1074  stream << "TradeResponse(header=" << message.header << ","
1075  << "order_id=" << message.order_id << ","
1076  << "price=" << message.price << ","
1077  << "quantity=" << message.quantity << ","
1078  << "leaves_quantity=" << message.leaves_quantity << ","
1079  << "side='" << message.side << "')";
1080  return stream;
1081  }
1082 
1087  inline std::string to_string() const {
1088  std::ostringstream stream;
1089  stream << this;
1090  return stream.str();
1091  }
1092 } __attribute__ ((packed));
1093 
1094 } // namespace Messages
1095 
1096 } // namespace OrderEntry
1097 
1098 #endif // ORDER_ENTRY_MESSAGES_HPP
OrderEntry::Messages::CancelRequest::order_id
const OrderID order_id
the order ID of the order to cancel
Definition: messages.hpp:648
OrderEntry::Messages::ReplaceResponse::ReplaceResponse
ReplaceResponse(SequenceNumber sequence, OrderID canceled_, OrderID new_order_id_, ReplaceStatus status_)
Initialize a new order response message.
Definition: messages.hpp:869
OrderEntry::Messages::LoginResponse::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:369
OrderEntry::bool_to_side
constexpr Side bool_to_side(bool side)
Convert a boolean to an order side.
Definition: messages.hpp:124
OrderEntry::Messages::LoginRequest::LoginRequest
LoginRequest(SequenceNumber sequence, Username username_, Password password_)
Initialize a new login request.
Definition: messages.hpp:262
OrderEntry::Messages::PurgeResponse::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:1010
OrderEntry::Messages::CancelResponse::status
const CancelStatus status
whether the cancel was accepted
Definition: messages.hpp:714
OrderEntry
Logic for sending/receiving application messages in a financial market.
Definition: authorizer.hpp:26
OrderEntry::Messages::PurgeRequest::header
const Header header
the header for the message
Definition: messages.hpp:919
OrderEntry::Messages::Packet
std::array< char, 40 > Packet
Definition: messages.hpp:146
OrderEntry::Messages::ReplaceResponse::status
const ReplaceStatus status
the status of the newly created order
Definition: messages.hpp:860
OrderEntry::Messages::LogoutResponse::reason
const LogoutReason reason
the reason the reason the logout
Definition: messages.hpp:453
OrderEntry::Messages::ReplaceRequest::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:822
OrderEntry::Messages::LoginRequest
A request that indicates a client is attempting to create a new session.
Definition: messages.hpp:248
OrderEntry::make_password
Password make_password(std::string password)
Make a password from the given input string.
Definition: messages.hpp:62
OrderEntry::Messages::PurgeRequest::PurgeRequest
PurgeRequest(SequenceNumber sequence)
Initialize a new purge request message.
Definition: messages.hpp:925
OrderEntry::Messages::OrderRequest::header
const Header header
the header for the message
Definition: messages.hpp:504
OrderEntry::Messages::Header::uid
const MessageID uid
the template ID for the message
Definition: messages.hpp:194
OrderEntry::Messages::OrderResponse
A response describing the status of an order request.
Definition: messages.hpp:585
OrderEntry::Messages::OrderRequest::quantity
const Quantity quantity
the quantity of the order
Definition: messages.hpp:508
OrderEntry::Messages::LoginRequest::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:299
OrderEntry::Messages::LoginResponse::status
const LoginResponseStatus status
the status of the login request
Definition: messages.hpp:338
OrderEntry::Messages::ReplaceRequest::operator<<
friend std::ostream & operator<<(std::ostream &stream, const ReplaceRequest &message)
Write the data from the message to a stream.
Definition: messages.hpp:806
OrderEntry::Messages::LogoutResponse::header
const Header header
the header for the message
Definition: messages.hpp:451
OrderEntry::Messages::OrderRequest::side
const Side side
the side of the order
Definition: messages.hpp:510
OrderEntry::Messages::OrderRequest::price
const Price price
the price for the order
Definition: messages.hpp:506
OrderEntry::Messages::OrderResponse::OrderResponse
OrderResponse(SequenceNumber sequence, OrderID order_id_, OrderStatus status_)
Initialize a new order response message.
Definition: messages.hpp:599
OrderEntry::Messages::PurgeRequest::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:946
OrderEntry::Messages::LogoutReason
LogoutReason
Reasons that a user may have been logged out.
Definition: messages.hpp:426
OrderEntry::Messages::CancelResponse::CancelResponse
CancelResponse(SequenceNumber sequence, OrderID order_id_, CancelStatus status_)
Initialize a new cancel response message.
Definition: messages.hpp:722
OrderEntry::Messages::ReplaceResponse::operator<<
friend std::ostream & operator<<(std::ostream &stream, const ReplaceResponse &message)
Write the data from the message to a stream.
Definition: messages.hpp:886
OrderEntry::Messages::OrderResponse::operator<<
friend std::ostream & operator<<(std::ostream &stream, const OrderResponse &message)
Write the data from the message to a stream.
Definition: messages.hpp:614
OrderEntry::Messages::CancelRequest::operator<<
friend std::ostream & operator<<(std::ostream &stream, const CancelRequest &message)
Write the data from the message to a stream.
Definition: messages.hpp:665
OrderEntry::Messages::LoginRequest::username
const Username username
the user name of the connecting client
Definition: messages.hpp:252
OrderEntry::Messages::OrderRequest
A request to place a new limit / market order in the book.
Definition: messages.hpp:502
OrderEntry::Messages::CancelResponse::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:751
OrderEntry::Messages::LogoutRequest::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:414
OrderEntry::Messages::Header::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:232
OrderEntry::Messages::PurgeResponse::status
const PurgeStatus status
whether the purge was accepted
Definition: messages.hpp:980
OrderEntry::Messages::LoginRequest::header
const Header header
the header for the message
Definition: messages.hpp:250
OrderEntry::Messages::Header::Header
Header(uint16_t length_, MessageID uid_, SequenceNumber sequence_=0)
Initialize a new session header.
Definition: messages.hpp:206
OrderEntry::Messages::Header::operator<<
friend std::ostream & operator<<(std::ostream &stream, const Header &header)
Write the data from the header to a stream.
Definition: messages.hpp:217
OrderEntry::Messages::ReplaceRequest::price
const Price price
the price for the order
Definition: messages.hpp:773
OrderEntry::Messages::CancelRequest::CancelRequest
CancelRequest(SequenceNumber sequence, OrderID order_id_)
Initialize a new cancel request message.
Definition: messages.hpp:655
OrderEntry::Messages::LogoutRequest
A request that indicates a client is attempting to close an active session.
Definition: messages.hpp:385
OrderEntry::SequenceNumber
uint32_t SequenceNumber
A type for sequence numbers.
Definition: messages.hpp:36
OrderEntry::Messages::ReplaceResponse::new_order_id
const OrderID new_order_id
the ID of the newly created order
Definition: messages.hpp:858
OrderEntry::Messages::CancelResponse
A response describing the cancellation of an active order in the book.
Definition: messages.hpp:708
OrderEntry::Messages::TradeResponse::header
const Header header
the header for the message
Definition: messages.hpp:1028
OrderEntry::Messages::ReplaceResponse::header
const Header header
the header for the message
Definition: messages.hpp:854
OrderEntry::Messages::LoginRequest::password_string
std::string password_string() const
Return a string representation of the password for the account.
Definition: messages.hpp:273
OrderEntry::Messages::PurgeResponse::header
const Header header
the header for the message
Definition: messages.hpp:978
OrderEntry::Messages::OrderResponse::header
const Header header
the header for the message
Definition: messages.hpp:587
OrderEntry::Messages::LoginRequest::username_string
std::string username_string() const
Return a string representation of the user-name for the account.
Definition: messages.hpp:268
OrderEntry::Messages::Header::length
const uint16_t length
the length of the message in bytes
Definition: messages.hpp:192
OrderEntry::Messages::ReplaceRequest::header
const Header header
the header for the message
Definition: messages.hpp:769
OrderEntry::side_to_LOB_side
constexpr LOB::Side side_to_LOB_side(Side side)
Convert a side character to a LOB side value.
Definition: messages.hpp:115
OrderEntry::Messages::LogoutResponse::LogoutResponse
LogoutResponse(SequenceNumber sequence, LogoutReason reason_)
Initialize a new logout response message.
Definition: messages.hpp:460
OrderEntry::side_to_bool
constexpr bool side_to_bool(Side side)
Convert an order side character to a boolean value.
Definition: messages.hpp:102
OrderEntry::Messages::LogoutRequest::LogoutRequest
LogoutRequest(SequenceNumber sequence)
Initialize a new logout request message.
Definition: messages.hpp:393
OrderEntry::Messages::ReplaceResponse::canceled
const OrderID canceled
the ID of the newly created order
Definition: messages.hpp:856
OrderEntry::Messages::CancelRequest::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:678
OrderEntry::Messages::OrderResponse::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:628
OrderEntry::Messages::TradeResponse::order_id
const OrderID order_id
the ID for the order connected to the trade
Definition: messages.hpp:1030
OrderEntry::Messages::LogoutResponse
A response that tells the status of a session destruction to the client.
Definition: messages.hpp:449
OrderEntry::Messages::Header::padding
const uint8_t padding
arbitrary padding to align the sequence number in memory
Definition: messages.hpp:196
OrderEntry::Messages::Header::sequence
const SequenceNumber sequence
sequence number of the message (event time)
Definition: messages.hpp:198
OrderEntry::Messages::TradeResponse::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:1087
OrderEntry::Messages::PurgeStatus
PurgeStatus
Possible statuses for a purge response.
Definition: messages.hpp:958
OrderEntry::Messages::TradeResponse::price
const Price price
the price the trade executed at
Definition: messages.hpp:1032
OrderEntry::Messages::TradeResponse::leaves_quantity
const Quantity leaves_quantity
the number of shares that remain in the book
Definition: messages.hpp:1036
OrderEntry::Messages::LogoutResponse::operator<<
friend std::ostream & operator<<(std::ostream &stream, const LogoutResponse &message)
Write the data from the message to a stream.
Definition: messages.hpp:470
OrderEntry::Messages::CancelResponse::order_id
const OrderID order_id
the order ID of the order to cancel
Definition: messages.hpp:712
OrderEntry::Messages::LogoutRequest::header
const Header header
the header for the message
Definition: messages.hpp:387
Clock::TimeStamp
uint64_t TimeStamp
a type for timestamps
Definition: clock.hpp:28
OrderEntry::Messages::CancelResponse::operator<<
friend std::ostream & operator<<(std::ostream &stream, const CancelResponse &message)
Write the data from the message to a stream.
Definition: messages.hpp:737
OrderEntry::Messages::ReplaceRequest::quantity
const Quantity quantity
the quantity of the order
Definition: messages.hpp:775
OrderEntry::Messages::ReplaceRequest
A request to replace an active order in the book with a new order.
Definition: messages.hpp:767
OrderEntry::Messages::OrderRequest::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:551
OrderEntry::Messages::LoginResponse::operator<<
friend std::ostream & operator<<(std::ostream &stream, const LoginResponse &message)
Write the data from the message to a stream.
Definition: messages.hpp:355
OrderEntry::Messages::LoginResponse::LoginResponse
LoginResponse(SequenceNumber sequence, LoginResponseStatus status_)
Initialize a new login response.
Definition: messages.hpp:345
OrderEntry::operator<<
std::ostream & operator<<(std::ostream &stream, const Side &side)
Write the order side to a stream.
Definition: messages.hpp:79
OrderEntry::Messages::operator<<
std::ostream & operator<<(std::ostream &stream, const MessageID &uid)
Write a template ID to a stream.
Definition: messages.hpp:176
OrderEntry::Messages::TradeResponse::quantity
const Quantity quantity
the number of shares that were exchanges
Definition: messages.hpp:1034
OrderEntry::Messages::ReplaceRequest::ReplaceRequest
ReplaceRequest(SequenceNumber sequence, OrderID order_id_, Price price_, Quantity quantity_, Side side_)
Initialize a new order replace message.
Definition: messages.hpp:787
OrderEntry::Messages::OrderResponse::status
const OrderStatus status
the status of the newly created order
Definition: messages.hpp:591
OrderEntry::Messages::LoginRequest::operator<<
friend std::ostream & operator<<(std::ostream &stream, const LoginRequest &message)
Write the data from the message to a stream.
Definition: messages.hpp:283
OrderEntry::Messages::PacketQueue
std::deque< Packet > PacketQueue
A type for queuing packet buffers.
Definition: messages.hpp:149
OrderEntry::Messages::ReplaceStatus
ReplaceStatus
Possible statuses for a replace response.
Definition: messages.hpp:834
OrderEntry::Password
std::array< char, 12 > Password
A type for passwords.
Definition: messages.hpp:55
OrderEntry::Messages::PurgeRequest
A request to cancel all active orders in the book.
Definition: messages.hpp:917
OrderEntry::TimeStamp
Clock::TimeStamp TimeStamp
A forward a declaration for the Clock timestamp.
Definition: messages.hpp:33
OrderEntry::Messages::LoginResponseStatus
LoginResponseStatus
Possible statuses for a login response.
Definition: messages.hpp:311
OrderEntry::Messages::PurgeResponse
A response describing the status of canceling all active orders in the book.
Definition: messages.hpp:976
OrderEntry::Messages::PurgeRequest::operator<<
friend std::ostream & operator<<(std::ostream &stream, const PurgeRequest &message)
Write the data from the message to a stream.
Definition: messages.hpp:934
OrderEntry::OrderID
uint64_t OrderID
A type for order IDs.
Definition: messages.hpp:139
OrderEntry::Messages::LogoutResponse::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:483
OrderEntry::Messages::CancelResponse::header
const Header header
the header for the message
Definition: messages.hpp:710
OrderEntry::LOB::Side
Side
the possible sides for the LimitTree
Definition: structures.hpp:37
OrderEntry::Messages::CancelRequest
A request to cancel an active limit order in the book.
Definition: messages.hpp:644
OrderEntry::Messages::TradeResponse::operator<<
friend std::ostream & operator<<(std::ostream &stream, const TradeResponse &message)
Write the data from the message to a stream.
Definition: messages.hpp:1070
OrderEntry::make_username
Username make_username(std::string username)
Make a username from the given input string.
Definition: messages.hpp:46
OrderEntry::Messages::OrderRequest::OrderRequest
OrderRequest(SequenceNumber sequence, Price price_, Quantity quantity_, Side side_)
Initialize a new order request message.
Definition: messages.hpp:519
OrderEntry::Messages::LogoutRequest::operator<<
friend std::ostream & operator<<(std::ostream &stream, const LogoutRequest &message)
Write the data from the message to a stream.
Definition: messages.hpp:402
OrderEntry::Messages::OrderRequest::operator<<
friend std::ostream & operator<<(std::ostream &stream, const OrderRequest &message)
Write the data from the message to a stream.
Definition: messages.hpp:536
OrderEntry::Messages::Header
A header containing type information and metadata for a message.
Definition: messages.hpp:190
OrderEntry::Quantity
uint32_t Quantity
A type for order quantities.
Definition: messages.hpp:133
OrderEntry::Messages::TradeResponse::side
const Side side
the original side of the order
Definition: messages.hpp:1038
OrderEntry::Messages::TradeResponse::TradeResponse
TradeResponse(SequenceNumber sequence, OrderID order_id_, Price price_, Quantity quantity_, Quantity leaves_quantity_, Side side_)
Initialize a new trade response message.
Definition: messages.hpp:1049
OrderEntry::Messages::PurgeResponse::PurgeResponse
PurgeResponse(SequenceNumber sequence, PurgeStatus status_)
Initialize a new purge response message.
Definition: messages.hpp:987
OrderEntry::Messages::LoginRequest::password
const Password password
the password for the connecting client
Definition: messages.hpp:254
OrderEntry::Messages::PurgeResponse::operator<<
friend std::ostream & operator<<(std::ostream &stream, const PurgeResponse &message)
Write the data from the message to a stream.
Definition: messages.hpp:997
OrderEntry::Messages::LoginResponse
A response that tells the status of a session creation to the client.
Definition: messages.hpp:334
OrderEntry::Price
uint64_t Price
A type for order prices.
Definition: messages.hpp:136
OrderEntry::Messages::ReplaceRequest::side
const Side side
the side of the order
Definition: messages.hpp:777
OrderEntry::Messages::ReplaceRequest::order_id
const OrderID order_id
the order ID of the order to replace
Definition: messages.hpp:771
OrderEntry::Messages::ReplaceResponse::to_string
std::string to_string() const
Convert the object to an STL string.
Definition: messages.hpp:901
OrderEntry::Messages::MessageID
MessageID
Message IDs for messages in the protocol.
Definition: messages.hpp:152
OrderEntry::Messages::OrderResponse::order_id
const OrderID order_id
the ID of the newly created order
Definition: messages.hpp:589
OrderEntry::Messages::CancelRequest::header
const Header header
the header for the message
Definition: messages.hpp:646
OrderEntry::Messages::ReplaceResponse
A response describing the replacement of an active order with a new order.
Definition: messages.hpp:852
OrderEntry::Side
Side
The side of an order.
Definition: messages.hpp:71
OrderEntry::side_to_double
constexpr double side_to_double(Side side)
Convert an order side character to a double.
Definition: messages.hpp:89
OrderEntry::Messages::CancelStatus
CancelStatus
Possible statuses for a cancellation response.
Definition: messages.hpp:690
OrderEntry::Messages::LoginResponse::header
const Header header
the header for the message
Definition: messages.hpp:336
OrderEntry::Username
std::array< char, 4 > Username
A type for user names.
Definition: messages.hpp:39
OrderEntry::Messages::OrderStatus
OrderStatus
Possible statuses for an order response.
Definition: messages.hpp:567
OrderEntry::Messages::TradeResponse
A response describing a trade that occurred for a limit / market order.
Definition: messages.hpp:1026