Thursday, September 27, 2012

Gap strategy with intraday data

The gap fading strategy from previous posts looked all right, but my worry is that Yahoo data does not provide accurate quotes. To check the strategy performance, I've generated a new OHLC dataset based on the Weighted Average Price (wap) of 30-second intraday data. So the opening quote is the wap of first 30 seconds of trading and close is the last 30-second wap. To make sure that my dataset is correct, I have compared it to the yahoo quotes. As shown in the chart below, the difference between the two quotes is ~5ct which seems very reasonable.
Now, testing the gap fade strategy on the OHLC data that I generated myself produces much less favorable result:
One look at the pnl chart is enough to say that this strategy would be rubbish.
This brings me to a conclusion that I already was aware of: Yahoo opening quotes are not suitable for strategy backtesting.

Thursday, September 20, 2012

Gap strategy revisited

In the beginning of 2011 I've backtested a fade gap strategy. There seemed to be an edge to fading gaps, so let's take a look how this strategy performed since then. Once again strategy rules:
  • Trade only gaps larger than 0.1 %
  • Enter on the open (short for Up gap and long for Down gap). Profit target is set at previous day close.
  • If profit target was not reached during the day, exit on close
This time I corrected the data for dividends.

The results out-of-sample are pretty good, the strategy was doing well in 2011-2012.
A more realistic case is including transaction cost of about 0.03% , which is approximately 3ct for SPY. 1ct is IB commission, another two are needed for crossing the bid-ask spread.
The Sharpe ratio for these strategies is still not solid enough for me to actually put my money on it.

buyAndHold      0.189366
fadeUpGaps      0.508378
fadeDownGaps    0.595578
fadeAllGaps     0.783124

... and I still keep wondering, how can there be an edge while there seems to be no significant correlation between the night gap and the day session change.

Wednesday, September 19, 2012

SPY opening gaps

There are quite some people in the blogsphere claiming that gap trading is statistically profitable. Just google for 'opening gaps' or something similar to get a bunch of links. Some claims are quite interesting stating >70%  chance of  a gap closing after a 'gap up'. Well, I imagine that it is possible to have a 70% 'closed gap' statistics and still have zero edge in trading the gap. I have looked into this topic about a year ago and first results were promising.
This time I took a look at the matter in a slightly different way: looking for correlation between overnight change of the SPY (previousClose-to-open) and the daily change (open-to-close) of the following trading session.
Below is a chart of cumulative daily percentage changes  of SPY for about 3 years of data. Blue line is the overnight change and green line the day session change. It is immediately clear that day session is more volatile then night session. . Apart from that nothing really special in this  chart.
More insight comes from plotting the overnight return vs daily return :
Judging by eye, there is no relation between nightly change and the daily session. Testing for correlation between the two gives : 0.000062 ... yes, zero.  I'm not sure while my previous attempts at building a gap strategy produced positive results, but now I'm determined to get to the bottom of this...