Stocks shook off a wobbly start on Wall Street and closed higher Monday, adding to the market's recent run of solid gains.

The S&P 500 climbed 0.4% after wavering between small gains and losses in the early going. Banks, companies that depend on consumer spending and communications companies accounted for a big slice of the gains. Health care was the only sector to fall. Bond yields were mostly higher, another sign of optimism among traders. Oil prices fell.

Investors are balancing cautious optimism about the reopening of businesses shut down because of the coronavirus pandemic against worries that the civil unrest across the U.S. over police brutality and racism could disrupt the economic recovery and widen the outbreak.

The daily protests, which began last week in Minneapolis and have since turned violent in multiple cities, are not weighing on the stock market, at least so far.

“The market has been expecting a springtime for economic activity,” said Mike Zigmont, head of trading and research at Harvest Volatility Management. “If these events derail the animal spirits that the markets have been counting on across the country, then I think they will have an impact. But investors are dismissing it as a short-term, non-event.”

The S&P 500 rose 11.42 points to 3,055.73. The Dow Jones Industrial Average gained 91.91 points, or 0.4%, to 25,475.02. The Nasdaq composite climbed 62.18 points, or 0.7%, to 9,552.05. Smaller company stocks had some of the biggest gains. The Russell 2000 index picked up 11.34 points, or 0.8%, to 1,405.37.

The stock market is coming off its second month of solid gains. Stocks have now recouped most of their losses after the initial economic fallout from the coronavirus knocked the market into a breathtaking 34% skid in February and March. The S&P 500 is now down just under 10% from its all-time high in February.

The Federal Reserve and Congress have pledged unprecedented amounts of aid for the economy. That helped spur the market's move higher from its March lows. Now investors are betting that the worst of the recession has already passed, or will soon, as governments around the country and around the world slowly lift restrictions meant to corral the outbreak.

“I think we are through the worst of it for sure, and the markets reflect that in the bounce we’ve seen,” said David Trainer, CEO of investment research firm New Constructs.

This week will provide market watchers more insight on the impact that the coronavirus is having on U.S. workers and employers. Payroll processor ADP issues its May survey of hiring by private U.S. companies Wednesday. The next day, the government releases its weekly tally of applications for unemployment aid. And on Friday, the government reports its May labor market data. Analysts surveyed by FactSet expect the report will show the economy lost 9 million jobs last month.

The yield on the 10-year Treasury rose to 0.66% from 0.64% late Friday.

Oil prices ended lower. Benchmark U.S. crude oil for July delivery fell 5 cents to settle at $35.44 a barrel Monday. Brent crude oil for August delivery rose 48 cents to $38.32 a barrel.

European indexes closed broadly higher. Asian markets also finished higher, including a gain of more than 3% for Hong Kong’s stock market.

Overseas, Hong Kong’s market rose after President Donald Trump didn’t pull out of a trade truce reached earlier with China. But traders still worried that more trade friction was on the way.

Global stocks mostly rose after President Donald Trump avoided reigniting a trade war with China, though U.S. indexes appeared set to open lower

Hong Kong’s stock market surged more than 3% and European shares traded higher, while Wall Street futures were down slightly.

Investors appeared relieved that Trump avoided pulling out of a truce in a tariff war with Beijing in his response to Beijing’s security law on Hong Kong.

In the U.S., that seemed overshadowed by the civic unrest, where protests against police brutality and racism have become violent in multiple cities. The protests come at a time of surging unemployment and just as the country was looking to ease its lockdown measures. Some fear the demonstrations could lead to a new increase in coronavirus contagions.

In Europe, the FTSE 100 in London added 1% to 6,139 and the CAC 40 in France advanced 1.1% to 4,747 after new surveys showed a recovery in manufacturing activity, though it is still contracting due to the pandemic lockdowns. German markets were closed for a holiday.

Earlier, in Asia, Hong Kong’s Hang Seng index jumped 3.4% to close at 23,732.52. The Shanghai Composite Index rose to 2,915.43 and the Nikkei 225 in Tokyo added 0.8% to 22,062.39.

A monthly gauge of Chinese manufacturing issued by a business magazine, Caixin, edged up to a four-month high, but new export orders fell from an already low level in a sign of weak global demand.

In Seoul, the Kospi in Seoul added 1.7% to 2,065.08. Australia’s S&P-ASX 200 was 1.1% higher at 5,819.20 and India’s Sensex added 3.2% to 33,474.98. Singapore gained 1.9% and Bangkok rose 0.6%.

U.S.-Chinese tension has weighed on investor optimism about the global economy’s recovery from its deepest slump since the 1930s.

As China and some European countries revive economic activity, stock markets have been regaining much of this year’s losses despite rising numbers of virus cases in the United States, Brazil and some other countries.

Before the virus outbreak, the global economy already was under pressure from the U.S.-Chinese dispute over Beijing’s technology ambitions and trade surplus.

The world’s two biggest traders had raised tariffs on billions of dollars of each other’s goods. They signed a truce in January but Trump has added to market jitters by threatening to pull out if China doesn’t buy more American goods.

On Friday, Trump said Washington would begin eliminating agreements that gave Hong Kong privileges that China lacked, including exemption from some import controls.

That followed the ceremonial Chinese legislature’s endorsement of a security law for Hong Kong that pro-democracy advocates say undermines the autonomy promised to the former British colony.

It is unclear how the decision might affect U.S. companies in Hong Kong or the territory’s status as a finance and business center. Business groups say the uncertainty might hurt its appeal to foreign investors.

In energy markets, benchmark U.S. crude lost 8 cents to $35.41 per barrel in electronic trading on the New York Mercantile Exchange. The contract gained $1.78 on Friday to settle at $35.49. Brent crude, used to price international oils, gained 23 cents to $38.07 per barrel in London.

The dollar declined to 107.72 yen from Friday’s 107.81. The euro retreated to $1.1113 from $1.1165.