Read queue position from a strategy¶
Limit orders resting on a simulated book carry a queue position that shifts as trades consume volume in front of them and as the level shrinks under cancels. This page shows how to observe that movement from a strategy.
What's exposed¶
For every fill or order-update event delivered to a strategy, the event payload carries two extra fields:
queue_ahead(Python / Codon) /queueAhead(Node / QuickJS) — volume ahead of the order at its price level at the time of the eventqueue_total/queueTotal— total quantity at the order's price level
A new event status, QUEUE_POSITION_UPDATED, fires when only the
queue position changed (no fill, no cancel, no replace). It dispatches
to an on_queue_position_change / onQueuePositionChange callback
so strategies can react without subscribing to every order update.
Configure the emission threshold¶
A naive backtest would emit a queue-position event on every book tick, which is too chatty for high-frequency books. The simulator suppresses changes smaller than a configurable fraction of the order's volume-at-arrival.
Set the fraction to 0.0 to fire on every change (lossless, very
chatty) or to 1.0 to suppress queue-position events entirely.
Observe queue position from a strategy¶
Notes¶
- Queue position is a backtest-only signal. Live exchanges do not
publish queue position; the fields read as
0on live order events. - Fill events (
PARTIALLY_FILLED/FILLED) also carry the queue snapshot at fill time, soon_fillhandlers can record where in the queue the fill landed. - The threshold is computed against the order's
aheadAtArrivalsnapshot, so a single fractional setting applies uniformly to orders of any size.