Mix rising interest rates, surging inflation, corporate layoffs, and consumers that are increasingly struggling to pay for basic necessities, and you get the ingredients for a potential economic downturn. In fact, in the first two quarters of 2022, the U.S. economy posted negative GDP growth, which is the technical definition of a recession. 

What should investors do to prepare for more turmoil ahead? Look for ways to strengthen and recession-proof your portfolio -- and one stock that can help do that is auto parts retailer O'Reilly Automotive (ORLY 0.08%). Let's see why it should be on every investor's radar right now.

An economic downturn on the horizon 

Even someone like Jamie Dimon, CEO of JPMorgan Chase, who many would consider an expert on the state of the economy, sees a tough road ahead. He believes the U.S. economy will enter a recession within the next "six to nine months." Inflation that remains at 40-year highs is going to force the Federal Reserve to aggressively hike interest rates, which will pump the brakes on the economy. 

Further supporting the argument that a recession is likely in the near term is the fact that the Treasury yield curve is inverted. This means that two-year bonds offer a higher yield than 10-year bonds, as investors view the shorter term as having more risk than the longer term. And this situation usually precedes a recession. 

With this mental framework in mind, investors must find ways to protect their portfolios. 

An all-weather stock 

Predicting the economic cycle is a difficult thing to do, so it's best to look for stocks that perform well not only in robust times but also in a recessionary environment. One stock that fits this description is O'Reilly Automotive, whose shares are up 251% and 784% over the past five- and 10-year periods, respectively. 

O'Reilly operates 5,873 stores in the U.S. (and 27 in Mexico) that sell things like batteries, brakes, filters, and motor oil, among many other items, to both DIY and professional customers. Sales received a boost thanks to the pandemic, and the momentum is still solid. In the most recent quarter (ended June 30), revenue increased 5.9% from the prior-year period. And same-store sales, or comps, jumped 4.3%.  

When the economy is growing and consumers are doing well, O'Reilly's business also shines. This is because people are inclined to drive more when times are good, increasing the wear and tear on their vehicles, a situation that supports demand for the products O'Reilly sells. We saw this dynamic play out for the majority of the past decade, when sales rose at an average annual rate of 8.7% from 2012 through 2021. 

On the other hand, in recessionary times, O'Reilly absolutely flourishes. That's because consumers will delay purchasing new cars and instead invest in extending the useful lives of their existing vehicles, again bolstering demand for exactly the stuff that O'Reilly sells. During the Great Recession, revenue was up 35.5% in 2009 on a year-over-year basis. Investors can be sure that finding demand won't ever be a problem for O'Reilly. 

This business is also incredibly profitable, posting a gross margin of 51.3% and operating margin of 21.8% in the latest quarter. And in 2021, O'Reilly generated $2.5 billion of free cash flow. The company produces so much cash that over the past 10 years, the outstanding share count has been reduced by almost half, meaning that existing shareholders end up owning a bigger share of the business. 

Management expects revenue to rise 6.1% and comps to increase between 3% and 5% this year compared with 2021. While that is a dramatic slowdown from the company's double-digit gains during the prior two years, it is in line with O'Reilly's growth in 2019. What's more, the business plans to open roughly 180 net new stores in 2022. 

Trading at a price-to-earnings ratio of 23 right now, the stock has a reasonable valuation that should entice investors to scoop up shares, especially in the face of a looming recession.