Estimating order queue position

When developing algorithmic trading strategies for FIFO markets it is beneficial to know our orders queue position in the order book. We use the queue position to calculate the intrinsic value of the order. When an orders intrinsic value is less than \(0\) we cancel it.

The method of estimation is highly dependent on the particular rules and technology of the exchange in question. Some exchanges provide direct API access to your order queue positions. Most US and European equity exchanges distribute a market-by-order data feed where you can infer exactly where your order is in the limit order book. Futures exchanges usually provide market data through a market-by-level feed where you receive the price and aggregate volume at the \(n\) topmost price levels.

Obviously if you have direct API access to queue positions or a market-by-order feed it is theoretically trivial to know your order queue position, but it can be technically challenging to implement. For the market-by-level feeds it’s necessary to devise a method to estimate the queue position. I will describe a simple method to do just that.

First we estimate the initial queue position of a newly inserted order. We then monitor the market data feed and revise this estimate in response to market data updates:

  1. We insert an order of size \(S\) at price \(P\) at time \(t_0\). An initial estimate \(\hat{V}(t_0)\) of the queue position is \(Q(t_0)\), the current aggregate size at price \(P\) at time \(t_0\) when we send our order. Alternatively we can use the size \(Q(t_1)\) at price \(P\) at the time \(t_1\) our order is acknowledged or an average of the two data points. Depending on if the market data feed coalesces updates we might see a size increase \(\Delta Q(t_3)\) of \(S\) at price \(P\) at time \(t_3 \in (t_0, t_0+\delta)\), we can then update our estimate \(\hat{V}(t_3)=Q(t_3)-S\). The time offset \(\delta\) is chosen to be a multiple of the delay between sending an order and observing it on the market data feed.

  2. Now in event time scale: For every decrease \(\Delta Q(n) < 0\) in the size \(Q(n)\) at price \(P\) we revise our estimate \(\hat{V}(n)\). If the feed allows us to discriminate between order cancellations and order fills we update \(\hat{V}(n+1)=max(\hat{V}(n)+\Delta Q(n),0)\) for each order fill at price \(P\). For other updates we use a model to determine the probability \(p(n)\) that the update affects \(\hat{V}(n)\). This model can be conditionally dependent on the relative size in front of and behind our order, properties of the order book and other factors. We then update .

One useful family of models can be constructed as where \(f(x)\) is an increasing function, for example \(\ln(1+x)\) or the identity function. The function \(f(x)\) would ideally be estimated using data from our own fills.