Class OrderBookView¶
Defined in File OrderBookView.hpp
Class Documentation¶
-
class OrderBookView¶
Public Functions
-
double get_depth_volume(bool is_bid, int k) const¶
Returns the total volume across the top
knon-empty levels.- Parameters:
is_bid – If true, queries the bid side; otherwise the ask side.
k – Number of levels to aggregate.
- Returns:
Sum of volume across the top
klevels.
-
double get_vwaa(bool is_bid, int top_n, uint64_t max_age_cap) const¶
Returns the volume-weighted average age of resting orders across the top
top_nlevels.- Parameters:
is_bid – If true, queries the bid side; otherwise the ask side.
top_n – Number of price levels to inspect.
max_age_cap – Age is capped at this value (in ticks) to prevent outlier skew.
- Returns:
VWAA in ticks, or NAN if no orders are present.
-
double get_price_at_level(bool is_bid, int k) const¶
Returns the price at the
k-thnon-empty level (0-indexed).- Parameters:
is_bid – If true, queries the bid side; otherwise the ask side.
k – Zero-based level index.
- Returns:
Price at level
k, or NAN if fewer thank+1levels exist.
-
double get_vwap_depth(bool is_bid, int k) const¶
Returns the volume-weighted average price across the top
klevels.- Parameters:
is_bid – If true, queries the bid side; otherwise the ask side.
k – Number of levels to include in the VWAP calculation.
- Returns:
VWAP over the top
klevels, or NAN if no volume exists.
-
double get_vol_at_level(bool is_bid, int k) const¶
Returns the total volume at the
k-thnon-empty level (0-indexed).- Parameters:
is_bid – If true, queries the bid side; otherwise the ask side.
k – Zero-based level index.
- Returns:
Volume at level
k, or NAN if fewer thank+1levels exist.
-
double get_bid_price(int level = 0) const¶
Returns the bid price at the given level.
- Parameters:
level – Zero-based level index (default: best bid).
- Returns:
Bid price at
level, or NAN if the level does not exist.
-
double get_ask_price(int level = 0) const¶
Returns the ask price at the given level.
- Parameters:
level – Zero-based level index (default: best ask).
- Returns:
Ask price at
level, or NAN if the level does not exist.
-
double get_bid_size(int level = 0) const¶
Returns the bid volume at the given level.
- Parameters:
level – Zero-based level index (default: best bid).
- Returns:
Bid volume at
level, or NAN if the level does not exist.
-
double get_ask_size(int level = 0) const¶
Returns the ask volume at the given level.
- Parameters:
level – Zero-based level index (default: best ask).
- Returns:
Ask volume at
level, or NAN if the level does not exist.
-
trading::Action get_last_action() const¶
Returns the action type of the most recently processed event.
-
trading::Side get_last_trade_side() const¶
Returns the aggressor side of the most recent trade.
- Returns:
The side, or trading::Side::None if the last event was not a trade.
-
int get_bid_depth() const¶
Returns the number of live (non-zero volume) bid price levels.
-
int get_ask_depth() const¶
Returns the number of live (non-zero volume) ask price levels.
-
double get_mid_price() const¶
Returns the midpoint between the best bid and best ask.
- Returns:
Mid price, or NAN if either side of the book is empty.
-
double get_spread() const¶
Returns the spread between the best ask and best bid.
- Returns:
Ask minus bid, or NAN if either side of the book is empty.
-
const trading::Level *get_level(bool is_bid, int level) const¶
Returns the Level at the
level-thnon-empty price level (0-indexed).Note
Level pointers are value-stable for the lifetime of the session.
- Parameters:
is_bid – If true, queries the bid side; otherwise the ask side.
level – Zero-based level index.
- Returns:
Pointer to the Level, or nullptr if fewer than
level+1non-empty levels exist.
-
std::vector<const trading::Order*> get_orders_at_level_snapshot(bool is_bid, int level) const¶
Returns all resting orders at the
level-thnon-empty price level, in queue order.Note
Order pointers are only guaranteed correct for the current tick. See section note above.
- Parameters:
is_bid – If true, queries the bid side; otherwise the ask side.
level – Zero-based level index.
- Returns:
Snapshot pointers to each Order at that level, or empty if the level does not exist.
-
std::vector<const trading::Order*> get_orders_at_level_snapshot(const trading::Level *level) const¶
Returns all resting orders at the given Level, in queue order.
Note
Order pointers are only guaranteed correct for the current tick. See section note above.
- Parameters:
level – Pointer to a Level object; accepts nullptr (e.g. as returned by get_level).
- Returns:
Snapshot pointers to each Order at that level, or empty if
levelis nullptr.
-
const trading::Order *get_order_snapshot(trading::OrderId id) const¶
Looks up a resting order by its order ID.
Note
Order pointers are only guaranteed correct for the current tick. See section note above.
- Parameters:
id – The order ID to search for.
- Returns:
Snapshot pointer to the Order if currently resting in the book, otherwise nullptr.
-
double get_depth_volume(bool is_bid, int k) const¶