The S&P 500 and Nasdaq closed at all-time highs on Thursday on renewed optimism that the US and China are close to reaching a deal in their costly trade war.

Financial, technology and healthcare stocks powered much of the rally, which gave the S&P 500 its second straight gain and erased its losses from earlier in the week.

Bond yields surged and real estate companies, utilities stocks and household goods makers fell as investors shifted money away from safe-play investments.

The market has been quick to react to headlines and remarks out of the Trump administration about the 16-month trade war, and Thursday was no different.

Shares jumped in the early going after President Donald Trump said that the US is getting close to a “big deal” with China.

Traders were also encouraged by a Wall Street Journal report saying Washington has offered to slash existing tariffs and cancel new ones set to kick in on Sunday in exchange for more agricultural purchases and intellectual property protection.

“If we do see the tariffs removed, that’s saying, ‘OK, China must be agreeing to things or we must be right there,’” said Ben Phillips, chief investment officer at EventShares. “That’s why the market is looking at tariffs as the bellwether to a trade deal.”

The S&P 500 climbed 26.94 points, or 0.9%, to 3,168.57. The index is up about 0.5% from its last all-time closing high on November 27.

The Dow Jones Industrial Average rose 220.75, or 0.8%, to 28,132.05. The Nasdaq gained 63.27 points, or 0.7%, to 8,717.32. The index, which is heavily weighted with technology stocks, is now up about 0.1% on its record set on November 27.

The Russell 2000 index of smaller company stocks climbed 12.89 points, or 0.8%, to 1,644.81.

China’s Ministry of Commerce said on Thursday that its negotiators were in “close communication” with their American counterparts ahead of the new round of tariffs but gave no indication whether the trade talks were making progress.

The planned weekend US tariff expansion would extend punitive duties to almost everything the US buys from China. Beijing has threatened to retaliate if the new tariffs go into effect.

Uncertainty over trade has been the biggest wildcard for stocks this year. The long-standing conflict has hurt manufacturing around the world and caused US businesses to hold back on making investments. The saving grace for the economy has been a strong job market and consumer spending.

Speculation that the world’s two biggest economies could be close to reaching an interim “Phase 1” trade agreement spurred investors on Thursday to move money into technology, industrial and other stock sectors that tend to do well when the economy is growing.

“If we get a China trade deal, it’s probably going to catalyse another 12-plus months of growth in the US and globally,” Mr Phillips said.

Banks helped lead the gains as bond prices fell, sending yields higher. Bank of America rose 3.1%. Higher yields allow banks to charge more lucrative interest rates on mortgages and other loans.

The yield on the 10-year Treasury jumped to 1.90% from 1.79% late on Wednesday. That is an unusually large increase and signals more confidence in economic growth.

Technology companies also made strong gains. The sector is one of the most sensitive to swings in trade because many of the companies rely on China for sales and supply chains. Cisco Systems climbed 3.1%.