Source: Recitethis.com.

I heard an amazing statistic earlier this year. According to Bloomberg, the 50 stocks with the lowest Wall Street analyst ratings at the end of 2011 outperformed the S&P 500 by seven percentage points in 2012. 

Think about that. Warren Buffett's goal was once to outperform the market by 10 percentage points a year. Doing the opposite of what Wall Street's smartest minds recommended last year got you two-thirds of the way there. 

As we head toward bonus season, how did finance's top analysts do this year? I dug through FactSet data on companies with the most buy and sell recommendations as of January. 

Drum roll...

Includes dividends, through December 11, 2013.

The S&P 500 is up 27.4% year to date, including dividends. So, companies with the most sell ratings in January outperformed the market by a median 25 percentage points, while those with the most buy ratings underperformed by more than seven percentage points. 

Bravo, gentlemen. 

There are two takeaways here. 

One of the most important lessons in all of finance is to understand the incentives of the guy sitting across the table from you.

It sounds crazy, but a lot of professional stock analysts aren't terribly concerned with the accuracy of their picks. "Until recently, brokerage firms did not even track the accuracy of their analysts' opinions," Stephen McClellan of The Financial Times wrote in 2009. "It is just not an important part of the analyst's job description."

Institutional Investor magazine once surveyed mutual funds, hedge funds, and other big investors -- the folks who pay for Wall Street's research -- asking what attributes are most important to them in an analyst. "Of 12 factors ranked in order of priority, stock selection placed dead last," McClellan wrote. "Industry knowledge was the key quality that institutions wanted in analysts." Individual investors hearing news of an analyst upgrade can be taken down a dangerous path without realizing this. 

But there's almost certainly something else going on here. It's the power of contrarianism. 

In 1999, at the end of the biggest bull market in history when stocks were as overvalued as they'd ever been, Merrill Lynch analysts issued 940 buy recommendations on stocks and sell ratings on just seven. Morgan Stanley had 670 buy ratings and not a single sell recommendation. Compare this with 2010, after the market crashed: Less than 30% of global stock ratings issued by Wall Street brokerage firms were buys. More than 50% were hold ratings, according to Bloomberg. 

In 2005, the investment bank Dresdner Kleinwort wrote a paper on the history of financial forecasts and found something astounding. When a composite of analyst forecasts on things like bond yields and stock prices were overlaid with what actually happened, the forecasts had an almost perfect lag. A few months after bond yields rose, analysts forecast that they would keep rising. A few months after yields fell, analysts switched their forecasts and predicted yields would continue to fall. Viewed in a chart, it was obvious what was going on: When forecasting the future, analysts were just looking at what happened in the past and drawing a straight line. "Analysts are terribly good at telling us what has just happened, but of little use in telling us what is going to happen in the future," the report said.

It's the same with stocks. Most of the companies analysts flooded with sell ratings earlier this year performed terribly last year. 

Markets will always assume tomorrow will look just like yesterday, moving as a herd toward what is often the wrong conclusion. The only way to protect yourself from this group-think is to train your brain to be allergic to popular opinions, taking contrarian views when everyone else is convinced they're right. Most people can't do that (by definition), but it's a trait you'll see in all the world's best investors. If you're uncomfortable making decisions most people around you think are wrong, don't try to beat the market. You'll never do it. 

Check back every Tuesday and Friday for Morgan Housel's columns on finance and economics.