DEV Community

quantstrat
quantstrat

Posted on Originally published at quantstr.at

The IBS effect in ETFs: section 4.4 of 151 Trading Strategies, replicated in Python and R

This is a standalone version of an article first published on quantstr.at. The Python and R code, the data files and the line-by-line walk-through are in the original.

TL;DR

  • Strategy: Section 4.4 of 151 Trading Strategies sorts ETFs by Internal Bar Strength (IBS), where the close sits within the day's range, and bets on mean reversion the next day.
  • What we did: an attempt to replicate Pagonidis (2014), The IBS Effect: Mean Reversion in Equity ETFs, on Yahoo Finance data for 31 of its 33 ETFs (two are no longer available), first over the original window to 5 December 2013 and then on the 13 years since.
  • Result in the original window: the average next-day return after the lowest IBS bucket was 0.353% and after the highest −0.134% (original: 0.350% and −0.126%). A long-short rule earned 30.8% a year per ETF before costs.
  • Since 2013: the gap between the lowest and highest bucket fell from 0.49 to 0.19 percentage points a day. The same rule earned 9.2% before costs and −0.1% after 5 basis points per trade.
  • The book's decile rule: 38.6% a year before costs since 2013, 16.4% at 2 basis points and −10.4% at 5. It turns over its portfolio about 3.5 times a day, so the cost assumption decides the result.

The idea

IBS = (Close − Low) / (High − Low). It is 0 when the close is the low of the day and 1 when it is the high. Pagonidis finds that ETFs that closed near their low tend to rise the next day and those that closed near their high tend to fall.

IBSi(t)=racPiC(t)−PiL(t)PiH(t)−PiL(t) IBS_i(t) = rac{P^C_i(t) - P^L_i(t)}{P^H_i(t) - P^L_i(t)}

The single-ETF rule goes long when IBS is 0.2 or below and short when it is 0.8 or above, for one day. The book's version ranks the ETFs each day, buys the lowest tenth and sells the highest tenth with equal weights.

Replication: average next-day return by IBS bucket (%)

0 to 0.2 0.2 to 0.4 0.4 to 0.6 0.6 to 0.8 0.8 to 1
Pagonidis (2014), to 5 Dec 2013 0.350 0.096 0.025 −0.032 −0.126
Ours, to 5 Dec 2013 0.353 0.099 0.032 −0.048 −0.134
Ours, after 5 Dec 2013 0.142 0.072 0.025 −0.005 −0.044

Gap between lowest and highest bucket: 0.49 points in the original window (original: 0.476). Probability of a positive next day: 57.2% after the lowest bucket and 46.4% after the highest (original: 56.8% and 46.2%).

Average next-day return by IBS bucket

The rule, before and after 2013

Average annual return per ETF of the long-short rule (compounded):

Yearly returns of the IBS rule

After 2013 the effect is positive in 29 of 31 ETFs but weaker, and trading costs matter: at 5 basis points per trade the rule is about break-even.

IBS as a filter for RSI

Pagonidis combines IBS with Cutler's RSI(3): buy below 10, hold while RSI(3) is 40 or below, and in the filtered version hold only while IBS is 0.5 or below. The sum of daily returns without the filter is 121.9% in the original window (original: 119.0%); with the filter 119.4% (original: 128.6%), in about half the days. We reproduce the halving of time invested but not the improvement in return in that window. After 2013 the filter helps: 30.4% against 20.3%.

The book's decile rule

Annual growth rate of the dollar-neutral decile rule, before and after costs:

Cost per unit traded To 5 Dec 2013 After 5 Dec 2013
None 337.9% 38.6%
2 bps 268.3% 16.4%
5 bps 184.1% -10.4%
10 bps 84.1% -42.1%

Growth of 100 dollars in the decile rule

Break-even cost is roughly 3.9 basis points. Fills at the close are assumed, which is idealised because the final IBS is only known once the close is set.

Limitations

  • Yahoo adjusted prices differ from the vendor in the original, and two ETFs (GXG, RSX) are missing. The ETFs that remain survived to today.
  • This is an attempt to replicate; where choices were not stated (range and volume medians, tie-breaking, the cost model) they are ours and are listed in the original article.
  • No bid-ask spread, market impact or borrow costs in the replication tables. Not investment advice.

Conclusion

The IBS effect reproduces closely in the original window: next-day returns after low-IBS days were 0.49 percentage points higher than after high-IBS days. Since 2013 the gap has narrowed to 0.19, and whether anything is left after trading costs depends on assumptions a backtest cannot settle.

Reference: Pagonidis, A. S. (2014). The IBS Effect: Mean Reversion in Equity ETFs. Working paper, NAAIM. Book: Kakushadze, Z. and Serur, J. A. (2018), 151 Trading Strategies, Section 4.4.

The full article, with the Python and R code: https://quantstr.at/quant-strategies/mean-reversion/?utm_source=devto&utm_medium=syndication

Top comments (2)

Collapse
 
quantstrat profile image
quantstrat •

Here's the Python code: quantstr.at/quant-strategies/mean-...

Collapse
 
quantstrat profile image
quantstrat •