The Nasdaq gained 1 percent to close at 8,109.69. The S&P 500 rose 0.6 percent to 2,914.04, closing above 2,900 for the first time. The S&P 500 tech sector rose 1 percent. The Dow Jones Industrial Average climbed 60.55 points to 26,124.57 as Apple rose 1.5 percent to an all-time high.
Amazon shares rose 3.4 percent to a record after Morgan Stanley raised their price target on the stock, predicting a $1.2 trillion valuation for the company. Analyst Brian Nowak said Amazon's advertising, subscription and cloud businesses "will drive higher profitability and continued upward estimate revisions." Amazon's stock closed at $1,998.10.
Shares of Google-parent Alphabet gained 1.5 percent after Morgan Stanley raised its price target on the stock, making it the highest on Wall Street. The analysts cited Waymo, the company's self-driving auto unit, as the big upside catalyst for the stock. Alphabet shares closed at $1,264.65.
Canadian Foreign Minister Chrystia Freeland rejoined NAFTA talks after the U.S. and Mexico announced they had struck a bilateral trade deal. Freeland told reporters that Mexico's "difficult" concessions to the States earlier this week would help lead the way for productive discussions between the three countries this week.
On Tuesday, U.S. Treasury Secretary Steven Mnuchin told CNBC that he was optimistic on striking a deal with Canada, but added that the White House was ready to go forward with Mexico alone, if it isn't executed. The U.S. is hoping an agreement with Canada will be made before the week ends.
The Canadian dollar rose marginally against its U.S. counterpart, erasing earlier losses. Canadian Prime Minister Justin Trudeau said there is a possibility a trade deal that includes Canada could be reached by Friday. He noted, however, that any NAFTA deal must be "the right deal for Canada."
President Donald Trump said later on Wednesday he was optimistic that Canada will join the U.S.-Mexico trade deal.
The Mexican Peso rose 0.6 percent.
The S&P 500 and Nasdaq eked out record closes on Tuesday as investors continued to cheer on the U.S.-Mexico trade breakthrough.
"This is actually not a surprise for us," said Matt Lloyd, chief investment strategist at Advisors Asset Management. "We knew Mexico was going to make a deal, but there was going to be some pushback. ... With Canada, we think there's going to be a bit less pushback."
As trade tensions ease, Lloyd said he likes U.S. equities, "preferably large-cap" stocks. "The dollar rally will likely start to curb," thus boosting shares of large multinational companies.
The U.S. economy grew at a stronger pace in the second quarter than previously thought. The Commerce Department raised its second-quarter economy growth estimate to 4.2 percent from an initial forecast of 4.1 percent.
"Today's estimate should also serve as another lesson to shelf geopolitical noise and focus on the fundamentals, which are nothing if not strong," said Mike Loewengart, vice president of investment strategy at E-Trade. "Jobs numbers are robust, and this number comes in after earnings season, which reflects broad corporate growth, particularly in retail, which bodes well for our economy. Some say we're late in the business cycle, but clearly there's more gas in the tank at least for now."