Stocks in the United States drifted between gains and losses Friday, staying just below an all time record even as the thaw between Washington and Beijing continued.

The S&P 500 opened slightly higher before falling back later in the afternoon. It remained less than 0.5 percent from the July 26 record of 3026.

A three-week-long rally has lifted the S&P 500 by almost 6 percent from its August lows. The latest leg higher has come as President Trump and officials in China have taken steps to lower the tension between them as a new round of trade talks approach.