financialnoob.me

Blog about quantitative finance

Buy on gap strategy and its performance over time

In this short post I will backtest buy on gap intraday mean reversion strategy and demonstrate how its performance has deteriorated over time. The strategy is described in E.P.Chan’s book ‘Algorithmic trading: winning strategies and their rationale’. The rules of the strategy are very simple, below is a quote from the book describing it:

1. Select all stocks near the market open whose returns from their previous day’s lows to today’s opens are lower than one standard deviation.The standard deviation is computed using the daily close- to-close returns of the last 90 days.These are the stocks that “gapped down.”

2. Narrow down this list of stocks by requiring their open prices to be higher than the 20-day moving average of the closing prices.

3. Buy the 10 stocks within this list that have the lowest returns from their previous day’s lows. If the list has fewer than 10 stocks, then buy the entire list.

4. Liquidate all positions at the market close.

As my stock universe I will use constituent stocks of Vanguard Small-Cap Value ETF (ticker: VBR). The list of constituent stocks might not be exactly accurate because I parsed it several months ago, but it not important. The main goal is to have big enough stock universe. I used small-cap stocks because I think that small-cap market should be less efficient and therefore have more trading opportunities compared to large-cap stocks from SP500. Also we need to understand that the data used has a survivorship bias, but since our holding period is from market open to market close, it shouldn’t matter.

I will backtest the strategy using 3 year periods starting in 2005 and moving 1 year forward until 2018. I will remove any stocks that has a volume of less than 1000 on any trading day during the backtest period. I assume that two-way transaction cost is 0.1%. The code for backtesting is provided below.

Now let’s look at the results.

Strategy performance without transaction costs

As we can see above the strategy has very good performance in earlier time frames. Sharpe ratio for a 3-year period starting in 2005 is 3.58 and the strategy continues to have positive returns and Sharpe ratio bigger than one until 2015–2018 trading period. Now let’s look at the results which account for the transactions costs.

Strategy performance with transaction costs

Here the returns and Sharpe ratios are significantly lower, but they are still very good in earlier time frames. In 2008–2011 trading period strategy’s Sharpe ratio is 1.57 with an APR of 70%. But then the performance starts to deteriorate. The book was published in 2013 and after that time only one period (2014–2017) has positive returns. Let’s look at the scatter plot of Sharpe ratios.

Sharpe ratios of the strategy in different trading periods

We can clearly see a downward trend in Sharpe ratios on the plot above. Now I will plot strategy returns for the first (2005–2008) and the last (2018–2021) trading periods. Also for comparison I will include market returns (average return of all stocks during that period).

Cumulative returns during 2005-2008 trading period
Cumulative returns during 2018-2021 trading period

Here we have clearly demonstrated how performance of buy-on-gap strategy has deteriorated over time. I was surprised to see how well this simple strategy performed in 2005–2010. I think it might be interesting to test this strategy on different (non-US) markets or maybe experiment with different lengths of moving windows used for calculating moving average and moving standard deviation.


Jupyter notebook with source code is available here.

If you have any questions, suggestions or corrections please post them in the comments. Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *