Can Computers Time The Market?

by: Harry Sauers
Summary

I developed a market simulator based on Dr. Robert Shiller’s data from his work at Yale and Irrational Exuberance.

Software, old and new, allows us to analyze and play out hypothetical scenarios with greater efficiency.

A quantitative model supporting occasional effectiveness of market timing was found.

According to it, the S&P 500 remains a “Buy” currently.

Intro

A source of much controversy and disagreement among investors, especially retail, is the ability to call the tops or bottoms of a bubble or “wait for the correction.” Despite extensive literature on the topic, many managers still attempt to wait out current highs before entering new positions and in turn give up potential upside.

With my background in software, I decided to design, develop, and test out various quantitative models, and leveraged AI to determine the optimal values for each model or “strategy.” Though some excellent quant platforms like Quantopian exist, I opted to develop this simulator from the bottom up. This allowed me to leverage more custom datasets from Dr. Robert Shiller, Quandl.com, and Multpl.com. The factors used in developing a comprehensive, functional quantitative model were overwhelmingly selected from Dr. Shiller’s work at Yale and some one-off thought experiments in inequality and conception. Such factors include:

  • Instantaneous P/E ratio

  • Shiller (or cyclically-adjusted) P/E ratio

  • Dividend yield

  • Yield on ten-year Treasury bills

  • Changes in P/E

  • Changes in yield

  • Birth rates

  • Conception rates

  • Changes in birth and conception rates

  • Moving averages over various periods of time

  • Income inequality (the Gini coefficient)

Shiller P/E Ratio Over Time

Correlations

To develop a better understanding of exactly how various quantitative factors influence stock market returns over one-year, five-year, fifteen-year, and twenty-five year periods, I ran correlations on these data and the future returns of the S&P 500 Index. Some metrics were found to have a strong correlation with future returns over various periods of time, but were found to be essentially worthless when used to guide a buy or sell decision. For instance, the change in conception rate was correlated positively with 20-year trailing returns with a coefficient of 0.48, but due to unknown factors (potentially factors such as declining birth rates, recent dependence on immigration for population growth) no values were found to produce or enhance returns better than a buy-and-hold strategy.

The converse was also found to be true: instantaneous P/E ratios have a relatively low correlation to returns that can still be used successfully: the P/E ratio has a slightly inverse correlation to one-year returns, but as we examine the tail ends of the distribution it becomes an excellent predictor of over- or under-valuation, and can be used to generate buy or sell signals in a quantitative model.

Other correlations found include:

P/E and 1-Year

-0.0437

Current Price and Conception

-0.6636

P/E and 5-year

-0.0388

P/E and 15-year

-0.3223

1-Year Returns and Conception

-0.0025

P/E and 25-year

-0.2003

5-Year Returns and Conception

-0.0967

15-Year Returns and Conception

-0.3745

Shiller P/E and 1-Year Returns

-0.1731

20-Year Returns and Conception

-0.5636

Shiller P/E and 5-year Returns

-0.3486

Shiller P/E and 15-year Returns

-0.4094

1-Year Return and Conception Growth

0.1534

Shiller P/E and 25-year Returns

-0.2796

5-Year Return and Conception Growth

0.0275

15-Year Return and Conception Growth

0.3776

Div. Yield and 1-Year Returns

0.2052

25-Year Return and Conception Growth

0.4846

Div. Yield and 5-Year Returns

0.3492

Div. Yield and 15-Year Returns

0.7240

10YR Bond Yield and 1-Year Return

0.1069

Div. Yield and 25-Year Returns

0.6490

Gini Coeff., 1yr Return

0.1268

Change in Div. Yield and 1-Year Returns

0.1141

Gini Coeff. Trailing 20yr, 1yr Return

-0.1985

‘’ and 5-Year Returns

0.1527

‘’ and 15-Year Returns

0.4411

‘’ and 25-Year Returns

0.7624

Simulation Design and Backtesting

Following my development of a quantitative backtesting code library (including the S&P 500 Index, Treasury ten-year bonds, and cash as possible assets), I designed, tested, and optimized various quantitative strategies to achieve the greatest risk-adjusted total return, before accounting for tax liabilities. While backtesting is imperfect, the consistency over time indicates that quantitative analysis may have something to offer on top of standard due diligence for investors, particularly those using tax-sheltered accounts such as an IRA.

The following “rules” were found to produce the greatest returns and risk-adjusted returns (as measured by alpha) for one-year periods from 1900 to 2016. Due to limited data, testing was more extensive for one-year periods from 1962 to 2016. They are ranked in descending order of “priority,” meaning that a signal from a higher number is ignored if a contrary signal from a lower number exists. For lack of a better name, I'll refer to this as the "fundamental-oriented strategy."

  • 1: Shiller P/E > 34.75; Sell

  • 2: Current P/E / P/E of one year ago today > 1.29; Sell

  • 3: 10yr yield / trailing average yield of past decade > 1.2; Sell

  • 4: Current P/E / P/E of one year ago today < 0.75 && PE < 29.5; Buy

  • 5: Current P/E > 29; Sell

  • 6: Current P/E < 28; Buy

Possibly because our data was limited to the first of each month (meaning we can only place twelve trades each year), no consistent model was found to enter and exit a short position that would outperform a bond allocation during the same period. This supports one of the most prominent ideas in investing: never short America.

1962-2016: Equal-weighting strategy labeled as “Rational Growth”

Strategies and Analysis

We found this strategy to perform optimally on both an absolute and a risk-adjusted basis. From the time period of 1962 to 2016, a lump sum investment (with dividends reinvested) was found to produce annualized returns of 10.28% with a standard deviation of 16.51% and a Sharpe ratio of 0.25. These figures will be used as the benchmark.

Our fundamental-oriented strategy, discussed above, produced annualized returns of 12.40% over the same period, with a standard deviation of just 9.57%, a Sharpe of 0.66, and a beta of 0.4116. This leaves us with an annualized alpha of 4.6%, which is quite excellent given the time period of 1962 to 2016.

Another strategy that was initially experimented with, out of curiosity, was using the 6-month and 2-month moving averages to generate buy and sell signals based upon price momentum. Though this clocks in a higher beta than our initial strategy, it is also relatively uncorrelated with a fundamental-oriented strategy and has the following metrics over the period measured:

  • Annualized return: 13.15%

  • Standard deviation: 10.34%

  • Beta: 0.4729

  • Alpha: 5.08%

  • Sharpe ratio: 0.68

We decided to synthesize these two quantitative models and weight them equally, rebalancing each year since they held a relatively low correlation with each other. The success of a combination of strategies may be attributed to the fact that fundamental analysis (the first “strategy”) plays upon underlying value, while technical analysis (the second “strategy”) ignores fundamentals in favor of exploiting price action. An equal-weighted portfolio of the two would have been more successful than either over the period measured, with the following metrics:

  • Annualized return: 12.85%

  • Standard deviation: 9.04%

  • Beta: 0.4476

  • Alpha: 4.89%

  • Sharpe ratio: 0.75

Another portfolio strategy would be to weight the previous strategy at 60% and hold a 40% bond allocation (as ten-year Treasury bonds). Though this reduced upside, it significantly decreased the standard deviation of returns thanks to diversification of asset classes. From 1962 to 2016, this portfolio would have produced these metrics:

  • Annualized return: 10.28%

  • Standard deviation: 5.68%

  • Beta: 0.2587

  • Alpha: 3.11%

  • Sharpe ratio: 0.74

Again, backtesting does not guarantee future performance, but the models here remain significant due to the very real cause and effect relationship of valuation on future performance (as well as other macro factors). One interesting finding was that though conception rates may predict recessions, the market’s fundamental and technical signals appear to price it in before the general population (via conception) is able to. I am not a firm believer in the efficient market hypothesis - in fact, as a value investor, I seek to profit from inefficient markets - but this finding is certainly telling.

`

Conclusions

This experiment is not a perfect scientific study, nor do I believe it should be used blindly to guide investments into an index. However, it is an exploratory model for individuals and institutions to construct a wealth management strategy, and allow us to better understand our limits in market timing.

If you found this article interesting, please give me a follow. If you have questions about my methodology, data, or code, leave a comment or shoot me a PM - I look forward to your responses.

Disclosure: I/we have no positions in any stocks mentioned, and no plans to initiate any positions within the next 72 hours. I wrote this article myself, and it expresses my own opinions. I am not receiving compensation for it (other than from Seeking Alpha). I have no business relationship with any company whose stock is mentioned in this article.