Inferring Trade Aggressor Side from Quotes and Trade Prices
Summary
The document considers how to infer whether a trade was buyer or seller initiated when a feed omits the aggressor-side field. A basic quote test labels trades at or above the best ask as buys and those at or below the best bid as sells, leaving trades inside the spread or ambiguous quotes unclassified. This can fail when the trade itself changes the best quote or when trade and quote messages arrive out of order.
The replies point to the Lee-Ready method, which uses the prevailing quote and a trade-price test for cases inside the spread. They caution that trade direction remains imperfectly classified, especially with delayed or misaligned quote and trade feeds such as equity SIP data. Another reply notes that smart routers can execute aggressive parent orders through passive child orders, so observed trade direction may not reveal the parent order’s intent. Modeling order-book changes may provide more context, but the discussion offers no tested algorithm or precision comparison.
Key ideas
- A quote test classifies trades at the ask as buyer initiated and at the bid as seller initiated.
- Trades inside the spread and quote changes caused by the trade are difficult to classify reliably.
- The Lee-Ready method is suggested as a common approach, but misclassification remains possible.
- Feed delays and message ordering can distort classifications based on quotes and trades.
- Trade direction may not reveal parent-order intent when smart routers use passive child orders.
Tags
Full text
# Algorithm to detect the aggressor side of a trade
# Algorithm to detect the aggressor side of a trade
Most of the exchanges provide aggressor side property of trades (e.g. Tag=5797 AggressorSide on CME) in their raw data. But many data providers do not provide this information via their datafeed API's. I need an algorithm to estimate with high precision the trade's aggressor side.
Suppose, I receive depth data updates and trades updates. The simplest algorithm is (in Java code):
```
public static int get_aggressor(int bid, int ask, int trade_price){
int aggr = Tags.UNKNOWN_SIDE;
if (bid < ask){ // i.e. no cross
if (trade_price >= ask){
aggr = Tags.BUY_SIDE;
} else if (trade_price <= bid){
aggr = Tags.SELL_SIDE;
}
}
return aggr;
}
```
where `bid` and `ask` are best bid/ask prices at a time when the trade was received. This algorithm may fail to detect the aggressor when the trade in the question affects the best bid/ask.
Question: Suppose I have the history of recent price updates. How to improve the precision of the aggressor detection algorithm? Also, consider two types of data feed:
- The trades always arrive before the resulted price updates
- The order of updates arrival in #1 is not guaranteed.
Please let me know if there are published researches on this topic.
## Answer by madilyn (score 11)
https://quant.stackexchange.com/a/14515
The most commonly-known approach to this is described in Inferring trade direction from intraday data (1991) by Lee and Ready. You will find that the non-trivial part has to do with classifying trades that are reported inside the spread. I believe you will find that the Lee-Ready algorithm will outperform the naive midpoint reference approach suggested by @Svisstack, but nevertheless you will not be able to fully mitigate misclassification.
A more modern exposition of the criticisms of the Lee-Ready algorithm is given by Chakrabarty et al (2012), which should give you a starting point for other readings.
## Answer by experquisite (score 7)
https://quant.stackexchange.com/a/14546
Most of these classifications of aggressive trades are not so relevant anymore, due to smart order routers which execute aggressive parent orders using passive child orders, as Maureen O'Hara points out in http://www2.warwick.ac.uk/fac/soc/wbs/subjects/finance/fof2014/programme/maureen_ohara.pdf
I am not sure what I would do if I wanted this information, but I suspect one will have to model the order book in order to get a real sense of whether liquidity is actually entering or leaving the market.
EDIT: Also, be very careful if you are trying to do this for equities using SIP data, since very often the quote feed and the trade feed are lagged with respect to each other, which will throw off any of the above classifications.
## Answer by Svisstack (score 4)
https://quant.stackexchange.com/a/14514
I think spread midpoint will be more safe reference, after that if transaction price is higher from midpoint its buy, otherwise sell, if equal then not specified.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.