What happened

Shares of auto-parts retailer O'Reilly Automotive (NASDAQ:ORLY) rose 43.1% 2018, according to data from S&P Global Market Intelligence. It was a year of startling outperformance from the auto-parts retailers -- AutoZone (NYSE:AZO) and Advance Auto Parts (NYSE:AAP) also did very well in an otherwise lackluster year for the S&P 500.

ORLY Chart

ORLY data by YCharts.

There are probably three reasons O'Reilly and the others did so well. For starters, they all reported solid same-store-sales growth in 2018, marking somewhat of a recovery from a period of weakness.

Comparable same store sales growth at O'Reilly Automotive, AutoZone and Advance Auto Parts

Data source: company presentations. Chart by author.

Revenue growth at auto-parts retailers is partly dependent on weather -- as extreme weather in winter and summer puts stress on cars -- as well as on miles driven and the age of the automobiles. Vehicles more than seven years old are typically the sweet spot for auto-parts retailers.

Therefore, after a couple of years of mild winters, O'Reilly, AutoZone and Advance Auto Parts found themselves surpassping easier comparable numbers from previous years, aided by a pickup in the economy in 2018 that encouraged a record year for miles driven.

Second, fears over a cyclical slowdown in the economy fed through into a defensive mentality in the market, and investors may have decided to switch away from more cyclically aligned stocks toward auto-parts retailers -- traditionally seen as good recession-resistant stocks to buy.

 A collection of car parts

Image source: Getty Images.

Third, the slowdown in auto sales has encouraged investors to believe that the outlook for O'Reilly is going to get better in the coming years. After a few years of roaring new-car sales, the average age of the U.S. passenger car is now creeping up again.

Indeed, as Advance Auto Parts CEO Tom Greco argues, "the number of vehicles greater than seven years old is expected to grow in 2019 for the first time since 2015" -- a good omen for the sector.

So what

Perhaps the most interesting development is that the sector has somewhat demonstrated that isn't going to be demolished by Amazon.com's (NASDAQ:AMZN) entry to the industry. There's little doubt that Amazon has pressured the industry, but O'Reilly et al. are likely to still have a key edge through their ability to have parts in stock that a customer -- particularly a business customer -- needs immediately.

Of course, when auto-parts retailers' sales were weak in 2016 and 2017, there was no end of speculation that Amazon was behind it. The performance in 2018 helped allay existentialist fears over the sector.

Now what

Investors fearing the worst from the economy in 2019 are likely to still favor buying stock in the sector, but given the strong rise in 2018, O'Reilly and the others need to deliver on their potential. The sector was left for dead at the start of 2018, but now that positive expectations have been baked into valuations, investors need to keep a very close eye on all three companies to see whether they meet expectations in 2019.

Check out the latest O'Reilly Automotive, AutoZone, Advance Auto Parts, and Amazon earnings call transcripts.