XLKXLU Ratio Trading Strategy

XLK/XLU Ratio Trading Strategy (Backtest, Returns, Python Code)

The XLK/XLU ratio is the XLK ETF price divided by the XLU ETF price. It is often used to read market sentiment.

A rising XLK/XLU is considered bullish, while a falling ratio is considered bearish.

In this article, we backtest the ratio and use it to time buys and sells for S&P 500. We also provide you with the complete Python code.

The logic behind the XLK/XLU trading strategy

XLK-XLU Ratio Trading Strategy

XLK tracks technology stocks, while XLU tracks “boring” utility stocks. These two sectors are kind of “opposite”. Tech is mostly about growth, while utility stocks are about value and preservation.

Typically, during bullish sentiment, tech stocks lead. Opposite, during a bear market, utilities outperform other sectors.

By charting these two sectors, you can understand market sentiment. If the ratio is going up, tech stocks are stronger, and the market is bullish. If the ratio is going down, the market is generally headed lower.

XLK/XLU trading rules

With this in mind, now the trading rules are the following (members can unlock the trading rules and get trading rules for hundreds of trading strategies):

THIS SECTION IS FOR MEMBERS ONLY. _________________ BECOME A MEBER TO GET ACCESS TO TRADING RULES IN ALL ARTICLES CLICK HERE TO SEE ALL 400 ARTICLES WITH BACKTESTS & TRADING RULES

Let’s backtest the trading rules:

XLK/XLU trading strategy to time S&P 500 – backtest and perforemance

The data is adjusted for dividends and splits. Here is the equity curve:

XLK/XLU trading strategy
XLK/XLU trading strategy

Let’s look at the statistics, facts, and trading performance:

  • CAGR was 9.24% vs. 10.33% for the S&P 500
  • Time spent in the market was 56.23%
  • Risk-adjusted return was 16.43%(CAGR divided by time spent in the market)
  • Maximum drawdown was -26.78% vs. -55.19%

And what if we invest in utilities when the ratio is below the 200-day SMA? Here is the equity curve:

XLK/XLU trading strategy backtest
XLK/XLU trading strategy backtest
  • CAGR improves to 11.60% vs. 10.33% for the S&P 500
  • Time spent in the market is 100%
  • Maximum drawdown is now -51.77% vs. -55.19%

Python code

Here’s the complete Python code for the strategy:

XLK/XLU trading strategy Python code

Similar Posts