The indexes -- and stocks -- haven't been at their best this year. But this sell-off isn't a reason to turn your back on the market. History has shown us these periods don't last forever. That means investors who hold on to their investments win out over time.

It also means investors who buy stocks now often get great bargains on companies that will reward them down the road. There are plenty of great opportunities out there. But today, let's look at a leader in two high-growth businesses. I'm talking about Amazon (AMZN 3.43%), a giant in e-commerce and cloud computing. After a double-digit share decline, is the stock a buy now?

The bad news and the good

Amazon hasn't defied the market downturn or today's tough economic conditions. Let's get through all of the bad news first. Higher inflation and supply chain issues have weighed on the company's e-commerce business. Transport costs for international containers have more than doubled from pre-pandemic times, management said a few months ago. And it found itself with too much fulfillment capacity after ramping up during earlier stages of the pandemic.

As a result, earnings have suffered. In the second quarter, operating cash flow fell 40% to $35.6 billion for the trailing 12 months. Operating income dropped nearly 60% to $3.3 billion. And the company reported a net loss of $2 billion.

This is a big turnaround from the growth we've seen over the past few years.

AMZN Operating Income (Quarterly) Chart

AMZN operating income (quarterly). Data by YCharts.

Now the good news. First, Amazon is making progress on addressing these troubles. In the quarterly report, the company said it has taken steps to manage controllable costs. Earlier this year, it said two-thirds of incremental costs were within its control. This is a considerable share. So if it can continue on this path, that's positive. Management also has improved productivity and use of its fulfillment network.

A booming business

Second, in spite of the crisis, the cloud computing business is booming. Amazon Web Services (AWS) grew operating income and revenue by double digits in the quarter. AWS also keeps winning big contracts. For example, Delta Airlines chose it to transform its digital business. And BT Group, the U.K.'s biggest telecom company, signed on AWS to revamp legacy infrastructure.

What's key here is that AWS traditionally has made up most of Amazon's operating income, so it's a clear profit driver for the company. This is one of the high-growth businesses I referred to earlier. The market for cloud computing services grew more than 41% last year to more than $90 billion, according to Gartner, and AWS leads this enormous market.

E-commerce is suffering in the current economic context, but there are a few positive points. As mentioned above, Amazon is working to control as many issues as possible. Also, the current market environment is temporary, so brighter days lie ahead.

And the outlook for e-commerce remains strong. The global e-commerce market, at a compound annual growth rate of more than 14%, is forecast to reach about $27 trillion in 2027, according to Grand View Research.

Today, shares are trading at less than 3 times sales. The last time the price-to-sales ratio dipped that low was back in 2018. At the same time, revenue has continued to rise. So there isn't a slowdown in demand for Amazon's products.

What does this mean for investors?

Earnings probably won't improve overnight, and there could be more difficult quarters ahead.

But Amazon's leadership in two key businesses should prevail over time. As mentioned above, AWS continues with strong growth. And the company's market position and management of the current situation make me confident about e-commerce growth down the road. All of this means investors who buy shares today could reap big rewards over the long term.