The economic outlook is bleak: The United States appears to be teetering on the brink of the steepest downturn since the Great Depression. Goldman Sachs economists, for example, expect the gross domestic product to contract at an astounding 34 percent annual rate in the second quarter, with unemployment reaching roughly 15 percent.

That makes the market’s recent bounce all the more remarkable.

A month ago, stocks were in a free fall. Investors were panicking over everything they didn’t know about the outbreak: how long it would last, how the government and the Fed would react, and how far-reaching the damage would be.

Since then, the Fed has said it was ready to buy an unlimited amount of Treasury and other government-backed bonds, Congress and President Trump have enacted a $2 trillion relief package (with more almost certain to come), and officials in China have lifted travel restrictions in Wuhan, the city where the pandemic began late last year.

Even in New York State — the epicenter of the outbreak in the United States, where a single-day high of 779 deaths were recorded on Tuesday — officials have said the increase in hospitalizations has begun to slow.

“The difference between now and the start of the pandemic is that we can at least see the end,” Brad McMillan, chief investment officer for Commonwealth Financial Network, a privately held investment firm with more than $160 billion under management, wrote in a market commentary on Wednesday. “We can see that we have flattened the curve, and we can reasonably project when the pandemic will be brought under control. We are not at that point yet, but at least we can see it.”

Energy companies have been a key driver of the rally, with the S&P 500 energy sector up more than 17 percent in April. Exxon Mobil and Chevron are up more than 15 percent, with investors hopeful that Saudi Arabia and Russia can settle the price war that has driven American oil prices down almost 60 percent this year.

Paradoxically, some of the most skeptical investors — short-sellers, who make their money betting that shares will fall — have contributed to the rally.