quantpad.ai The 2011 Cont, Kukanov and Stoikov paper, "The Price Impact of Order Book Events," shows that order flow imbalance explains about 65% of short term price movement. I reproduced it from scratch on recent US equities and landed at 63%, with the same drop in fit on high priced, thin names that the original authors found. The relationship in the paper is contemporaneous. The imbalance and the price move are measured over the same 10 second window, which makes it a description of how price forms, not a prediction. To check whether there's anything tradable, I reran the regression with the imbalance lagged by one bin. The R squared collapsed by 78x. The signal is gone the moment you ask it about the next move instead of the current one. Order flow imbalance moves price. This paper describes that mechanism well. It does not describe a trading strategy. Some research papers are good starting points for one. This isn't, and the test that tells you which is which is the whole point. #quant #quantfinance #algotrading #orderflow #marketmicrostructure #quantpad
Full Transcript
This is one of the most cited research results in quantitative finance. This paper from 2011 says that about 2/3 of every price movement can be explained by order book imbalance. That's the imbalance between the number of buyers at the best bid and the number of sellers at the best ask. Today, we're going to reproduce it entirely from scratch and then answer the one question that really matters, which is whether or not you can trade it. Here I have the paper and its figures in LaTeX format. It doesn't really matter what format it's in. It can be a PDF. And we're going to drag it into our new Quantpedia project. The interesting thing about this paper and about order flow imbalance is that it treats a canceled sell order and a new buy order as the same thing. Because order flow imbalance just measures the delta between the total number of buyers at the best bid and the total number of sellers at the best ask. So, if a seller walks away or a new buyer comes along, that has the same impact on the order flow imbalance. And the paper says that that number, order flow imbalance, explains about 65% of where price goes in the very near term. Okay, so let's test it. The most difficult part by far about reproducing a paper like this as a retail trader would be getting your hands on the data. We don't just need tick data, meaning trade level data, for years and years of history on these US stocks, but we also need to know the best bid and ask. Okay, so Quantpedia just read the entire paper and then decided how it would reproduce. It's also determined exactly how it's going to map this onto available data. It's asking us a couple questions. How much of the paper should I reproduce? The core result, that's all that we care about. Uh and then which stock universe and window should I run on? Let's do 10 to 15 names just to save some time. Okay, so what we're doing right now is just reproducing the core findings of this paper. But after that, I want to clarify something interesting about this paper in particular, and that's going to inform our next steps from there. So, Quantpedia is dealing with millions and millions of rows of data, and it decided in its original plan, if you remember, that it was going to chunk the data. Streaming the data in chunks is an architectural decision that Quantpedia knew to make so that it wouldn't OOM the workspace, meaning run out of memory. Because Quantpedia is familiar with the size of the data that's going to be served from the data API. QuantPad has just finished up and it looks like our results are shockingly actually similar to the research papers. We've perfectly reproduced it in a single prompt, no less. So, the paper got 65% meaning that the order flow imbalance accounts for 65% of the variability in the price change and we got 63%. QuantPad also puts forth a hypothesis about why our results are slightly different from the papers. We found that order flow imbalance explains less of the variability in price change for high price names. Cat, JP Morgan, Apple, these trade at $200 to $350 with a very thin displayed top of book depth. It says that this pattern is similar to what was observed in the original paper, also. I'm going to ask QuantPad to produce one more visual just so that we can see all of the symbols at once and then I'm going to get to something a little bit more important. While QuantPad works on this, I'll explain what we're going to do next. So, this paper looks at price variability and order book imbalance for the same 10-second window. They found that order book imbalance explains 65% of the price movement in the same 10-second window in which the order book imbalance was computed. That's not really that interesting. That's not a forward-looking signal, though. Our visual is done here. They're looking at a price move that happened within a 10-second window and then the order book imbalance from within that same window. It's not a predictive signal. It's two things that happen at the same time and then they analyze them in retrospect and say, "Yeah, the order book imbalance does explain 65% of the variability in the price." Not order book imbalance explains the price movement that will happen in the next time step, in the next bin. So, that's what we're going to test right now. Is this something actually tradeable? Does it have any predictive value or is it just a non-tradeable kind of intuitive fact that they formalized in this research paper? Okay, here's our second visual from QuantPad. I'll just blow this up over here. Okay, I'll blow that up on the screen there or there and now we're going to ask QuantPad to test whether this is actually tradeable. Run the regression again, but lag the imbalance by one bin to see if I haven't been opening any of the files that Quantpedia has been creating, but obviously this is just like a normal IDE where we can open up files in the middle. I kind of just didn't want to crowd our view. We can view spreadsheets, obviously. We can view these parquet files that Quantpedia downloaded of the price information and everything, but I'll just clear that out and blow up the chat here. In Quantpedia, we can also add follow-up messages. So, if I have something that I want to send after this, but I don't want to have to wait by my computer for Quantpedia to finish, I can just send a second message to do or something. Send it and we'll queue it like that. I can send it now to interrupt or I can edit it and I can delete it here. If I wanted to go back and edit a previous message, I can just click it to edit it. I can select the model that I'm going to send that message with, and then I can also, when I send it, I get the option to revert the workspace to the snapshot of all of our files taken here when I sent this message. I can also revert to a previous snapshot just by clicking this button here. And we have snapshots of the workspace for every single message that I've sent before this. It's kind of how file versioning works on Quantpedia. Wow, guys. Okay, so this is not very surprising, but look at the difference in the R squareds here. The explanatory power collapses by 78 times the moment you lag the imbalance by a single 10-second bin. The detail confirms it's noise and not a tradeable signal. The strong contemporaneous R squared is a statement about price formation, not prediction. So, the phenomenon studied in and explained by this paper does not have predictive value. It just explains how price evolves. It's intuitive, really, if you think about it, that order book imbalance would change prices, but actually, I remember that was something that ICT lovers used to hate me for saying. About a year ago, people actually used to vehemently disagree with me that buying and selling pressure moves market prices, which is absolutely ridiculous, but our research here and this paper obviously disputes that. And it says that order book imbalance, otherwise known as buying and selling pressure, is the mechanism by which price changes. If the order book gets imbalanced so that there are many buyers and few sellers, then sellers have more price setting power. In the inverse case, the opposite is true. They set the price higher and then eventually an ask gets hit and price moves up. In the inverse case, the opposite is true. So, we can put that debate to bed, not that it ever should have been a debate, and we can also say that this paper does not have a signal. The paper doesn't describe a trading signal. It just describes a mechanism. But, we were able to perfectly reproduce that research paper with just one prompt and spending $0 on market data. Other financial research papers can serve as very strong jumping-off points for real strategies. This didn't happen to be one of them, but on to the next in-depth
Original Description
quantpad.ai
The 2011 Cont, Kukanov and Stoikov paper, "The Price Impact of Order Book Events," shows that order flow imbalance explains about 65% of short term price movement. I reproduced it from scratch on recent US equities and landed at 63%, with the same drop in fit on high priced, thin names that the original authors found.
The relationship in the paper is contemporaneous. The imbalance and the price move are measured over the same 10 second window, which makes it a description of how price forms, not a prediction. To check whether there's anything tradable, I reran the regression with the imbalance lagged by one bin. The R squared collapsed by 78x. The signal is gone the moment you ask it about the next move instead of the current one.
Order flow imbalance moves price. This paper describes that mechanism well. It does not describe a trading strategy. Some research papers are good starting points for one. This isn't, and the test that tells you which is which is the whole point.
#quant #quantfinance #algotrading #orderflow #marketmicrostructure #quantpad