Stocks closed broadly higher on Wall Street Wednesday, clawing back all of its losses from a day earlier and extending its strong gains for the week.

The S&P 500 rose 1.7% as the market bounced back from a sudden drop on Tuesday that snapped the index’s three-day winning streak. Crude oil prices posted their fifth straight gain.

Technology, the only sector that’s holding on to a gain for the year, accounted for much of the market’s upward move. Communication services companies and banks also helped drive the market higher. Major stock indexes in Europe and Asia also finished higher. Bond yields moved broadly lower, a sign of caution in the market.

The S&P 500 gained 48.67 points to 2,971.61. The Dow Jones Industrial Average rose 369.04 points, or 1.5%, to 24,575.90. The Nasdaq composite, which is heavily weighted with technology stocks, climbed 190.67 points, or 2.1%, to 9,375.98. In another bullish signal, small-company stocks led the rest of the market, sending the Russell 2000 index up 39.21 points, or 3%, to 1,346.93.

With the gains so far this week, the S&P 500 has recouped its losses from last week and is on track for its best weekly gain since early April. The index is still down about 12% from its all-time high in February, however.

Fresh hope about a potential vaccine for COVID-19 and optimism that the U.S. economic will recover in the second half of the year as businesses gradually reopen and stay-at-home orders aimed at stemming the spread of the coronavirus are relaxed have spurred stocks higher this week.

“Although this is optimism, this is very cautious optimism,” said J.J. Kinahan, chief strategist with TD Ameritrade. “You’re seeing people also buy bonds today. That’s very surprising seeing the stock market doing well and also seeing people buy bonds.”

Experts also raised doubts over a potential vaccine being developed by Massachusetts-based Moderna Inc. that on Tuesday had driven Wall Street’s biggest rally in more than five weeks. Scientists noted that data from early clinical trials of the vaccine were too limited to yield any conclusive results.

“Doubts cast over the Moderna vaccine trial results knock out one leg from under the market rally,” Jasper Lawler of London Capital Group said in a commentary. “Investors are trying to bake in a scenario where economies reopen and a vaccine is available in time to prevent a second wave. But there are still many unknowns.”

Investors are betting that the economy and corporate profits will begin to recover as the U.S. and countries around the world slowly open up again. However, concerns remain that as more people venture out it could lead to another surge in infections, potentially ushering in another wave of shutdowns.

“What it all comes down to is consumer spending,” said Scott Wren, senior global market strategist at Wells Fargo Investment Institute. “If we’re all still sitting home in September or October, the market is going to go lower.”

The market is getting some insight into how companies are navigating the economic fallout from the coronavirus this week as several retailers report quarterly results. Lowe’s and Target reported quarterly results that topped Wall Street’s forecasts as they benefited from people stocking up on supplies at the stores and online during the coronavirus lockdown. The companies also reported a sharp increase in costs related to the pandemic.

After rising initially, Lowe’s shares closed only 0.1% higher, while Target fell 2.9% as some traders questioned whether the companies’ results will weaken as the economy opens up and people have more shopping options.

Wall Street also hammered Royal Caribbean after the cruise line operator said it booked a $1.4 billion first-quarter loss as it was forced to suspend operations due the pandemic. Its stock briefly climbed after the company said bookings for 2021 are within historical ranges. It closed 3.4% lower.

The latest on oil

Oil prices, which have nearly doubled since late April, continued to climb. Benchmark U.S. crude for July delivery rose $1.53, or 4.8%, to settle at $33.49 a barrel. July Brent crude oil, the international standard, gained $1.10, or 3.2%, to close at $35.75 a barrel.

The price of oil has made a comeback this month as oil producing nations cut back on output and the gradual reopening of economies around the globe have driven up demand. Crude oil started the year at about $60 a barrel, but plummeted earlier this year as demand sank due to widespread travel and business shutdowns related to the coronavirus.

Bonds yields were mostly lower. The yield on the 10-year Treasury note, a benchmark for interest rates on many consumer loans, fell to 0.68% from 0.71% late Tuesday.

Overseas

Global stock markets moved broadly higher. France’s CAC 40 rose 0.9%, while Germany’s DAX climbed 1.3%. Britain’s FTSE 100 rose 1.1%. Markets closed mostly higher in Asia.

Japan’s benchmark Nikkei 225 rose 0.8% to finish at 20,595.15 on expectations that a state of emergency still in effect for Tokyo and seven other cities and prefectures may soon end.

South Korea’s Kospi gained 0.5% to 1,989.64. and Australia’s S&P/ASX 200 rose 0.2% to 5,573.00. But Hong Kong’s Hang Seng inched up less than 0.1% to 24,399.95. The Shanghai Composite fell 0.5% to 2,883.74.

India’s Sensex jumped 1.9% and shares were higher in Taiwan but fell in Singapore and Indonesia.

Japan’s state of emergency, which asked people to stay home but was not a lockdown, was recently lifted in the rest of the nation, with social distancing restrictions.

Yoshimasa Maruyama, chief economist at SMBC Nikko Securities, said the lifting of the emergency could come as soon as later this month. But the hardest hit sectors, such as tourism and restaurants, are unlikely to recover for some time, he said.

“It remains unclear whether there will be another surge in coronavirus cases, but if medical care systems can be maintained, a gradual return to normal economic activity can also be expected,” he said.