The S&P 500 closed up more than 4 percent on Wednesday, recovering its losses from the day before.

For investors, who have come to see President Trump as a boon to stock markets ever since his administration slashed corporate taxes, Mr. Biden’s policies would offer less of a swing away from pro-business policies than those of Mr. Sanders.

Compared with Mr. Sanders, Mr. Biden’s “proposed tax rises are relatively modest, he supports light touch regulation and he would pursue a much softer line on tariffs,” Michael Pearce, an economist at Capital Economics wrote to clients. “The prospect of a Biden-Trump showdown would be a clear positive for the markets, and probably a small plus for the economy too.”

Shares were also bolstered by the news that U.S. lawmakers reached a deal on Wednesday for an $8.3 billion emergency aid package to combat the spread of coronavirus. It includes nearly $7.8 billion for agencies dealing with the virus and about $500 million for telehealth services. Also on Wednesday, the International Monetary Fund said it would provide $50 billion in emergency funding, including no interest loans, to help poorer countries respond to the epidemic.

Financial markets have been on a roller coaster as investors grapple with the potential economic damage caused by fractured supply chains, travel bans and the disruption of daily life.

There is little clarity about how long it will take governments and health officials to contain the virus, leading to a gloomy prognosis for global economic growth.