Although the S&P 500 is up slightly to start 2023, it is still well off its peak from over a year ago. And many of the highest-quality stocks are in the same boat, trying to claw back the gains they experienced over the past couple of years. 

One such enterprise is home-improvement giant Home Depot (HD -1.70%). This massive retailer saw a surge in fiscal 2020 and fiscal 2021, growing annual revenue in the double digits, but it is now facing a dramatic slowdown that investors should be thinking about. 

With Home Depot shares down almost 30% from their all-time high set in December 2021, is now the right time to buy the stock? Let's take a closer look. 

The good times are over 

After posting 19.9% and 14.4% revenue gains in fiscal 2020 and fiscal 2021, respectively, Home Depot was only able to grow sales by 4.1% in fiscal 2022. Things actually decelerated quickly in the most recent quarter (the fourth quarter of 2022, ended Jan. 29), when revenue was up by just 0.3% year over year to total $35.8 billion.

This was the first time since November 2019 that Home Depot missed Wall Street expectations for the top line. Moreover, same-store sales were down 0.3% in the quarter, with diluted earnings per share (EPS) increasing 2.8%. 

While rapidly rising mortgage rates in the U.S. have led to the housing market cooling off, shareholders shrugged off any concerns this would have a serious negative effect on Home Depot. The thinking was that if people are less inclined to buy a new home, they might instead want to focus on fixing up their existing one. But with an uncertain economy, things aren't so rosy anymore. 

Management believes that revenue and same-store sales growth will be flat in fiscal 2023. The leadership team blames softer customer demand and a shift in spending away from goods and toward services and travel that were largely delayed in prior years by the pandemic. 

Adding pressure to margins in the coming fiscal year is Home Depot's announcement that it will invest $1 billion into raising employees' wages and benefits, and boosting their training. Consequently, the operating margin is expected to be 14.5% for fiscal 2023, down from 15.3% in the latest fiscal year. Diluted EPS is forecast to decline by mid-single digits. 

On a bright note, Home Depot raised its quarterly dividend by 10%, which continues a long history of increasing payouts to shareholders. For investors who prioritize dividends, that's certainly welcome news. 

What about the valuation? 

Home Depot's stock is down about 6% in 2023 as of this writing, and it now trades at a price-to-earnings (P/E) ratio of under 18. Not only is this a slight discount to the valuation of the overall S&P 500, but it is also cheaper than Home Depot's trailing-five-year average P/E of more than 22. It's definitely hard to ignore this discount, despite the challenges the business is facing. 

The stock looks even more attractive when compared to Home Depot's smaller rival, Lowe's (NYSE: LOW), whose current P/E is close to 20. This is an unusual occurrence, as Lowe's shares have typically traded at a bit of a discount to Home Depot's. To be fair, Lowe's diluted EPS has skyrocketed in recent years, which could justify the higher valuation. 

But if we zoom out, we'll see that Home Depot is the superior company. It generates more of its sales from high-value professional customers, who spend and visit more. Home Depot has generally posted better margins.

And in the latest quarter, the business' return on invested capital (ROIC) was a superb 44.6%; for Lowe's, the latest quarterly figure was 27.6%. And Home Depot's top line has increased at a higher compound annual rate over the past five years. 

This points to Home Depot being a wonderful company, and its attractive P/E as being unjustified. Therefore, it might be time for investors who can look past the near-term struggles to take a closer look at the stock.