By quintuitive
Markets are very smart in absorbing and reflecting information. If you think otherwise, try making money by trading. If you are new to it, make sure you don’t bet the house.
In other words, markets are efficient. At least most of the time. So then why people trade? The general believe is that there are windows during which prices of certain assets are inefficient. Thus, there are opportunities to make money. Is the presence of autocorrelation one such opportunity? Let’s find out.
To keep things simple, we will use the standard R acf function to compute the autocorrelation.
require(quantmod) spy=getSymbols("SPY",from="1900-01-01",auto.assign=F) # Note: We use adjusted close - it's unrealistic to expect anything from actual close in the # presence of dividends spy.rets = ROC(Ad(spy),na.pad=F) aa = acf(tail(spy.rets,500),main="ACF computed over the last 500 days") head(aa) # [1] 1.000000000 0.051116484 -0.037469705 -0.010014871 -0.126667484 -0.004113005
This will produce the following chart:
It shows the autocorrelation coefficients at different lags. The first lag is the correlation of the series with itself (lag 0), and, it’s always 1. The second value (0.051116484) is the correlation of the series with the series lagged by one.
The two dashed lines are the confidence intervals for the lags. They are of special interest since we are going to use them to decide when there is significant autocorrelation. How are they computed? To find the answer, I had to look at the acf’s code:
# xx is the series, conf.level is the confidence level - think 0.95 for instance conf = qnorm((1 + conf.level)/2)/sqrt(sum(!is.na(xx)))
The above is nothing else but computing confidence intervals for normal (0,1) distribution. It still puzzles me (I couldn’t find an answer quickly when I thought about it) why the correlation coefficients at different lags are distributed normally in (0,1), but that’s irrelevant.
The last question is how to trade extreme autocorrelation – do we bet that the autocorrelation persists, …read more
Source:: r-bloggers.com