U.S. markets reacted with a jolt Friday after President Trump announced that he and the first lady had tested positive for the coronavirus, but investors’ shock was quickly eclipsed by optimism about more stimulus.

The three major U.S. indexes slumped more than 1.5 percent after Trump tweeted the diagnosis, but then cut their losses after House Speaker Nancy Pelosi (D-Calif.) said she was anticipating a bipartisan economic relief deal, suggesting that Trump’s infection could hasten an agreement.

The Dow Jones industrial average shed 134.09 points, or 0.5 percent, to close at 27,682.81. The S&P 500 index fell 32.38 points, nearly 1 percent, to end at 3,348.42. The tech-heavy Nasdaq sank 2.2 percent, or more than 251 points, to settle at 11,075.02. Big tech names led the declines: Apple fell 3.2 percent, Nvidia fell 4.1 percent and Tesla sank more than 7 percent.

The potential for more stimulus was enough to take investors’ minds off the election.

“The President will undoubtedly have the best care, so financial markets will remain mostly optimistic he will recover well before Election Day,” Ed Moya, an analyst with OANDA, wrote in commentary Friday. “There was enough uncertainty heading into this election with high fears we would have a significant delay in getting results or if it would be contested.”

Vice President Pence has tested negative for the coronavirus, the administration announced Friday. Meanwhile, Joe Biden, who shared a stage with Trump this week for the presidential debate, also tested negative. Their wives also got the all-clear.

Meanwhile, the last monthly jobs report issued before the Nov. 3 election signaled that the economic recovery could be cooling off. The U.S. added just 661,000 jobs in September — the smallest monthly jobs gain since the recovery began in May. This brings the unemployment rate to around 7.9 percent, which is more in line with other recent recessions.

“September payroll gains were on the disappointing side, below expectations and well below the pace seen in previous months,” Mark Hamrick, senior economic analyst at Bankrate.com, wrote in commentary Friday. “We continue to see elevated unemployment rates for Blacks, Hispanics and teenagers, in the double-digits and showing little improvement.”

Trump was diagnosed hours after it was disclosed that Hope Hicks, a top aide, had tested positive Thursday. Dow futures sank more than 500 points shortly after the announcement, and the VIX volatility index soared 9 percent.

“Tonight, @FLOTUS and I tested positive for COVID-19,” the president tweeted just before 1 a.m. “We will begin our quarantine and recovery process immediately. We will get through this TOGETHER!”

Moments later, Trump’s physician Sean P. Conley wrote that the president and first lady Melania Trump “are both well at this time, and they plan to remain at home within the White House during their convalescence.”

The news initially rattled overseas markets. Japan’s Nikkei closed down 0.7 percent but European indexes recovered and nearly broke even. Chinese and South Korean markets are closed for public holidays.

The president has downplayed the seriousness of the disease throughout the pandemic and frequently flouted government safety guidelines. He routinely appears in public without a mask and has held large rallies with hundreds of supporters who did the same, often in violation of local ordinances. At 74, he is part of a population that is more vulnerable to the virus.

Stocks in Britain were hammered earlier this year as Prime Minister Boris Johnson battled covid-19 and spent time in an intensive care unit.

“Initial market reactions to the news that President Trump tested positive for COVID19 are as expected — negative. However, markets could have some unexpected reactions as this could break the log jam in current stimulus negotiations,” Jamie Cox, managing partner for Harris Financial Group, wrote in commentary Friday.

Oil markets were also shaken by the news. Brent crude, the international oil benchmark, slumped more than 3.4 percent to trade at $39.51 a barrel. West Texas Intermediate Crude, the U.S. oil benchmark, sank more than 3.6 percent to trade at $37.38 a barrel.

“It seems reasonable to assume that markets will be on shaky ground throughout October with the perfect storm of a highly contentious election and a pandemic that remains stubbornly at the forefront,” Peter Essele, head of portfolio management for Commonwealth Financial Network, wrote in commentary Friday.