By Joe Wallace and Gunjan Banerji

U.S. stocks advanced Wednesday, while mainland Chinese shares extended a winning streak for a seventh consecutive day.

The S&P 500 advanced 0.8% as of the 4 p.m. close of trading in New York. The Nasdaq Composite added 1.4%. The Dow Jones Industrial Average was up 0.7%.

U.S. stocks have traded in a narrow range for the past month, after zipping higher for much of the second quarter. Investors have been weighing stimulus efforts by central banks and governments against signs that the rebound in U.S. economic growth has lost speed. Meanwhile, there's been a jump in coronavirus cases in parts of the country, and tensions have risen between China and the West.

"I would characterize the stock market as relatively immune to the [health] crisis," said Gregory Perdon, co-chief investment officer at Arbuthnot Latham & Co., a U.K. private bank. It is difficult for stock prices to go down when stimulus measures by the Federal Reserve and European Central Bank have pinned down bond yields, he added.

The S&P 500 snapped a five-session streak of wins Tuesday as the U.S. reported 60,000 new coronavirus cases, a single-day record, according to data compiled by Johns Hopkins University.

There are signs investors are also turning cautious in other parts of the market. Gold prices have risen to the highest level since September 2011 and are continuing to advance.

"There's definitely never been more unknown unknowns out there. We'll have to see whether the economy can stay open and people can get back to work," said Nancy Davis, portfolio manager of the Quadratic Interest Rate Volatility and Inflation Hedge Exchange-Traded Fund.

The yield on 10-year Treasury notes rose to 0.664%, from 0.648% on Tuesday. Bond yields and prices move in opposite directions.

Chinese shares resumed their recent spurt, pushing the Shanghai Composite Index up 1.7%. The index has advanced 8% this week as individual investors bet that a recovering economy will boost profits. The streak has revived memories of an earlier rally in Chinese stocks in 2015, which ended in a crash.

International stock markets were mixed. Japan's Nikkei 225 Index was down 0.8%. The Stoxx Europe 600 fell 0.7%.

Write to Joe Wallace at Joe.Wallace@wsj.com and Gunjan Banerji at Gunjan.Banerji@wsj.com