Looking at the headline of this article, readers might think I'm going to offer up a discussion on popular auto stocks like Ford, Rivian, or Tesla. But they'd be mistaken. There's another auto stock that has my attention, and it's one that has been a winning investment for quite some time.  

That stock is O'Reilly Automotive (ORLY -0.97%), one of the leading aftermarket parts retailers in the country. The stock price is up about 48% just in 2021, and the company now sports a market capitalization of $45.2 billion. 

Regardless of the 2021 runup, I think O'Reilly still has a long runway of solid performance ahead of it. Here's why it's my favorite auto stock heading into the new year. 

person shopping for motor oil in auto supply store

Image source: Getty Images.

Performing in any type of economy 

What makes this business worthy of your investment dollars is that it can flourish in good and bad economic times. During recessionary periods, like in 2008 and 2009, O'Reilly generated the best revenue growth in recent memory. Sales jumped 41.8% in 2008 and 35.5% in 2009 as people held off on buying new cars and instead chose to undertake repairs and maintenance for vehicles they already owned. 

Even during the healthy economic growth in the U.S. over the past several years (excluding 2020), O'Reilly was able to steadily increase revenue at mid- to high-single-digit percentages on an annual basis. When unemployment is low and consumer confidence is high, people tend to drive more, supporting demand for O'Reilly's products and services. 

Therefore, what makes O'Reilly so attractive from an investment perspective is that potential shareholders don't need to make any predictions about the state of the economy next year. This company should do well no matter what interest rates or unemployment figures are in 2022. 

Handling inflationary pressures 

Perhaps no topic has garnered more attention from investors over the past several months than inflation. As a direct result of supply chain bottlenecks and labor shortages, the retail sector has been impacted the most, causing consumers to pay higher prices for goods.  

O'Reilly's superb gross margin of 52.3% in the most recent quarter means that the company has substantial pricing power. While inflationary pressures were highlighted on the earnings call, Johnson mentioned that the company could pass increased input costs on to consumers with demand staying resilient. If someone's car is having problems, price is not the main concern -- getting back on the road as quickly as possible is. 

Additionally, the shortage of new and used vehicles (and consequent record prices) are leading customers to focus their dollars on extending the lives of their existing vehicles, a boon for O'Reilly. My guess on when inflation will ease is as good as the next person's. But this company is well-positioned for the wacky economic situation we're experiencing today. 

Broad industry tailwind improves outlook 

The key data point investors should look to for guidance as to the potential outlook for the automotive aftermarket parts industry is the number of miles driven. As Americans drive more and increase the wear and tear on their vehicles, O'Reilly benefits. 

Unsurprisingly, the pandemic put immense downward pressure on this metric as people spent a lot more time at home than ever before. Miles driven in 2021 returned to pre-pandemic levels. In 2022, expect this trend to continue in a meaningful way. "We expect the gradual improvement in miles-driven trends to continue and provide a benefit to the aftermarket as the recovery moves forward," CEO Greg Johnson said on the Q3 earnings call. 

The management team is so optimistic that they raised O'Reilly's full-year outlook. For 2021, the business is forecast to grow same-store sales by 10% to 12%, a jump from prior guidance for a 5% to 7% increase. Revenue and earnings per share are expected to be $13.1 billion (at the mid-point) and $29.35 (at the mid-point), respectively, for 2021. Both would be up significantly year-over-year. 

A solid foundation for your portfolio 

Owning O'Reilly Automotive can bring safety and security to your overall portfolio. The biggest reason why I view it as my favorite auto stock for 2022 is because it really doesn't matter what the economy is doing or whether or not inflation persists. This business has proven its ability to continue performing exceptionally well regardless of the circumstances. 

Over the past 10 years, the stock has produced a negative annual return only one time, in 2017. While predicting what the stock market will do in 12 months' time is a losing proposition, you can't argue with O'Reilly's track record. This is a low-risk and steadily growing business, and it's a top auto stock to own heading into the new year.