After a shaky start, U.S. stocks are rising Wednesday as technology companies continue to climb. Consumer-focused companies are up as Amazon jumps.

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.

KEEPING SCORE: The S&P 500 index climbed 17 points, or 0.6 percent, to 2,914 at closing time. The Dow Jones Industrial Average rose 61 points, or 0.2 percent, to 26,125. The Nasdaq composite jumped 80 points, or 1 percent, to 8,110.

Larger stocks rallied earlier this week after 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.

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.

Smaller companies tend to do better than larger ones when investors are worried about trade tensions, and vice versa. The Russell 2000 index of smaller-company stocks rose, but not as much, as it added 7 points, or 0.5 percent, to 1,736.

TIP-TOP TECH: Technology companies continued to lead the market higher. Google’s parent company Alphabet gained 1.6 percent to $1,265.47 and Microsoft picked up 1.4 percent to $111.76. The S&P 500 technology index has jumped 33 percent over the last year while the S&P 500 has risen a still-strong 19 percent.

THE QUOTE: Quincy Krosby, chief market strategist at Prudential Financial, said investors were pleased to see more signs of progress on trade, and were also reacting to the Commerce Department’s updated report on economic growth.

“Corporate spending is up, which is something that is very important for the overall economy,” she said.

WHAT’S BETTER THAN ONE TRILLIONAIRE? TWO: Amazon jumped 3.1 percent to $1,992.31 after a Morgan Stanley analyst raised his price target on its stock to $2,500. At the new 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 $1.07 trillion to Amazon’s $971 billion.

ROKU ROCKED: Roku slumped 5.1 percent to $59.80 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.

ENERGY: 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.

CRYING FOUL: 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.

Retailers struggled in general. Chico’s FAS fell 3.3 percent to $8.54 after its quarterly report. Elsewhere, Tiffany sank 4 percent to $125.81 and Nordstrom lost 0.8 percent to $61.49.

Footwear seller Shoe Carnival soared 14.9 percent to $42.41 after it raised its annual forecasts following a second quarter. the company said back-to-school sales are off to a good start.

HOME SLOWDOWN: Homebuilders fell after the National Association of Realtors said fewer Americans signed contracts to buy homes in July compared to the previous month. High home prices and rising mortgage rates are pushing home sales down even though economic growth is solid.

TopBuild declined 3 percent to $64.93 and TRI Pointe lost 2 percent to 14.48.

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.

CHINESE TAKEOUT: Yum China climbed 5.4 percent to $39.17 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.

OTHER COMMODITIES: 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.

BONDS: Bond prices were little changed. The yield on the 10-year Treasury note stayed at 2.88 percent.

CURRENCY: The dollar rose to 111.69 yen from 111.21 yen. The euro dipped to $1.1699 from $1.1696.

OVERSEAS: 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.

© The Associated Press. All rights reserved.