To find investment opportunities, investors can simply look at businesses that they are customers of. This is an easy activity to do in the retail sector, where huge companies dominate.

Costco (COST -1.31%) and Home Depot (HD -0.18%) might fall on your investing radar. They are two gargantuan enterprises with market capitalizations exceeding $400 billion. And over the long term, they both have rewarded their shareholders.

Which of these top retail stocks is the better buy right now?

Thriving warehouse club operator

Costco's relentless focus on providing consumers with a great shopping experience, with low prices on high-quality merchandise, has created a truly wonderful enterprise. This is evident when you look at the company's stellar financial performance. Costco's diluted earnings per share have climbed at an annualized pace of 13.5% in the past decade, with only one year showing a decline. That points to the company's resiliency no matter what the macro backdrop looks like.

Customer loyalty is high at Costco. This can partly be attributed to the successful membership model. The business requires shoppers to pay annual fees, which have exhibited pricing power historically, for the right to visit a warehouse. This provides Costco with a predictable, high-margin, and recurring revenue stream that grew 5% year over year in fiscal 2024.

Costco's scale advantage might be the most important factor of its success, underpinning its economic moat. With net sales totaling almost $250 billion in fiscal 2024, this is the world's third-largest retailer. As a result, Costco has unrivaled bargaining power with suppliers, leading to low costs that are always passed to shoppers. This drives more revenue, translating to even more savings.

Costco has been a fantastic investment, to say the least. In the past decade, shares have generated a total return of 746%, boosted by occasional special dividends.

Home improvement leader

With trailing-12-month sales of $155 billion, Home Depot is the clear leader in the massive $1 trillion home improvement sector. It's much larger than Lowe's, its key competitor in the industry. This gives Home Depot tremendous scale to better serve both do-it-yourself and professional customers.

Home Depot has been struggling recently, as it reported a 1.3% same-store sales dip in the latest fiscal quarter (Q3 2024 ended Oct. 27), which isn't encouraging for any retail-based enterprise. Management expects the weakness to continue throughout the full fiscal year.

However, not all hope is lost. For starters, the fact that the median age of a home in the U.S., now around 40 years, has steadily climbed over the years means that there will be greater need to undertake renovations and upgrades. Moreover, the sizable housing inventory shortage discourages moving and encourages spending to fix up current dwellings. This all supports demand for Home Depot's products and services.

Investors will certainly appreciate management's capital allocation policy. In fiscal 2023, the business paid $8.4 billion in dividends and repurchased $8 billion worth of outstanding shares. This is only possible because Home Depot generates huge amounts of free cash flow on a consistent basis.

Home Depot stock has been a big winner. It has produced a 126% total return in the past five years (as of Dec. 5), besting the S&P 500 index.

The deciding factor

It's obvious that Costco is firing on all cylinders, with healthy demand that's resulting in solid earnings growth. On the flip side, Home Depot is having a hard time posting growth, an unfavorable situation that might change with the prospect of lower interest rates going forward.

Investors deciding between these two companies must look at valuation as part of their analysis. Costco has been such a wonderful stock to own. And the market's enthusiasm is hard to ignore. Shares recently traded at a price-to-earnings (P/E) ratio of 60. The valuation has never been more expensive.

Home Depot stock can be bought at a P/E multiple of 29 today. While the business is trying to get on a better footing, the market is presenting investors with what I believe to be a better opportunity than buying expensive Costco shares. It's a tough choice, but of these two stocks, the home improvement giant looks like the way to go.