order_book 0.3.0
Exchange feed order book that prints the best bid and offer
Loading...
Searching...
No Matches
order_book::OrderBook Class Reference

#include <order_book.hpp>

Public Member Functions

std::expected< bool, BookError > apply (std::string_view order, const Event &event)
Bbo bbo () const
 Current best bid and offer.
std::size_t order_count () const
 Number of resting orders on both sides.
std::size_t level_count () const
 Number of price levels on both sides.

Detailed Description

Order book for one ticker, replayed from the exchange's own feed

The exchange has already matched the orders: each message applies to the resting order it names, and the book never matches orders itself. Each price level keeps a running total and a count of its orders, and every order is reachable from its ID in expected constant time. Each side lists its levels worst price first, so most adds and removals touch only its end.

Definition at line 42 of file order_book.hpp.

Member Function Documentation

◆ apply()

std::expected< bool, BookError > order_book::OrderBook::apply ( std::string_view order,
const Event & event )
nodiscard

Apply event to the order with ID order, returning whether the best bid or offer changed; on a BookError the book is unchanged. An exception, such as running out of memory, can leave the book inconsistent, so the book must not be used after one.

◆ level_count()

std::size_t order_book::OrderBook::level_count ( ) const
inlinenodiscard

Number of price levels on both sides.

Definition at line 53 of file order_book.hpp.

◆ order_count()

std::size_t order_book::OrderBook::order_count ( ) const
inlinenodiscard

Number of resting orders on both sides.

Definition at line 51 of file order_book.hpp.


The documentation for this class was generated from the following file: