You can find a wide array of exchange-traded funds that cover nearly any part of the stock market that interests you. Some funds give you broad-based exposure to the entire market, while others look at narrower slices of the investing universe. One set of ETFs known as the Sector SPDRs offer 11 different funds that focus on specific sectors of the U.S. stock market.

Stocks didn't do too well in 2018, but a few Sector SPDRs still posted gains. Below, we'll look at how Healthcare Select Sector SPDR (NYSEMKT:XLV), Utilities Select Sector SPDR (NYSEMKT:XLU), and Consumer Discretionary Select Sector SPDR (NYSEMKT:XLY) managed to deliver positive returns last year.

XLV Total Return Price Chart

XLV Total Return Price data by YCharts.

Staying healthy with healthcare stocks

The healthcare SPDR led the way in 2018, with a total return of 6%. As investors hunkered down into a defensive posture over the course of the year, companies that provide vital healthcare products and services tended to fare better than some traditionally higher-growth areas of the market. When you look at some of the biggest players in the market, top Dow performers Merck and Pfizer played vital roles in driving the sector higher, with impressive share-price appreciation and healthy dividends.

In addition to pharmaceutical stocks, the healthcare ETF also has a considerable allocation to health insurance companies. These businesses fared well as attempts to change the status quo in the market failed, leaving companies with their largely successful business models. With the likelihood of gridlock in Washington on the rise, health insurers should continue to expect the current environment to persist, and that could drive further gains for the entire sector in 2019.

White mosaic blocks spelling ETF against gold mosaic blocks in background.

Image source: Getty Images.

Utilities gain ground

The utilities ETF also managed to post a gain on the year, rising 4%. Rising interest rates posed a threat to these low-growth stocks early in 2018, as investors feared that regulated companies wouldn't be allowed to raise utility rates to keep their dividend yields competitive with fixed-income securities. Yet later in the year, it became evident that the pace of future interest rate increases would almost certainly slow, and weaker economic growth made the defensive characteristics of utility stocks more attractive.

Most utilities don't have a lot of growth potential, because their business models are designed to generate a fixed level of profit while guaranteeing enough of a return to cover the costs of providing utility services to their customers. That makes utilities less attractive when the overall economy is growing. But in the absence of higher-growth alternatives, high-yielding utilities become more attractive, and that theme might well continue into 2019.

Thriving with e-commerce and the consumer

Finally, somewhat surprising late in the economic cycle was the success of consumer discretionary stocks. The Sector SPDR for consumer discretionary posted a 2% rise in 2018, but there was an unusual aspect to the ETF that was pivotal in generating that result.

Fully 22% of the consumer discretionary ETF's assets were invested in e-commerce giant Amazon.com (NASDAQ:AMZN) at the end of 2018, reflecting the company's huge market capitalization. Amazon had amazing performance during the first part of 2018, and even though its share price fell substantially near the end of the year, it still finished with solid gains. That was pivotal in driving the ETF's overall return, even though the many retailers, restaurant companies, automakers, and other businesses that have smaller weightings in the ETF didn't fare nearly as well. Amazon has plenty of potential for future growth, but the ETF's huge weighting to the e-commerce giant makes it a riskier proposition than many of its more diversified counterparts in other sectors.

Be ready for 2019

It's hard to predict future performance based on past results, and just because these sectors did well in 2018 doesn't mean they'll continue to do well in 2019. The beauty of Sector SPDRs is that they give you the opportunity to use whatever strategies make the most sense to you, and so whether you think these ETFs will duplicate their strong relative performance in 2019 or others will take their place, it's easy to position your portfolio appropriately.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Dan Caplinger has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Amazon. The Motley Fool has a disclosure policy.