The past 10 years have been extraordinarily good for stocks, but depending on the makeup of your portfolio, your experience may be better or worse than the market average. Tech investors have enjoyed a wonderful ride, while those heavy in energy stocks have seen their wealth ebb and flow with multiple booms and busts in the energy business.

The following graphic provides a quick visual of stock market returns, sector by sector, and year by year, over the 10-year period spanning from 2008 to 2017. Here are five things that stick out to me when looking back over the past 10 years.

Grid of annual returns by S&P 500 sector from 2008 to 2017.

Image source: author. Data from Morningstar, using sector SPDR ETFs as a proxy for returns.

1. "Bomb shelter" stocks have been surprisingly good performers

Even if the economy turns for the worse, people will still buy soap, toothpaste, and packaged foods. They might even buy more of these products, preferring grocery store deals to expensive restaurant meals. As stocks plummeted in 2008, consumer-staples stocks held up better than most, since most enjoy nearly persistent demand for their products.

But there's another reason, too: Consumer-staples stocks categorically dominate lists of dividend growth stocks. So when interest rates plummeted in 2008, people who wanted to earn a respectable yield on their capital turned to reliable dividend payers, many of them in the consumer-staples industry. 

I suppose consumer staples' performance through bull and bear markets isn't as surprising as the comparatively good performance of consumer discretionary stocks. In theory, consumer discretionary stocks should lag the market when the economy falls off a cliff. After all, discretionary purchases (travel, home goods, or streaming video, for example) tend to be the first things that get axed when people lose their jobs or generally feel less confident about their financial futures.

However, consumer discretionary stocks performed second best in 2008 and have delivered positive returns in the nine years since then. The consumer-discretionary category is a bit of an oddball, though, powered by stakes in companies that include long-term winners such as, Walt Disney, McDonald's, Netflix, and Priceline Group. You might consider some of those companies more tech than consumer discretionary, as I do. It's important never to judge any sector by its cover, as what lies beneath may be very different from what you might expect.

An alarm clock against a green background, sitting on a wooden surface.

Image source: Getty Images.

2. Financials: Worse than they appeared

Financials got off to a poor start over the 10-year period starting in 2008, but financial stocks started to plummet in 2007, a year that doesn't appear on our grid. The sequence of returns (-19% in 2007 and -55% in 2008) was devastating to anyone invested in the sector, as some of the largest financial institutions failed, and those that managed to hold on mostly did so by diluting their investors with stock issuance to stay solvent.

Since then, though, financial stocks have rewarded their owners with impressive returns. Excluding 2011, the year of the European debt crisis (remember that?), and 2015, when banks were plagued by oil loans gone bad, financial stocks have been a good place to be. Short-term interest rates have increased markedly, bank profits have rebounded, and the sector benefits from the fact that steady-as-she-goes Berkshire Hathaway currently makes up more than 10% of the sector by market value.

Financial stocks' recent performance is only buoyed by the fact that almost everyone agrees that the industry will be the biggest beneficiary of the corporate tax cut, given they generate the bulk of their earnings in the United States and pay full freight in taxes to Uncle Sam.

3. Energy has been volatile (just as it always is)

I'll be upfront here: I tend to think energy is an industry that's better for people who see themselves as traders rather than investors. The sector's booms and busts make for a wild ride that rarely compensates investors with good long-run returns.

Over a 42-year period ended in 2007, according to the book Valuation: Measuring and Managing the Value of Companies by McKinsey & Company, energy companies ranked poorly for return on invested capital, a proxy for profitability. That's a remarkable finding, given that the study ended at what should have been a very favorable period for the industry, as oil prices were rising to new records with regularity.

Over the past 10 years, it's notable to me that energy stocks had the most years with negative returns (four in all). And the worst years came during 2014 and 2015, when oil companies were plagued with the simple reality that they were simply bringing too much oil and gas to the ground with new fracking technologies.

Energy can be a great industry to invest in -- assuming you time troughs and peaks with precision. Over the course of virtually any 10-year period, you'll find at least one boom and bust in energy. It's a tough business for creating long-term wealth, since the industry as a whole gets aggressive when oil prices soar and cuts deep when energy prices decline. 

4. Tough to beat tech's performance

Tech stocks have been runaway winners in the past 10 years, logging gains in every year excluding 2008. The sector's performance profile puts tech up there with relatively sleepy consumer stocks for generating consistent gains for their investors.

Tech's outperformance is driven primarily by just a handful of large companies that have been reliable winners for their investors. Apple, Microsoft, Alphabet, and Facebook have simply crushed the market, thanks to their cash cow business models that turn a large portion of revenue into cold, hard cash to fund dividends, share repurchases, and acquisitions. 

Since the largest companies by market value make up the largest portion of sector-based indexes, gains of the largest companies have a greater impact than gains in the smallest do. It's really amazing, since smaller stocks are generally expected to outperform larger stocks over the long run, but over the past 10 years, tech is one industry where winners have simply kept winning. (Shares of Apple, the largest company on American exchanges, are worth nearly two times more today than they were in May 2016.)

5. Some years (like 2017) are unforgettably good

Last year was an outlier in terms of performance. All but one sector gained in value, and the S&P 500 returned roughly 22% for the year, driven by investors' expectations of higher economic growth and increased earnings expectations thanks to corporate tax cuts.

Making money isn't always this easy, as stocks have rarely risen for nine years in a row. It's just as rare that stocks rise for 14 out of 15 consecutive years, as they have done in the 15 years leading up to 2018. After leaving many investors scarred from losses in 2008, the markets said "sorry" with more than nine years of consecutive gains.

No one knows what the future will hold, of course. Bull markets have a way of going on for a long time, just as they also have a way of coming to abrupt halts, as we saw in 2008, but there's always an opportunity to be found somewhere. Even in the carnage of 2008, there were 25 S&P 500 stocks that ended the year higher than where they started out, which is almost unbelievable, given that the predominant index declined 37% that year.

Perhaps the most important thing to glean from this look back over the past decade is how important it is to be diversified. Over the past 10 years, never did a single sector lead the market for two years in a row.