How to Backtest Stock Fundamentals Using Portfolio123

Step 6: Set up the backtest

Once you are on the settings page, I recommend you change the benchmark to the S&P 500 Equal Weight.

Changing the backtest benchmark

Then you will want to click on the BACKTEST tab and adjust the settings.  I recommend setting the Slippage % to 0, the Carry Cost % to 0, the date range from 01/02/1999 to the end of the previous year, Rebalance Frequency to 1 Year, and the Risk Statistics Period to Monthly.  It is important to use a 1 Year rebalance period in order to compare your results to most academic studies, and to also simulate the 1-year minimum holding period required for the low US long term capital gains tax rate.

Changing the backtest settings

Step 7: Run the backtest

After you make those adjustments, click the CLEAR RESULTS button (circled above) and then click the RE-RUN BACKTEST button.

Portfolio123 Backtest results

After you hit the Re-Run Backtest button, you will get the summary statistics above and a graph of the screen over time as compared to the benchmark. I recommend that you enter the screen statistics into a spreadsheet (I recommend Google Docs if you don’t have Excel) for this 1st quintile. Next, click on the top most date in the list of detailed Backtest Results as highlighted in the screenshot below.

Backtest results details

Clicking on that date will list the rank data and Screen Factors for each stock in the first quintile.  Record the median PE value listed under the @PEIncXorTTMMedian in your spreadsheet. If you don’t see @PEIncXorTTMMedian be sure to select the Screen Factors button.  Once you are done doing that, click the “X” in the upper right hand corner of the box to close that view.

 

Backtest Factor median

Step 8: Run the rolling backtest

Next you will want to run a rolling backtest of this 1st quintile screen to get the average excess return of the 1st quintile regardless of what month we start the backtest on.  We do this to avoid being fooled by seasonal issues.  Click the ROLLING BACKTEST tab on the screen page. Make sure to set the date range the same as you do before in step 6. The set the Frequency to 4 weeks to test each month (weekly frequency seems overkill to me for an annual holding period) and also set the Holding Period to 1 Year.  When you finish changing those settings so they match the screenshot below, click the RUN ROLLING BACKTEST button.

Rolling Backtest on Portfolio123

Look for the Average line towards the bottom of the backtest results and then record the number under the Excess% column.  The position of the average excess returns result is highlighted in the image below.

Rolling backtest average excess returns

Step 9: Backtest the second quintile

In the previous step, you finished backtesting the 1st quintile.  Great work! Now you just have to repeat this process 5 more times. Sorry.

To backtest the second quintile you need to go back to the screen RULES tab and change the second to last rule.  It should be changed to the following:

FRank(“PEInclXorTTM”,#Previous,#DESC) > 20 AND FRank(“PEInclXorTTM”,#Previous,#DESC) <= 40

Portfolio123 backtest rules for the 2nd qunitile

Then repeat the process for steps 7 and 8.

Step 10: Backtest the third quintile

To backtest the third quintile you need to go back to the screen RULES tab and change the second to last rule.  It should be changed to the following:

FRank(“PEInclXorTTM”,#Previous,#DESC) > 40 AND FRank(“PEInclXorTTM”,#Previous,#DESC) <= 60

Portfolio123 backtest rules for the 3rd qunitile

Then repeat the process for steps 7 and 8.

Step 11: Backtest the fourth quintile

To backtest the fourth quintile you need to go back to the screen RULES tab and change the second to last rule.  It should be changed to the following:

FRank(“PEInclXorTTM”,#Previous,#DESC) > 60 AND FRank(“PEInclXorTTM”,#Previous,#DESC) <= 80

Portfolio123 backtest rules for the 4th qunitile

Then repeat the process for steps 7 and 8.

Step 12: Backtest the fifth quintile

To backtest the fifth quintile you need to go back to the screen RULES tab and change the second to last rule.  It should be changed to the following:

FRank(“PEInclXorTTM”,#Previous,#DESC) > 80

Portfolio123 backtest rules for the 5th qunitile

Then repeat the process for steps 7 and 8.

Step 13: Backtest the filtered stock universe

This step could be considered optional, but I still recommend you do it especially if the list of stocks you get after your stock filters is vastly different than the benchmark you are using. To backtest the stock universe you need to go back to the screen RULES tab and deactivate the second to last rule.  You do this by clicking on the green circle and turning it to a red circle.

Portfolio123 rules for testing the backtest universe

Then repeat the process for steps 7 and 8.

Step 14: Review your backtest results

Hurray! You completed your first comprehensive backtest of a stock fundamental on Portfolio123. Pat yourself on your back. Now it is time to organize your results and examine your findings. I recommend that you put your results in a table similar to the one from my recent backtest article, Mebane Faber Shareholder Yield Backtest.  I created columns for each quintile backtest and I made rows for each of the key statistics I was interested in following. Your table could look similar to the one below:

Backtest results for Shareholder Yield
16-year backtest of the Meb Faber Shareholder Yield

I would focus your attention on the average excess return, Sortino ratio and standard deviation for each of the quintiles as compared to the benchmark and/or the universe. Ideally, you want to see a nice linear trend of average excess returns from the lowest to highest quintile for the stock fundamental you are testing.

If you use this tutorial to test other stock fundamentals on Portfolio123, please share your results with me.  I’ll be sure to share the best ones here on Fat Pitch Financials. If you need any help or have any questions, be sure to leave a comment in the comments section below and I’ll try my best to help you out.

One thought on “How to Backtest Stock Fundamentals Using Portfolio123

  • September 7, 2016 at 6:24 pm
    Permalink

    I have a question. How does one account for delisted or failing companies in this or any backtest?
    Thanks.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.