|
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
|
L2Book<kMaxDepth>: price-aggregated book for crypto feeds (5.4). More...
#include "fastmm/core/book/book_view.hpp"#include "fastmm/core/config_macros.hpp"#include "fastmm/core/containers/static_vector.hpp"#include "fastmm/core/messages.hpp"#include <algorithm>#include <cstddef>#include <cstdint>#include <span>#include <type_traits>Go to the source code of this file.
Classes | |
| class | fastmm::L2Book< kMaxDepth > |
Namespaces | |
| namespace | fastmm |
L2Book<kMaxDepth>: price-aggregated book for crypto feeds (5.4).
Each side is a sorted StaticVector<Level> with the BEST level at back(): top-of-book is O(1), and the common near-top insert/erase only memmoves a handful of 16-byte levels; an insert or erase moves the levels better than its own (into a full side, the ones worse than it, as the worst level goes), and a snapshot loads in O(levels). Bids are stored ascending by price, asks descending, so both sides share one code path keyed on "distance from best". Lookups scan the top 16 linearly and bisect the rest.
Depth is capped at kMaxDepth: levels worse than the worst stored one are dropped and the side is flagged truncated() until the next snapshot (crypto venues resend snapshots on resync; we deliberately do not try to repair). Crossed books are tolerated (Binance can cross for ~100 ms between updates); the engine polls crossed_for(now) against a grace.