Rule-based Portfolio to beat Market Returns

11 min read

The objective of the project is to create a rule-based portfolio for a retail investor. The concept and implementation of rules should be simple and easy to implement, for an ordinary retail investor with a day job. And most importantly, it should be able to beat the broad-based indices!

This article is the final project submitted by the author as a part of his coursework in the Executive Programme in Algorithmic Trading (EPAT) at QuantInsti. Do check our Projects page and have a look at what our students are building.


About the Author

Manoj Hatalage pic

Manoj Hatalage is an Oil & Gas professional with 18 years of experience. He holds various highly recognised certifications in his field. Manoj developed a keen interest in financial markets around three years ago.

Being from a non-financial and non-programming background, he was in search of a systematic approach to trading and investing. A well-designed and all-inclusive EPAT course helped him to gain the structured approach for his future journey in financial markets.

Manoj is determined to gain more knowledge in the field of finance and develop his own sophisticated Quantitative trading and investment strategies.


Introduction

Making money in the market is difficult! The percentage of successful traders, percentage of stocks that we’re able to create wealth for investors are all below 10%. A number of large-cap funds which could beat broad-based indices are below 35 to 40% globally.

We will backtest the equal weight portfolios based on a single criterion and evaluate the performance of these portfolios against the broad-based indices. For this backtest, we will calculate the returns generated by portfolios based on five different factors.  

Broad-based and Smart beta indices

At present, apart from various broad-based indices, there are several smart beta indices launched by NSE. Various AMCs have launched index funds and ETFs, which are available for some of these indices. Past performance of these indices can be calculated from the historical data.

So, instead of doing our own backtest, why not just invest in one of these indices or simply replicate them?

Well, these indices are created with defined rules, there are several factors that affect the performance of these indices.

What is the impact of the changes in these factors on performance?

Let’s see various factors which impact the performance of the portfolio.


Factors that impact the performance of a Portfolio

Costs

If an investor were to replicate the index, the investor will have to bear the transaction costs, brokerage, and other direct taxes. If an investor invests through an index fund, he/she will have to take into consideration the expense ratio and tracking error.

Rebalancing frequency

Smart beta indices are rebalanced quarterly or semi-annually. Let’s say a particular index is rebalanced semiannually. How are the returns and other portfolio parameters affected, if the portfolio is rebalanced quarterly or yearly?

Weightage

The weightage of a stock in an index is based on some factors, sector, and market capitalization. The indices follow restrictions on the weightage of stocks and sectors in indices. We wish to create an equal weight portfolio without stock or sectoral weightage restrictions.

Number of stocks

The performance of the portfolio is affected by the number of stocks in the portfolio. What will be the effect of having a higher number of stocks or a smaller number of stocks?

Stock Universe

The stock universe of these indices is set mainly to large and midcap stocks. The effect of expanding the stock universe should be evaluated.

The impact of all these factors on the portfolio should be quantifiable and examined to draw a firm conclusion.


Strategy

The portfolio will be designed based on various factors. The aim of the portfolio is to simplify the portfolio construction for a retail investor. So, we will consider the basic factors like Alpha, Previous rolling year returns, Volatility, beta and returns w.r.t. Volatility.


Factors (Selection criteria)

  • Alpha: Jensen’s Alpha is used as a selection criterion. Jensen’s Alpha is the return of a stock, more than its theoretical expected return.
  • Yearly Returns: The previous rolling year price returns are used as a selection criterion.
  • Returns/Volatility: The previous rolling year price returns divided by annualized volatility is used as a selection criterion.
  • Beta: Beta is a measure of a stock's volatility in relation to the overall market. Low beta stocks are shortlisted for portfolio creation.
  • Volatility: Volatility is a statistical measure of the dispersion of returns for a given security or market index. Stocks with lower annualized volatility are shortlisted for the portfolio.

Portfolio Parameters

  • Benchmark index: Nifty 50, Nifty 100, Nifty Total market Index.
  • Number of stocks in portfolio: - Portfolio performance for 15, 30, 50 stocks in the portfolio to be measured.
  • Weightage: Equal Weight Portfolio
  • Taxes (Income tax/ LTCG/STGC): 10%
  • Brokerage & transaction costs: 0.275%
  • Cash in hand: 10% of portfolio value or previous cash balance, whichever is higher. The 10% cash component is maintained for the payment of transactional costs and taxes.
  • Factors (selection criteria): Alpha, Previous year returns, Volatility, beta, and returns/volatility.
  • Data: EOD data for equity instruments traded on NSE.
  • Duration of backtest: Jan 2008 to Dec 2020.
  • Rebalance Frequency: Portfolio performance to be evaluated by rebalancing yearly, semiannually, quarterly.
  • Stock Universe: Portfolio performance to be evaluated for different stock universes shortlisted based on average daily turnover.

Methodology

Step 1 - Calculating the factor and average daily value

Measure the value of factor and average turnover value for each stock, for the previous rolling year. Either take all the stocks into consideration or filter the top 750 stocks by average daily traded value and sort them by the selection criteria.

Step 2 - Calculate the current portfolio value

For the initial portfolio, the portfolio value will be the initial capital. Further, when rebalancing, calculate the portfolio value by the sum of CMP*Quantity in hand, for each stock. If the cash in hand is less than 10% of the portfolio calculate the portfolio value by setting aside the cash as per cash component. If the stock is delisted, take the closing price of the last trading day.

Step 3 - Rebalance

If the stock in a portfolio is also present in newly shortlisted stocks, buy/sell the stock so that the stock value = Portfolio Current Value/number of stocks. Calculate transactional costs, profit/loss and taxes for the sold quantity.

If the stock in a portfolio is not present in newly shortlisted stocks, sell the stock. Calculate transactional costs, profit/loss and taxes for the sold quantity.

For the newly shortlisted stocks which are not present in the current portfolio buy the number of units = (Portfolio Current Value/number of stocks)/CMP.

Step 4 - Cash in hand

The transactional costs and taxes will be deducted from cash in hand. During the next portfolio rebalance, initiate by adjusting the cash balance.


Results

Using the above methodology, the backtests were carried out for various combinations of Number of stocks, the stock universe and rebalancing frequency.

Before assessing the performance of various portfolios, let’s first review the price returns of various broad-based indices and strategy (smart beta) indices for the same period (i.e., 1st Jan 2008 to 31st Dec 2020)

Sr. No.

Index

CAGR

MAX

DRAWDOWN

Rebalancing Frequency

1.

Nifty 50

6.52%

60%

Semi Annual

2.

Nifty Total market Index

5.92%

65%

Semi Annual

3.

Nifty 100

6.70%

62%

Semi Annual

4.

Nifty Low Volatility 50

11.23%

52%

Quarterly

5.

Nifty Alpha 50

8.21%

79%

Quarterly

6.

Nifty 200 Momentum30

9.94%

68%

Semi Annual

7.

Nifty High Beta 50

-6.45%

81%

Quarterly

8.

Nifty Alpha Low volatility 30

11.56%

58%

Semi Annual

 

The returns and drawdown numbers of these indices are obviously different from inception to date. The indices and portfolios show much better results if we start the backtest just 3 years earlier or later than 2008.

The reason why we are considering backtest period from 1st Jan 2008, is the current market phase. Today every other person in the market is of opinion that, the market is expensive and soon we may expect a sharp correction.

What could be the greatest fear of an investor, then seeing a sharp correction (drawdown) immediately after the strategy is deployed or a rule-based portfolio is implemented.

So, we have started the backtest just before the worst drawdown Indian markets have seen to date.

PORTFOLIO PERFORMANCES

 

 

Stock universe

750

750

750

All

All

All

 

Number of stocks

15

30

50

15

30

50

 

 

Returns

Max Drawdown

Returns

Max Drawdown

Returns

Max Drawdown

Returns

Max Drawdown

Returns

Max Drawdown

Returns

Max Drawdown

Yearly Rebalance

Alpha

5%

-87%

4%

-84%

6%

-82%

3%

-87%

4%

-85%

4%

-84%

Yearly Returns

-2%

-89%

3%

-83%

4%

-82%

0%

-89%

3%

-83%

4%

-82%

Returns/

Volatility

0%

-85%

4%

-83%

6%

-82%

0%

-86%

4%

-83%

6%

-82%

Low_Beta

1%

-63%

6%

-60%

8%

-64%

6%

-58%

8%

-63%

8%

-65%

Low_Volatility

6%

-50%

9%

-47%

9%

-49%

5%

-50%

8%

-46%

9%

-48%

 

 

Semi annual Rebalance

Alpha

6%

-87%

8%

-84%

7%

-83%

9%

-88%

8%

-86%

8%

-85%

Yearly Returns

4%

-86%

3%

-84%

5%

-82%

2%

-87%

6%

-84%

6%

-83%

Returns/

Volatility

8%

-86%

6%

-83%

6%

-82%

10%

-87%

9%

-82%

10%

-82%

Low_Beta

3%

-61%

7%

-60%

6%

-63%

10%

-63%

11%

-65%

10%

-64%

Low_Volatility

6%

-50%

8%

-46%

9%

-48%

6%

-48%

8%

-44%

9%

-46%

 

 

Quarterly Rebalance

Alpha

6%

-88%

7%

-84%

9%

-81%

7%

-86%

7%

-86%

9%

-84%

Yearly Returns

9%

-84%

7%

-83%

8%

-80%

6%

-83%

9%

-84%

9%

-82%

Returns/

Volatility

12%

-83%

10%

-82%

10%

-80%

12%

-84%

13%

-81%

13%

-80%

Low_Beta

7%

-56%

8%

-58%

7%

-60%

11%

-59%

9%

-63%

9%

-65%

Low_Volatility

8%

-45%

9%

-45%

10%

-46%

6%

-45%

9%

-45%

10%

-47%

                             

Observations

Rebalancing frequency

The yearly rebalanced equal weight portfolios fail to beat the broad-based indices and have higher drawdowns than broad-based indices, except for low volatility portfolios which have close to market returns and lower drawdown.

Semi-annual rebalancing of portfolios is able to beat market returns except for yearly returns portfolio. Quarterly rebalanced portfolios generate comparatively higher returns except for portfolios based on alpha, as some of the semiannual rebalancings has generated higher returns.

Drawdown of Alpha, yearly returns, returns w.r.t. volatility is higher than broad-based indices irrespective of rebalancing frequency.

Number of stocks

The impact of a number of stocks on portfolio returns is not conclusive, in some of the portfolios, reducing the number of stocks created higher returns and in some of the portfolios, returns decreased with an increase in the number of stocks in the portfolio. In most cases, the maximum drawdown has decreased by more than 2 to 5% when the number of stocks is increased, except for a low beta portfolio where the drawdown is increased with a number of stocks in the portfolio.

Stock universe

Filtering the stocks based on market capitalization is an appropriate system. However, since we do not have access to a historical market capitalization of stocks, we have used average traded value to filter the stocks.

The returns portfolios with the stock universe of the top 750 stocks filtered based on average daily traded value are lower than the complete stock universe. This may have resulted due to several penny stocks, traded in huge quantities being filtered when we filter stocks based on average daily traded value. The average traded value should not be used as a proxy to market capitalization for filtering the stocks.


Challenges faced during backtesting

Data - The biggest and only challenge faced was to obtain the data!

The first obvious step was to try and obtain the data through free resources. The leading concern was to eliminate survivorship bias, to obtain the splits and bonuses adjusted data of each stock traded on NSE, during our backtest period.

There is also an issue with symbol change, mergers. There is no single source that will provide the splits and bonuses adjusted data, for listed and delisted equity instruments.

We can access the data for each instrument from NSE bhavcopies but the bhavcopies are not adjusted for splits & bonuses. The split and bonus history of delisted stocks is unavailable. Therefore, the only option available was to procure the data.

But again, the data vendors also do not have the data for stocks that are delisted before a certain period. The symbol change directory is available but only from 1999. The EOD data from 2008 or 2010 till date have fewer discrepancies.

There were few discrepancies observed even during this period, but it was restricted to 10 instruments. The unadjusted data for these 10 instruments were included in the procured data, which may have slightly affected the backtest performance.


Limitations

We have compared strategies based only on point-to-point returns. Various strategies generate different results during different market phases. It is possible that if we would have selected different start dates and end dates, the results would have been different. The performance of these portfolios should be evaluated in-depth, for different market phases.

Markets are dynamic

Carrying out a backtest gives an understanding of how the various parameters worked in past. It is very easy to beat market returns in history or on paper. There are new forces and paradigms which affect the economy and markets in long run. What worked in the past may not necessarily work in the future.

Slippages

During the backtest the closing price on rebalance date is used for calculation. Practically it is not possible to rebalance the entire portfolio exactly at the closing price, on rebalance date. This may affect the portfolio performance.

Transaction costs and taxes

Over the years the taxes, brokerage, transactional costs have changed. The transactional costs and taxes will affect the portfolio returns. Also, we have considered taxes at flat 10% on each rebalance date, which will vary from 0 to 30 % depending on various personal factors like capital invested, duration of stock in the portfolio, tax bracket of an individual and of course, on how creative one’s chartered accountant can be!

Risk-free rate

For the backtest risk-free rate is not considered. The portfolio constituents and portfolio returns will change based on the risk-free rates.

Scaling up & liquidity

We have not considered the ease of buying or selling without affecting the stock prices. The portfolios include small-cap, micro-cap stocks. As the portfolio grows, we may not be able to exit the entire quantity at the desired price. The impact cost during entry and exit will affect the portfolio performance. Whilst shortlisting the stock, a filter should be added to ensure the entry and exit of the stock without affecting the price.


Future Development

Multi-factor portfolio: For the scope of this project we restricted our portfolios based on a single factor. Portfolios based on two or three factors may be able to generate higher returns with lower drawdowns.

Portfolios based on Fundamental criteria: We have backtested the portfolios based on very few factors, which are based on the price of the stock. Other factors like quality or value of stock were not a part of this study.

The portfolios based on fundamental factors or a combination of price, volatility, fundamental factors may generate higher returns.


Conclusion

The Quarterly rebalanced portfolios based on returns w.r.t. volatility and low volatility generated higher returns in backtested portfolios. If we consider the drawdowns alone, the Low beta and Low volatility portfolios have shown very low drawdowns.

These observations are based on the CAGR returns as of 31st Dec 2020. A single factor may not always consistently outperform other factors. Various factor-based portfolios outperform other factors in shorter or longer time periods.

Let’s look at the graphical presentation of the cumulative returns of the quarterly rebalanced portfolios based on low volatility, low beta, and volatility w.r.t returns.

cumulative returns chart

From the above cumulative returns chart, it is visible that a comparatively, low volatility portfolio has been a consistent performer. For short time periods and at the end of backtest period, returns w.r.t. volatility portfolio was able to beat low volatility and low beta portfolio.

It is important to note that, for a long time returns w.r.t. volatility portfolio has underperformed the broad-based index and low volatility portfolio. If we purely look at the CAGR numbers at the end of backtesting, returns w.r.t. volatility portfolio may be seen as a better option.

However, if we look at the drawdowns and consistent performance, the quarterly rebalanced low volatility portfolio is a clear outperformer.

Also, another observation that can be noted here, which supports the low-beta anomaly in CAPM observed by a number of scholars, across many markets. The low beta portfolio was able to generate higher returns, with lower drawdown, than Nifty High Beta 50 index.


If you want to learn various aspects of Algorithmic trading then check out this algo trading course which covers training modules like Statistics & Econometrics, Financial Computing & Technology, and Algorithmic & Quantitative Trading. EPAT equips you with the required skill sets to build a promising career in algorithmic trading. Enroll now!


File in the download: Factor portfolio Python code Jupyter notebook


Disclaimer: The information in this project is true and complete to the best of our Student’s knowledge. All recommendations are made without guarantee on the part of the student or QuantInsti®. The student and QuantInsti® disclaims any liability in connection with the use of this information. All content provided in this project is for informational purposes only and we do not guarantee that by using the guidance you will derive a certain profit.

 Advanced Momentum Trading: Machine Learning Strategies Course