.. _program_listing_file_engine_include_OrderBookView.hpp: Program Listing for File OrderBookView.hpp ========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``engine/include/OrderBookView.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include "OrderBook.hpp" class OrderBookView { private: const OrderBook& book_; const trading::Level* level_at(bool is_bid, int k) const; public: OrderBookView(const OrderBook& book) : book_{book} {} // --- Level Queries --- double get_depth_volume(bool is_bid, int k) const; double get_vwaa(bool is_bid, int top_n, uint64_t max_age_cap) const; double get_price_at_level(bool is_bid, int k) const; double get_vwap_depth(bool is_bid, int k) const; double get_vol_at_level(bool is_bid, int k) const; // --- Bid / Ask --- double get_bid_price(int level = 0) const; double get_ask_price(int level = 0) const; double get_bid_size(int level = 0) const; double get_ask_size(int level = 0) const; // --- Trade Event State --- trading::Action get_last_action() const; trading::TimeStamp get_last_ts() const; trading::Side get_last_trade_side() const; trading::Price get_last_trade_price() const; trading::Volume get_last_trade_size() const; // --- Depth --- int get_bid_depth() const; int get_ask_depth() const; // --- Derived Metrics --- double get_mid_price() const; double get_spread() const; // --- Order Queries --- // // Level pointers (trading::Level*) are value-stable for the lifetime of the // session: levels are heap-allocated on first use and never moved or freed. // // Order pointers (trading::Order*) are NOT value-stable across ticks. // The order pool is pre-allocated and never reallocated, so the address // itself will not become null, but cancel_order uses a swap-and-pop strategy: // the cancelled slot is immediately overwritten with the last active order. // A pointer to a cancelled order therefore silently becomes a pointer to a // completely different order after the next cancellation. Do NOT store Order // pointers across ticks; treat them as valid only for the duration of the // current compute() call. const trading::Level* get_level(bool is_bid, int level) const; std::vector get_orders_at_level_snapshot(bool is_bid, int level) const; std::vector get_orders_at_level_snapshot(const trading::Level* level) const; const trading::Order* get_order_snapshot(trading::OrderId id) const; };