Home Depot's (HD 0.94%) share prices have been under pressure lately. The home improvement retailer's stock is down 7.6% so far in 2023, and trading down a disappointing 30% from its all-time high set near the start of 2022. Rapidly rising interest rates last year, coupled with the general macroeconomic uncertainty, have taken a toll.

No investor likes to see losses in their portfolio, but in times like this, it's important to keep the right mentality. That means staying focused on the long term. Despite shares being down, is Home Depot a magnificent stock to buy? Let's take a closer look. 

Recent growth trends 

There's no denying Home Depot saw a sales slowdown recently. In the most recent quarter (the fourth quarter of fiscal 2022, ended Jan. 29), revenue increased a mere 0.3% year over year, with comparable sales declining 0.3%. Net income of $3.4 billion was essentially flat, compared to Q4 2021, but thanks to stock buybacks, diluted earnings per share (EPS) rose 2.8%. For the full fiscal year, sales were up 4.1%. This was a respectable showing, but it pales in comparison to the double-digit percentage gains Home Depot registered in the prior two fiscal years.  

It's not going to get much better in the near term. For fiscal 2023, management expects sales growth to be flat. And thanks to a $1 billion investment to better compensate hourly store employees, Home Depot's operating margin is likely to shrink from 15.3% in fiscal 2022 to 14.5% this fiscal year, according to the leadership team.

With the business lapping difficult comparisons, investors shouldn't be too alarmed at this slowdown. It's hard for a company the size of Home Depot to consistently put up double-digit annual revenue increases, so expect it to revert back to mid- to high-single-digit sales growth over the long term. That's what shareholders should like to see.

It's also no surprise that the higher levels of macroeconomic uncertainty are putting a damper on Home Depot's business. The housing market has cooled, mortgage rates are at levels not seen in over a decade, and consumers aren't spending as much on physical goods as they were during the depths of the pandemic. 

"With respect to the goods sector of the economy, as I said over the last seven quarters, we've seen that shift across the consumer economy from goods to services," CFO Richard McPhail said on the Q4 2022 earnings call. "So we would anticipate this would put slight pressure on our market." This points to muted gains as we look toward the rest of the year. 

The bigger picture on Home Depot

While Home Depot's latest financials and fiscal 2023 outlook might be worrying for some investors, it's always important to zoom out and not get too caught up with numbers from one quarter or one year. Over the past five fiscal years, Home Depot was able to increase its revenue and diluted EPS at compound annual rates of 9.3% and 18%, respectively. This is the sign of a true compounder. 

HD Revenue (TTM) Chart

HD Revenue (TTM) data by YCharts

Then we can look at Home Depot's huge size advantages. With fiscal 2022 revenue of $157.4 billion, the company is the clear leader in a massive $900 billion home-improvement market. This scale allows Home Depot to better source inventory to stock its shelves, offer advantageous pricing to customers, and invest in omnichannel capabilities that a mom-and-pop hardware store isn't able to do. What's more, commanding only about 17% of the market gives Home Depot plenty of room to keep growing in the decade ahead. 

With shares down so much from their peak, Home Depot's stock currently trades at a price-to-earnings ratio of 17.3, which is well below the trailing-10-year average of 22.4. Boosting investor returns is a current dividend yield of 2.7%, the highest it's been in the past decade (excluding the early 2020 jump).

Once the economy stabilizes, whenever that may be, Home Depot could be back on its way to growing sales and earnings. This makes it a solid foundation for most investors' portfolios.