A lot of research already have been done trying to find out how to predict the stocks market returns. On a daily time frame, both trend-following and mean-reversal trading strategies applied to single stocks can’t sustain a stable Sharpe ratio across the time, making us believe that even if the random walk hypotesis is wrong, we still can’t find a model that precisely describe how the prices moves. But, as discussed in my previous article (Technical Analysis for intraday stocks trading? FORGET IT!), the relationship between the stock’s future index and the stocks individualy allow us to gather some Alpha.
The trading idea that will be presented here is quite simple and was first proposed by Andrew W. Lo and A. Craig MacKinlay, in their paper When Are Contrarian Profits Due to Stock Market Overreacction (1990). The same pattern was also documented in the paper Contrarian Strategies and Cross-Autocorrelations in Stock Returns (1998) in the French Stock market.
The base point of this trading strategy is that stocks do overreact. To test this, it’s natural to test for the presence of autocorrelation in the stocks returns. For those who doesn’t know, correlation is a number that measure the presence os statiscical relationship between two time series. Let X and Y two random variables, the correlation between them is:
Where are the sample standard deviation of the series and and are the sample means. The concept of autocorrelation derives from the fact that we are trying to find some kind of correlation in X and in its own past values, not with another random variable.
So, the obvious starting point for testing stocks overreaction is evaluating the presence of autocorrelation between today’s return and past n returns.
In this article, i’m going to test this hypothesis for the Brazilian stocks. The data used here was directly from the BM&F Bovespa FTP. This database contains more than 2 years of tick-by-tick data, but, for this study, was adjusted to the daily frequency. Th data span vary from 25/11/2014 and 20/01/2017.
The data was corrected from dividends, splits, inplits and subscription rights accordingly to Bloomberg’s database.
As mentioned before, the first basic idea for testing for overreaction in stocks is looking if there is any kind of autocorrelation in the time series of returns for individual stocks. The language i’ll be using for this is Python.
Let’s first retrieve the data first. I’ve put all my data in a MongoDB server. The acess to it is done via an excellent library called Arctic. For those how don’t know Arctic project, you can check it here.
Now, equities is a Pandas DataFrame cointaining the first 97 most liquid stocks in brazilian equity market. We can do this also using Yahoo/Google Finance databases; you’ll find the same results.
Right now, ret_eq will be our return serie. It’s a 535 x 97 DataFrame (535 days for 97 stocks). The autocorrelation is simple done using acf function, contained in the statsmodels.tsa.stattools library.
In this test, we’ll gonna be using a 80% confidence interval. It’s not a huge confidence, but the main purpose here is always to find Alpha and not to prove our models has a super high statistical security. When it comes to stock market, few things have that and normally mostly of the Alpha do exist in situations where the confidence interval is lower than the usual 95%.
When we mean our individual results and plot it, what we get is not so exciting:
This graph is simple the means of the autocorrelation values between the return series and itself lagged in n days. As you can see, there isn’t any lag that gave us some statistical confidence, even in 80%. So, can we conclude then that stocks do not overreact? NO.
As mentioned in my previous post, stocks have a lot of cross-correlation. Why don’t we try mesure the overreaction using this concept? The idea now will be mesure if there is some kind of overreaction when some stock outperforms (or underperforms) the mean return of the market (instead of just see if it went up or down like before).
To do this, i used the same metodology as Lo and Craig. Instead of using the Index to track market perfomance, they simple used a equally-weighted returns of all stocks.
Now, using the same calculation than before, our results changes a little:
Now we can see that there is some kind of negative autocorrelation in the relative return series and itself lagged by 1 day. That means that mostly of the days when a stock outperform the market, the next day it tends to underperform.
If we do simple sell the outperformers in the market close and buy the underperformers, using the same capital allocation to everyone, we get this result curve:
Obviously, that’s not so simple. Any kind of cost was added to this backtest. When dealing with stocks that’s critical, so that’s why i won’t measure any kind of perfomance of this trading strategy yet because that’s still on the rough stone. There’s a lot to mold. We can test other more intelligent types of position sizing, filters, stops… We can the same ideia for higher and lower frequencies. And that’s what I intend to do, but on next articles.
The idea here is to show that’s still Alpha around there, even with pretty old ideas.