Investopedia recently came out with an article on Warren Buffet’s barometer for gauging stock market valuations and how it currently shows an extreme overvaluation of the market. The “Buffet Indicator” is the ratio of market capitalization of all publicly-traded U.S. stocks to U.S. GDP. The article states that when the ratio is between 70%-80% it safe to put in stocks, 100% means danger and 140% means extreme danger. We are currently at a record high of 138%.

I thought it would be interesting to gauge the performance of this indicator using the historical data provided by QuantConnect and see how well it predicted previously overvalued markets. In the algorithm below I would stay invested in the SPY until the ratio reached the danger mark or 100%, and exit until the markets were not overvalued.