Simple way to come up with trading strategies using order flow data

FX Order Flow as a Predictor

By Ernest P. Chan, Managing Member of QTS Capital Management, LLC.

Order flow is signed trade size, and it has long been known to be predictive of future price changes. (See Lyons, 2001, or Chan, 2017.) The problem, however, is that it is often quite difficult or expensive to obtain such data, whether historical or live. This is especially true for foreign exchange transactions which occur over-the-counter. Recognizing the profit potential of such data, most FX market operators guard them as their crown jewels, never to be revealed to customers. But recently FXCM, a FX broker, has kindly provided me with their proprietary data, and I have made use of that to test a simple trading strategy using order flow on EURUSD.

First, let us examine some general characteristics of the data. 

It captures all trades transacted on FXCM occurring in 2017, time stamped in milliseconds, and with their trade prices and signed trade sizes. The sign of a trade is positive if it is the result of a buy market order, and negative if it is the result of a sell. If we take the absolute value of these trade sizes and sum them over hourly intervals, we obtain the usual hourly volumes (click to enlarge) aggregated over the 1 year data set:

image-1.png

The highest volume occurs between 15:00–16:00 London time.

Next, I compute the daily total order flow of EURUSD… 

(with the end of day at New York’s midnight), and I establish a histogram of the last 20 days’ daily order flow. I then determine the average next-day return of each daily order flow quintile. (I.e. I bin a next-day return based on which quintile the prior day’s order flow fell into, and then take the average of the returns in each bin.) The result is satisfying:

img-epchan2.png

We can see that the average next-day returns are almost monotonically increasing with the previous day’s order flow. The spread between the top and bottom quintiles is about 12 bps, which annualizes to about 30%. This doesn’t mean we will generate 30% annualized returns, since we won’t be able to arbitrage between today’s return (if the order flow is in the top or bottom quintile) with some previous day’s return when its order flow was in the opposite extreme. Nevertheless, it is encouraging. Also, this is an illustration that even though order flow must be computed on a tick-by-tick basis (I am not a fan of the bulk volume classification technique), it can be used in low-frequency trading strategies.

One may be tempted to also regress future returns against past order flows, but the result is statistically insignificant. Apparently only the top and bottom quintiles of order flow are predictive. This situation is actually quite common in finance, which is why linear regression isn’t used more often in trading strategies.

Finally, one more sanity check before backtesting. 

I want to see if the buy trades (trades resulting from buy market orders) are filled above the bid price, and the sell trades are filled below the ask price. Here is the plot for one day (times are in New York):

img-epchan3.png

We can see that by and large, the relationship between trade and quote prices is satisfied. We can’t really expect that this relationship holds 100%, due to rare occasions that the quote has moved in the sub-millisecond after the trade occurred and the change is reported as synchronous with the trade, or when there is a delay in the reporting of either a trade or a quote change.

So now we are ready to construct a simple trading strategy that uses order flow as a predictor. 

We can simply

  • buy EURUSD at the end of day when the daily flow is in the top quintile among its last 20 days’ values, 
  • and hold for one day, 
  • and short it when it is in the bottom quintile. 

Since our daily flow was measured at midnight New York time, we also define the end of day at that time. (Similar results are obtained if we use London or Zurich’s midnight, which suggests we can stagger our positions.) In my backtest, I have subtracted 0.20 bps commissions (based on Interactive Brokers), and I assume I buy at the ask and sell at the bid using market orders. The equity curve is shown below:

img-epchan4.png

The CAGR is 13.7%, with a Sharpe ratio of 1.6. Not bad for a single factor model!

Acknowledgement: I thank Zachary David for his review and comments on an earlier draft of this post, and of course FXCM for providing their data for this research.

This post originally appeared on Quantitative Trading in February.


Those who signup for Alpaca will be entered in a lucky drawing to receive a free copy of “Machine Trading,” by Author Ernie Chan.

Medium - Machine Trading.png

About the Author: Ernie is the Managing Member of QTS Capital Management, LLC., a commodity pool operator and trading advisor. Ernie has worked for various investment banks (Morgan Stanley, Credit Suisse, Maple) and hedge funds (Mapleridge, Millennium Partners, MANE) since 1997. He received his Ph.D. in physics from Cornell University and was a member of IBM’s Human Language Technologies group before joining the financial industry. He is the author of “Quantitative Trading: How to Build Your Own Algorithmic Trading Business”, “Algorithmic Trading: Winning Strategies and Their Rationale”, and “Machine Trading: Deploying Computer Algorithms to Conquer the Markets”. Find out more about Ernie at www.epchan.com.

===

 

/