The U.S. and China have reached a consensus on trade, representatives from both sides said. The S&P 500 advanced 0.55% and the Nasdaq Composite climbed 0.63%, the third day of gains for both indexes.