Stocks closed mostly lower on Wall Street after a day of waffling between small gains and losses and more in Wednesday’s Stock Market Update.

The market stumbled in the late morning Wednesday following a report that the U.S. and China wouldn’t sign their initial trade deal until next month, but the losses were mostly gone within two hours.

Losses for energy and communications stocks offset gains in health care.

The U.S.-China trade war has been a top concern for investors since early 2018, and momentum has recently been tilting toward at least a partial agreement. That, combined with encouraging reports on the economy and corporate profits, have recently propelled U.S. indexes past their prior peaks from July to all-time highs.

While acknowledging that trade talks could easily falter again, Jeff Mills, chief investment officer at Bryn Mawr Trust, said both sides have an incentive to come to a deal. China’s economic growth has slowed under the weight of increased U.S. tariffs. President Donald Trump’s chances of re-election, meanwhile, likely hinge in large part on the economy, and a worsening trade war would only sour it.

Mills is optimistic the economy will show more life after the Federal Reserve cut interest rates three times this year, if trade tensions continue to ratchet lower. It would be a sharp turnaround from just a few months ago, when worries were spiking that Trump’s trade war and four interest-rate increases by the Federal Reserve in 2018 could tip the economy into a recession.

“People know this intellectually but tend not to focus on it: Changes in interest rates impact the economy with a significant lag,” Mills said. “What we’ve been seeing the last year or so is the economy absorbing the rise in interest rates that we experienced in 2018.”

Early next year, the economy should start to get a boost from the Fed’s three rate cuts since the summer, “and I would expect the market to see the recession narrative as overblown,” he said.

Until then, though, markets are still trading on every whiff of news about trade. Wednesday’s moves following the report of a possible “phase one” delay demonstrated that.

“Trade is a key issue but it’s difficult to gain an edge because no deal has been signed,” said Tom Hainlin, national investment strategist at U.S. Bank Wealth Management. “It’s proving to be challenging for investors.”

STOCK MARKET UPDATE

KEEPING SCORE: The S&P 500 edged up 2 points, or 0.1%, to 3,076, two points below the record high it set on Monday. The Dow Jones Industrial Average was down a fraction at 27,492. The Nasdaq fell 24 points, or 0.3%, to 8,410.

HEALTHY RETURNS: Health care stocks climbed to the strongest gains, up 0.6% for the biggest gain among the 11 sectors that make up the S&P 500.

CVS Health (CVS) helped lead the way with a 5.3% gain after it reported a stronger profit for the latest quarter than analysts expected and raised its forecast for the year. Humana (HUM) jumped 3.4% after it also turned in a better-than-expected earnings report.

Stocks across the S&P 500 have been reporting better earnings for the latest quarter than Wall Street expected. In most cases, that meant smaller losses than analysts had forecast.

With only 20% of its companies still waiting to report, the S&P 500 index is on track to report a drop of 2.6% in earnings from a year earlier, according to FactSet. That’s not as bad as the 4% decline that analysts initially estimated.

PAIN AT THE PUMP: Energy stocks sank to the market’s worst losses, down 2.1% after the price of benchmark U.S. crude slumped 1.5%.

Exxon Mobil lost 2.1%, and oilfield services provider Schlumberger (SLB) fell 3.1%. Occidental Petroleum (OXY) tumbled 5.5%.

TECH TANGO: HP (HPQ) surged 6.3% for one of the biggest gains in the S&P 500 after The Wall Street Journal reported Xerox Holdings is targeting it for a buyout. Xerox has been struggling as consumers increasingly use digital documents instead of paper.

YIELDS: Treasury yields dipped, putting at least a temporary halt to the strong gains they’ve made this month. The yield on the 10-year Treasury fell to 1.82% from 1.86% late Tuesday.

DEFENSE WINS: The drop in Treasurys yields made the big dividends paid by utility and real-estate stocks more attractive. These stocks are often called “defensive” investments on Wall Street because they tend to hold up better than the rest of the market when the economy is stumbling. They’ve also been at the head of the market for months.

Some investors see leadership shifting toward areas that do best when the economy is strengthening, such as banks and energy companies, as recession worries fade. But defense was back on top Wednesday. Utilities rose 0.3%, real estate gained 0.5% and companies that sell everyday staples to consumers climbed 0.5%.

OVERSEAS MARKETS: Global markets mostly drifted higher. France’s CAC 40 rose 0.3%, Germany’s DAX returned 0.2% and the FTSE 100 in London added 0.1%. The Japanese Nikkei 225 rose 0.2%, the South Korean Kospi gained 0.1% and the Hang Seng in Hong Kong was virtually flat.

© The Associated Press. All rights reserved.