With the S&P 500 Index in negative territory on a year-to-date basis and the markets concerned about a cyclical slowdown in 2019, many investors are starting to think about going defensive with their portfolios. With this in mind, let's look at one industry traditionally seen as doing well in an economic slowdown: auto parts retailers like O'Reilly Automotive (ORLY 0.03%), AutoZone (AZO 0.93%), and Advance Auto Parts (AAP -1.88%). Not least because they have been crushing it in 2018.

Why auto parts retailers do well in recessions

Looking back into the last two recessions, you can clearly see that auto parts retailers tend to grow revenue and earnings in these conditions. This isn't because they are less affected by a downturn, as you might argue dentistry or healthcare are, but because recessionary conditions can actually be better for the sector.

The reason? In hard times, consumers tend to delay buying a new car in favor of continuing to run older cars, which require more servicing -- good news for auto parts retailers.

AAP Revenue (TTM) Chart

AAP revenue data by YCharts. TTM = trailing 12 months.

What happened in 2018?

In a nutshell, all three companies have reported pretty solid same-store sales growth in the last couple of quarters. This has reassured the market that the slowdown in 2016-2017 wasn't due to the existentialist threat from Amazon.com (AMZN -1.64%) entering the sector.

Advance Auto Parts, O'Reilly Automotive, and AutoZone comparable same store sales growth.

Data source: Company presentations. 

At the start of the year the sector had upside prospects in 2018. For a start, the last two years saw mild winters, and 2017 had a cooler spring and summer. Given that cars get more stressed in extreme weather, this tended to curtail demand in the previous years -- making it easier for the companies to beat previous years' sales.

Moreover, according to Advance Auto Parts CEO Tom Greco on the company's third-quarter earnings call, end-market conditions are set to improve: "...after three consecutive years of declines, the number of vehicles greater than seven years old is expected to grow in 2019 for the first time since 2015. This group of vehicles is one of the largest demand-drivers in our industry, and we're confident this will enable continued industry momentum."

Long-term issues

While the near-term outlook continues to look bright, there are longer-term questions. The Amazon threat is real. And even though the auto parts retailers will always have a business edge -- many do-it-yourselfers require in-store service and staff support, and do-it-for-me customers often need a part immediately -- it's hard to argue that price discounting from online competition won't hold back margin.

Moreover, in the very long term, growth in electric vehicles and/or hybrid cars could challenge the industry's business model, since auto parts retailers have traditionally sold parts for combustion-engine vehicles. Electric vehicles could require fewer repair costs and recurring purchases, and as traditional car-battery replacement is a significant revenue and footfall generator for auto parts retailers, the challenge from electric vehicles is significant.

An up arrow breaking through.

Image source: Getty Images.

But are they still a midterm buy?

The near-term outlook is good for auto parts retailers, and if you have significant worries about an oncoming recession, then they are a good place to be looking to buy stock. However, for the long-term investor, the threat from online competition and electric vehicles might be concerning enough to avoid the sector.

Auto parts retailers won't be killed by Amazon and electric vehicles, and the companies will still do relatively better than most in an economic slowdown. But it's not clear what their growth and margin prospects will look like over the long term.