Portfolio Design

Advanced concepts in stock investment portfolio design.  Fundamentals, technical analysis and many other related topics are discussed.

Overweight One Sector Based on Sector Performance

In the post How To Overweight One Sector In A Portfolio, I described how to increase the weighting of one sector relative to the others. Today, I will show how to overweight a sector based on recent sector performance.

Stock market analysis fueled by Portfolio123.

In this example, sector performance is measured using the formula EMA(50, 0, GetSeries("...") / EMA(200, 0, GetSeries("..."), where the series used by GetSeries is the SPDR Exchange Traded Fund (ETF) that best represents the sector. The Financial Services ETF (Symbol: XLFS) will represent the Financial sector as it is a better representation of Financials ex-Real Estate.

Note: Real Estate was recently moved out from the Financial sector and into its own sector. The ETF representing Real Estate is XLRE.

The Telecom sector will not be supported in this example as there aren't enough telecom companies to bother with trying to control the weighting.

Before getting started on the simulation, some custom formulas are defined to make the rules easier to follow: The custom formulas are shown below.

Custom formulas for the ten sectors (excluding Telecom)

The general setup for the simulation is pretty straight forward.  The rebalance frequency is set to weeklyand sold holdings are allowed to be rebought at current rebalance. The ideal weight for new positions is set to 2%, with a maximum weight deviation of 10%. The general setup and position sizing are shown below.

General simulation setup for the performance-based sector overweighting

The Buy rules consist of three distinct parts:

  1. Buy1-Buy10:  The performance of the sector ETFs are mapped into variables. The variable names are kept short by using the last character of the ETF symbol.
  2. Buy11: The performance of the sector for the stock currently being processed is mapped into the variable @Weight.
  3. Buy12:  @Weight is compared against all of the sector performance variables @Y, @K, @I, ... If @Weight is the highest of all ten sector performance variables then the sector that the stock resides in is the highest performing sector. Thus the top ten ranked stocks from that sector will be allowed into the portfolio. Otherwise, only the top 5 stocks will be bought.

The final rule Sector != Telecom blocks stocks from the telecom sector from being bought.

Simulation Buy rules

Set the Sell rule to TRUE. This is a big simplification to avoid having to include logic similar to what is in the Buy rules. i.e. checking the sector weights and selling stocks in sectors with too high of a weight. The simplification comes at a price however. as there will be many buy/sell differences.

Simulation Sell rule and Period / Restrictions

When the simulation backtest is run, the current sector allocation shows a Technology weight approximately double that of the other sectors.

Current sector allocation after the simulation has been run

Please note that there is an issue relating to the recent Global Industry Classification System (GICS).  With Real Estate becoming the eleventh sector, the number of sectors are eleven instead of ten. In all likelihood, you won't get a backtest representative of what you could get going forward, unless you block financials and real estate from being purchased.