NEW YORK (AP) -- U.S. stocks climbed Wednesday, driven by gains for big technology companies and Amazon. The S&P 500 and Nasdaq finished at record highs for the fourth day in a row.
Stocks have rallied over the last four days as investors grew more hopeful about trade talks between the U.S., Mexico and Canada. Canadian Prime Minister Justin Trudeau said Wednesday that Canada could join a trade pact between the U.S. and Mexico by Friday.
The Commerce Department said the U.S. economy was a bit stronger than it previously thought. It said gross domestic product grew 4.2 percent in the second quarter. Stronger business investment was a big reason, as companies spent more money on items like software.
"Corporate spending is up, which is something that is very important for the overall economy," said Quincy Krosby, chief market strategist at Prudential Financial.
Technology companies including Apple, Microsoft and Alphabet made strong gains.
The S&P 500 advanced 16.52 points, or 0.6 percent, to 2,914.04. The Dow Jones Industrial Average rose 60.55 points, or 0.2 percent, to 26,124.57. The Nasdaq composite jumped 79.65 points, or 1 percent, to 8,109.69.
The Russell 2000 index of smaller-company stocks added 6.33 points, or 0.4 percent, to 1,734.75. It also closed at a record high.
Technology firms and other large companies started climbing Friday as reported suggested a breakthrough on trade was near. On Monday the White House said it had reached a preliminary deal with Mexico to replace the North American Free Trade Agreement. Mexico is the U.S.' third-largest trading partner and Canada is second, behind China.
The S&P 500 has risen 3.5 percent in August after a 3.6 percent gain in July. That two-month gain is its best since late 2015.
Amazon jumped 3.4 percent to $1,998.10 after a Morgan Stanley analyst raised his price target on its stock to $2,500 from $1,850. At that price, Amazon would have a market value of $1.2 trillion.
"We have increasing confidence that Amazon's rapidly growing, increasingly large, high margin revenue streams (advertising, Amazon Web Services, subscriptions) will drive higher profitability," Brian Nowak wrote.
Apple became the first publicly traded company to reach the $1 trillion mark early this month. Investors currently value the iPhone maker at almost $1.08 trillion to Amazon's $975 billion.
Other retailers struggled. Dick's Sporting Goods dipped 2.2 percent to $35.60 after its sales fell short of expectations. The company said sales of Under Armour products dropped significantly because of that company's decision to expand distribution of its apparel to other stores.
Chico's FAS fell 4.1 percent to $8.47 after its quarterly report and watchmaker Movado sank 15.4 percent to $41.80. Elsewhere, Tiffany sank 4.3 percent to $125.48 and Kohl's lost 1.9 percent to $77.34.
Footwear seller Shoe Carnival surged 13.1 percent to $41.74 after it raised its annual forecasts following a second quarter. the company said back-to-school sales are off to a good start.
Energy companies rose along with oil prices. Benchmark U.S. crude rose 1.4 percent to $69.51 a barrel in New York while Brent crude, used to price international oils, gained 1.6 percent to $77.14 a barrel in London.
Homebuilders fell after the National Association of Realtors said fewer Americans signed contracts to buy homes in July compared with the previous month. High home prices and rising mortgage rates are pushing home sales down even though economic growth is solid.
TopBuild declined 2.7 percent to $65.10 and TRI Pointe lost 2.4 percent to 14.42.
The companies also dipped Tuesday after the S&P-Case Shiller index showed that home prices rose 6.3 percent in July, a slower pace than the month before.
Yum China climbed 5.5 percent to $39.23 after the Wall Street Journal reported that a group of investors offered to buy it for $46 per share, or $17.6 billion. The Journal said the offer was made in recent months and that Yum China rejected it.
Roku slumped 4.9 percent to $59.92 following a report that Amazon may challenge it with an ad-supported video service. The Information said Amazon will offer the service through its Fire TV devices, which are owned by about 48 million people.
In other commodities trading, wholesale gasoline rose 1.3 percent to $2.11 a gallon. Heating oil added 1.4 percent to $2.24 a gallon. Natural gas gained 1.5 percent to $2.90 per 1,000 cubic feet.
Gold fell 0.2 percent to $1,211.50 an ounce. Silver lost 0.5 percent to $14.70 an ounce. Copper sank 1 percent to $2.71 a pound.
Bond prices were little changed. The yield on the 10-year Treasury note stayed at 2.88 percent.
The dollar rose to 111.69 yen from 111.21 yen. The euro dipped to $1.1699 from $1.1696.
Germany's DAX picked up 0.3 percent and the CAC 40 of France rose 0.3 percent. The British FTSE slid 0.7 percent.
Tokyo's Nikkei 225 rose 0.1 percent while the Hang Seng in Hong Kong added 0.2 percent and Seoul's Kospi advanced 0.3 percent.