The percentage of "buy" ratings on SPX stocks just surpassed the 2014 peak
A good place to get analyst data is from Zacks, which shows the number of brokerages that are recommending a "buy," "hold," or "sell" rating for each stock. Looking at current S&P 500 Index (SPX) component stocks, the chart below shows the total percentage of recommendations that are a "buy."
This data puzzled me for a long time, because from 2012 through 2017, fewer and fewer individual stock recommendations were a "buy," even though the S&P 500 Index just kept going higher and higher. But the analysts are finally starting to catch on, as the percentage of "buys" has overtaken the 2014 levels. However, they still have a little bit to go before reaching the high marks of 2011, and the level reached during the tech-boom show just how euphoric times were -- though I’m not sure we’ll see this type of surge ever again.

Percent of Analyst "Buys" on the Rise
Here’s the same chart zoomed in to focus on data since 2007. It’s still befuddling to me how the lines generally move in the same direction until 2012. Then, from 2012 to 2014, especially, the lines are moving in opposite directions -- the percentage of "buy" ratings steadily decreased, while the SPX steadily increased.
Since then, the percentage of "buys" chopped around and hit a low of exactly 50% in early 2017. "Buy" recommendations then shot higher in 2018, and now sit at 56%.

This next chart shows the percentage of stocks with more than 50% "buy" ratings from analysts. As late as early 2018, not even half of the SPX component stocks had more than 50% of analysts recommending a "buy." Right now, however, that’s up to 56%.

Analysts Generous, But Still Far From a Bullish Extreme
The reluctance of analysts to give "buy" recommendations over the last several years while stocks moved higher turned out, in hindsight, to be a good buy signal. That said, the fact that the percentage of "buy" recommendations finally surpassed the level reached in 2014 might give us some caution, as stocks underperformed in 2015 after that signal.
The percentage of "buys," however, is still a decent amount below the post-financial crisis peak reached in 2011. In other words, this indicator is not signaling anywhere close to extreme optimism. Still, it’s noteworthy that analysts are finally starting to be more generous in handing out "buy" recommendations.