50 Order(uint64_t ref_num,
char side, uint32_t shrs, uint32_t prc,
const std::string& stk)
60using OrderIt = std::list<std::shared_ptr<Order>>::iterator;
69 std::list<std::shared_ptr<Order>>
orders;
73 auto add_order(
const std::shared_ptr<Order>& order) -> void;
96 LimitOrderBook(
const std::string& stock_symbol) : m_stock_symbol(stock_symbol) {}
113 auto print(std::ostream& out,
unsigned int delay_ms = 0) const ->
void;
133 std::string m_stock_symbol;
136 std::map<uint64_t, OrderIt> m_orders;
186 template <
typename T>
187 auto handle_message(
const T& ) ->
void { }
197 uint64_t order_ref,
char side, uint32_t
shares, uint32_t
price,
const std::string& stock
204 auto remove_order(uint64_t order_ref, uint32_t canceled_shares) -> void;
Manages the state of a limit order book for a specific financial instrument.
LimitOrderBook(const std::string &stock_symbol)
Constructs an order book scoped to a single stock symbol.
const std::set< char > book_messages
Set of message type characters that affect the book state.
auto get_bids() const -> const BidMap &
The map of active Bids.
std::map< uint32_t, PriceLevel, std::greater< uint32_t > > BidMap
auto print(std::ostream &out, unsigned int delay_ms=0) const -> void
Visualizes the current state of the order book to an output stream.
auto get_asks() const -> const AskMap &
The map of active Asks.
std::map< uint32_t, PriceLevel, std::less< uint32_t > > AskMap
auto process(const Message &message) -> void
Dispatches and processes a generic ITCH message.
Defines every ITCH 5.0 message struct, the Message variant, and the stream-printing helpers used to f...
std::list< std::shared_ptr< Order > >::iterator OrderIt
Iterator type for navigating the list of orders within a price level.
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.
Add Order, With MPID Attribution (F): like Add Order, but attributed to a market participant.
Add Order, No MPID Attribution (A): a new displayable order has been accepted and placed on the book.
Order Cancel (X): a partial cancellation reduced the shares of a resting order.
Order Delete (D): a resting order was cancelled in its entirety and removed from the book.
Order Executed (E): a resting order was executed in whole or in part at its display price.
Order Executed With Price (C): a resting order was executed at a price different from its display pri...
Order Replace (U): a resting order was replaced with a new order at a new reference number,...
Represents a single resting order within the Limit Order Book.
PriceLevel * level
Pointer to the price level containing this order.
char buy_sell_indicator
'B' for Buy, 'S' for Sell.
uint32_t price
Limit price of the order.
uint32_t shares
Current quantity of shares available in this order.
std::string stock
The stock symbol for this order.
Order(uint64_t ref_num, char side, uint32_t shrs, uint32_t prc, const std::string &stk)
Constructs an order with the given identity, side, quantity, and price.
uint64_t order_reference_number
Unique identifier assigned to the order by the exchange.
Represents a specific price node in the order book.
uint32_t total_shares
Aggregate volume of shares at this price.
auto add_order(const std::shared_ptr< Order > &order) -> void
Appends an order to the end of the queue (Time priority).
std::list< std::shared_ptr< Order > > orders
FIFO queue of orders.
auto remove_order(const OrderIt &order_it) -> void
Removes a specific order from the queue.