Wall Street closed out a wobbly day of trading Friday with the major stock indexes notching their second straight weekly gain.

The S&P 500 and Nasdaq eked out tiny gains, good enough to nudge each to an all-time high for the fourth time this week. The Dow Jones Industrial Average ended with a slight loss.

Gains in the technology, real estate and utilities sectors outweighed losses in energy and industrial stocks, and in consumer-centric companies.

Trading was mostly subdued and cautious following China’s report Thursday of a surge in cases of a new virus that raised fresh concerns about global economic growth.

“We were flat for most of the day,” said Quincy Krosby, chief market strategist at Prudential Financial. “But you’re also seeing that there is concern. Gold is up, money has come into the bond market and the yields have come down.”

The mixed finish for the indexes likely indicates some traders elected to sell and pocket some profits ahead of the long holiday weekend to get ahead of potential negative headlines about the virus, analysts said. U.S. markets will be closed Monday for the President’s Day holiday.

The S&P 500 index rose 6.22 points, or 0.2%, to 3,380.16. The Nasdaq composite gained 19.21 points, or 0.2%, to 9,731.18. Both indexes had been down most of the afternoon.

The Dow dropped 25.23 points, or 0.1%, to 29,398.08.

Smaller company stocks finished lower. The Russell 2000 index slid 6.15 points, or 0.4%, to 1,687.58.

Stock and bond markets are closed on Monday for the Presidents Day holiday.