Queue positions¶
Frame-level functions for the engine's queue reconstruction: each resting order's place in its price level's queue. The arrays underneath are on the Order-book engine page.
queue_positions is also exported from the package root
(from ob_analytics import queue_positions). On a run, result.queue()
returns the same table and keeps it (see
PipelineResult).
queue_positions ¶
Reconstruct FIFO queue position for each visible limit order over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
DataFrame
|
Classified canonical events ( |
required |
levels
|
('touch', 'all')
|
|
"touch"
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per order event (two for a move) with columns
:data: |
Notes
Price-time priority: created appends to the back of its level; a size
reduction (partial fill or partial cancel) keeps the order's place; a
deleted (or a reduction to zero) removes it. A changed row with no
fill and a new price moves the order to the back of its new level. It is
reported twice: as deleted at the old level, then as created at the
new one, where age_s still counts from the order's placement. A row
that reports a fill never moves the
order, whatever price it carries. Hidden orders (id == 0) and market
orders are skipped. While an order stays at one price, rank is
monotone non-increasing (FIFO: newcomers join the back), which the tests
assert.
queue_age_grid ¶
Touch-queue composition over time: the age of the order at each rank.
Replays one side's events and snapshots its touch (best) level at n_time
evenly spaced instants, recording each resting order's age by FIFO rank.
The table feeds the liquidity_at_touch L3 composition strip (a
pcolormesh/Heatmap of age over time x rank).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
DataFrame
|
Classified canonical events, with the columns :func: |
required |
side
|
('bid', 'ask')
|
Which touch to compose (default |
"bid"
|
n_time
|
int
|
Number of time columns. |
200
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per queue rank and one column per sample instant. The index
is |