With the S&P 500 and the Nasdaq Composite up 15% and 31%, respectively, in 2023, investors might find it challenging to identify good buying opportunities in the market today. But the good news is there are still compelling stocks to add to your portfolio. 

Even some of the largest companies remain well off their all-time highs. E-commerce and cloud-computing heavyweight Amazon (AMZN -0.24%), for instance, is down about 30% from its peak price of $186.12, which was set in July 2021. 

Despite its recent challenges, here's why Amazon is one top stock to buy right now. 

Dealing with macro issues 

Amazon thrived during the worst days of the pandemic, when people were spending more time than ever at home and had no choice but to turn to digital services to handle all aspects of their daily needs. 

Because roughly 50% of all spending online in the U.S. happens on Amazon's platform, it was well positioned to benefit from the growth in e-commerce. And the business invested aggressively to build out its logistics network to handle rising demand. 

However, as many internet companies found out, the pandemic-fueled demand wasn't going to last forever. Now they were faced with a new reality. Add in rising interest rates and elevated inflation, and things changed drastically. 

In Amazon's case, its revenue gains decelerated dramatically during 2022, as consumer spending slowed down. For the full year of 2022, company revenue climbed just 9.4% year over year. And the coveted cloud-computing unit, known as Amazon Web Services (AWS), also saw its growth rates slow and operating margin shrink. 

Like many other companies, Amazon's management team instituted cost-cutting efforts to ensure that expenses better matched the macroeconomic backdrop. Most notable was the layoffs of 27,000 employees. 

Still a worthy investment candidate 

Investors shouldn't ignore the recent problems Amazon has been dealing with because they are important to know and understand. But if you're truly a long-term investor, then what's been happening with a company over just a few quarters shouldn't really matter in the grand scheme of things. With this framework in mind, it's best to zoom out and focus on Amazon's attractive investment characteristics. 

For starters, Amazon's online marketplace benefits from a powerful competitive advantage known as network effects. Because of its enormous scale and wide reach, merchants want to sell their products on the most popular online site. Add in over 200 million global Prime members, and Amazon undoubtedly becomes essential for these merchants. 

Additionally, the vast selection of merchandise, coupled with free and fast shipping, makes buying things on Amazon a no-brainer decision for many consumers. As the marketplace grows with more merchants and shoppers, it becomes increasingly valuable for all parties. It's almost impossible for small rivals to compete. 

Then we can look at AWS. While it has seen revenue growth slow and margins contract, this is still the top cloud infrastructure and platform services provider in the world. As the market continues its sizable growth in the next decade and beyond, particularly as companies transition their IT needs from on-premises to off-premises, Amazon will benefit. 

Integrating artificial intelligence (AI) into AWS's offerings will also help to drive greater adoption and spending because customers will realize so much value. For example, Amazon Bedrock, which is a tool for developers to build their own machine-learning models, positions the tech behemoth to be a major player in the emerging AI wars, particularly against the likes of Alphabet and Microsoft. 

A more under-the-radar division of Amazon is digital advertising. While Google and Meta Platforms have dominated this segment for a long time, Amazon is rapidly becoming a force to reckon with. Its digital ad sales of $9.5 billion in Q1 2023 were up 23% year over year. It now holds fourth place in the market on a worldwide basis. This can prove to be a huge growth driver in the years ahead. 

There are lots of reasons to like Amazon stock right now. Investors would be smart to add shares to their portfolios while they are still well below their peak.