Materializers
quantpylib.hft.materializers contains feed sinks that turn native feed events
into live in-memory state. Use these when downstream code needs a materialized
view, such as a native order book, rather than individual
feed events.
NeedMoreWebsocketUpdates
Bases: Exception
The same snapshot may become usable after more websocket updates arrive.
OrderbookMaterializerSink
Bases: FeedSink
Materialize BookUpdate feed events into a native OrderBook.
The sink accepts
quantpylib.standards.models.BookUpdate
events from a feed sink path, applies each event to its orderbook
quantpylib.hft.orderbook.OrderBook
instance, and calls on_update(orderbook) after the update when a callback
is provided. It may be passed into Feed.add_l2_book_feed(...) or
Feed.add_l2_book_feeds(...) as a per-feed sink.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_update
|
callable
|
Callback called with the materialized quantpylib.hft.orderbook.OrderBook after each applied update. |
None
|
get_snapshot
|
callable
|
Snapshot provider used for periodic reconciliation when strict sequence semantics are available. |
None
|
buffer_capacity
|
int
|
Number of updates to retain while reconciling. |
256
|
reconcile_interval_sec
|
float
|
Seconds between successful
reconciliation attempts. If |
None
|
short_retry_sec
|
float
|
Delay while waiting for enough buffered updates to reconcile a snapshot. |
3
|
retry_sec
|
float
|
Delay after a failed reconciliation attempt. |
15
|
max_short_retries
|
int
|
Short retries before the attempt is treated as retriable failure. |
3
|
orderbook
|
OrderBook
|
Existing
quantpylib.hft.orderbook.OrderBook
to update. A new |
None
|
ReconcileGap
Bases: Exception
The current snapshot and buffered updates cannot prove continuity.
RetriableReconciliation
Bases: Exception
This reconciliation attempt failed; fetch a fresh snapshot later.
UnsupportedReconciliation
Bases: Exception
Strict reconciliation is not available for this stream.
filter_updates(snapshot, buffered)
Return [snapshot, ...replay_updates] for a strict snapshot replay.