Monday, February 28, 2011

Gaps, part 3

Recently I've come to realise that I've made quite a mistake calculating the 'fill' ratio for the gaps. It's time to correct it, before somebody will embarrass me in the comments ;-).The problem is that I've used asymmetric boundaries when calculating the  statistics. By doing this, the statistics shift in favor of the nearest stop. The closer the stop, the higher the chances of hitting it, but by no means does this mean profit. And previous close is usually not far from the open so chances of hitting it are quite high.
To make statistics fair, I've set the levels symmetric around the open, like this:
gap = open-prevClose
winLevel = open+gap
lossLevel = open-gap

With this calculation* the chances are quite different and closer to my results using the intraday data:
down gap: 52% fill
up gap: 48% fill

*geek note: when both win and loss levels are reached for the same day, it is counted both as win and loss (with daily ohlc data there is no way of knowing which one was reached first) . Data for SPY Feb.2000- Feb-2011.

Code: dumbGaps.m

Sunday, February 6, 2011

Closing the gap, part 2

I felt the need to verify the calculations in the previous post, just to be sure no coding error was made, or at least not a serious one. To do this, I've rewritten the strategy using vector operations rather than 'for' loops and I'm happy to say, the result still stands. Sharpe is a little lower at 1.13, but the curves are quite similar.
To make this post a worthy follow up, I've also included the code:
dumbGaps.m , download_hist_yahoo_data.m

The following remarks are still very appropriate:

  • It is very hard to get a fill at the opening price.
  • Results are frictionless.
  • All this is just a basic concept

Your feedback is very much appreciated.

Friday, February 4, 2011

Closing the gap strategy

Fading the opening gap is a well-known strategy, promising acceptable results with minimal efforts. A great article about trading gaps is written by Scott Andrews. It sounded interesting, so I've decided to spend an hour or so to check if the numbers are right. The basic 'Dumb gap' strategy that I've simulated always trades the opening gap in the direction of the previous days close. In other words, if opening above yesterdays close, go short. Take profit level is set on yesterdays close, if it is not reached, the strategy  closes the position on the days close.
As a test set I've chosen past 10 years of the SPY, ignoring transaction costs and slippage. And the results are:

  • The gaps fully closed on about 75% of occasions
  • The strategy has a sharpe of 1.3
  • Using 'BLUD' (below low of an up day) compensation introduces only marginal improvement. These days are quite rare, ~3% of all occurences.
And as a picture speaks a thouthand words, here are the pnl curves.
Disclaimer: this is just an idea that that needs some work before a tradeable stragegy is achieved. I do not recommend anyone trading using the rules described above.