|
ITCH 5.0 Market Data Handler 1.0.0
NASDAQ ITCH 5.0 Market Data Feed Handler
|
Order book price level aggregator. More...
Order book price level aggregator.
Maintains aggregated price levels for one side of an order book (buy or sell). The aggregator keeps the best N price levels (configured at construction) and tracks additional levels beyond that depth in a separate overflow set.
Key operations:
The aggregator automatically:
| _Traits | Book traits defining types (PriceType, QtyType, etc.) |
| _Side | Side character: 'B' for buy, 'S' for sell |
#include <core/src/Aggregator.h>
Public Types | |
| using | Traits = _Traits |
| Book traits type. | |
| using | PriceType = typename Traits::PriceType |
| Price type. | |
| using | QtyType = typename Traits::QtyType |
| Quantity type. | |
| using | CounterType = typename Traits::CounterType |
| Order counter type. | |
| using | Timestamp = typename Traits::Timestamp |
| Timestamp type. | |
Public Member Functions | |
| Aggregator (std::uint16_t depth=5) | |
| Construct aggregator with specified depth. | |
| void | clear () |
| Clear all price levels. | |
| template<class Handler> | |
| void | play (Handler &&handler) const |
| Replay all current levels to handler. | |
| template<class Handler> | |
| void | add_order (Handler &&handler, PriceType price, QtyType qty, Timestamp timestamp=0) |
| Add order quantity at a price. | |
| template<class Handler> | |
| void | reduce_qty (Handler &&handler, PriceType price, QtyType qty, bool order_removed, Timestamp timestamp=0) |
| Reduce quantity at a price. | |
| template<class Handler> | |
| void | modify (Handler &&handler, PriceType old_price, PriceType new_price, QtyType old_qty, QtyType new_qty, Timestamp timestamp=0) |
| Modify an order (change price and/or quantity). | |
| void | reset () |
| Reset aggregator to initial state. | |
| using b2bits::Aggregator< _Traits, _Side >::CounterType = typename Traits::CounterType |
Order counter type.
| using b2bits::Aggregator< _Traits, _Side >::PriceType = typename Traits::PriceType |
Price type.
| using b2bits::Aggregator< _Traits, _Side >::QtyType = typename Traits::QtyType |
Quantity type.
| using b2bits::Aggregator< _Traits, _Side >::Timestamp = typename Traits::Timestamp |
Timestamp type.
| using b2bits::Aggregator< _Traits, _Side >::Traits = _Traits |
Book traits type.
|
inline |
Construct aggregator with specified depth.
Creates an aggregator that maintains up to 'depth' price levels. Additional levels beyond this depth are tracked in overflow storage.
| depth | Maximum number of price levels to maintain (default: 5) |
|
inline |
Add order quantity at a price.
Adds the specified quantity to the order book at the given price. If the price level exists, quantity and order count are incremented. If it's a new price, a level is created (potentially causing level shifts).
The handler is invoked for:
| Handler | Handler type: void(Timestamp, const LevelUpdateEvent&) |
| handler | Handler to receive update events |
| price | Price to add quantity at |
| qty | Quantity to add |
| timestamp | Event timestamp (default: 0) |
References b2bits::LevelUpdateEvent< _Traits >::New, and b2bits::LevelUpdateEvent< _Traits >::Update.
Referenced by modify().
|
inline |
Clear all price levels.
Removes all levels and resets the aggregator to empty state.
|
inline |
Modify an order (change price and/or quantity).
Atomically changes an order from old price/quantity to new price/quantity. If possible, the level is modified in-place. Otherwise, the old quantity is reduced and new quantity is added (equivalent to cancel + add).
Optimization: If only quantity changes (same price), performs efficient update.
| Handler | Handler type: void(Timestamp, const LevelUpdateEvent&) |
| handler | Handler to receive update events |
| old_price | Previous order price |
| new_price | New order price |
| old_qty | Previous order quantity |
| new_qty | New order quantity |
| timestamp | Event timestamp (default: 0) |
References add_order(), reduce_qty(), and b2bits::LevelUpdateEvent< _Traits >::Update.
|
inline |
Replay all current levels to handler.
Iterates through all active price levels (0 to depth-1) and invokes the handler with a "New" event for each level. Useful for snapshot generation or initial state transmission.
| Handler | Handler type: void(Timestamp, const LevelUpdateEvent&) |
| handler | Handler to receive level events |
|
inline |
Reduce quantity at a price.
Removes the specified quantity from the order book at the given price. If an order is removed (order_removed=true), the order count is decremented. If quantity reaches zero, the level is removed and overflow levels may be promoted.
The handler is invoked for:
| Handler | Handler type: void(Timestamp, const LevelUpdateEvent&) |
| handler | Handler to receive update events |
| price | Price to reduce quantity at |
| qty | Quantity to remove |
| order_removed | If true, decrement order count |
| timestamp | Event timestamp (default: 0) |
References b2bits::LevelUpdateEvent< _Traits >::Remove, and b2bits::LevelUpdateEvent< _Traits >::Update.
Referenced by modify().
|
inline |
Reset aggregator to initial state.
Clears all levels and overflow storage, resetting depth to zero. Similar to clear() but reinitializes the levels vector.