Detect when a resting limit order is alone at its price level¶
The MarketPosition state level_empty reports when our resting
limit order is the only quantity left at its price. The detector
relies on the queue tracker's view of non-our quantity at the level
and works under both TOB and FULL queue models.
When it fires¶
level_empty fires when:
- The queue tracker is enabled (cfg.queueModel != NONE)
- The non-our quantity at our exact price is zero
- Either we are at best on our side, or no level on our side exists in the book (we are the only quote there)
The detector handles the common case where a level "vanishes" from
the book snapshot — providers usually drop levels at zero quantity
rather than reporting qty=0. The simulator now zeroes out any
tracked level that disappears from the next book snapshot so the
queue tracker stays in sync.
Configure¶
Just enable the queue tracker — no extra config:
React from a strategy¶
Notes¶
- Under
queue_model=nonethe detector returnsunknownfor level-empty queries; you need TOB or FULL to get this signal. - "Non-our quantity" is tracked from the book snapshots you feed
into the executor. The simulator never publishes our own resting
orders to its own book, so the level's
totalQtyrepresents other resting participants only. - The state is exclusive with
best: if we are at best and no others share our level, we arelevel_empty, notbest. Both imply "best", butlevel_emptyis the tighter classification.