TORONTO -- Canada's main stock index posted a triple-digit gain led by the energy sector Thursday, while U.S. stock markets posted stronger gains.

Markets climbed as investors swung back to optimism on the trade dispute between the U.S. and China, said Kash Pashootan, CEO and chief investment officer at First Avenue Investment Counsel Inc.

"We're seeing the tug of war between the China meltdown and the China collaboration continue," he said.

"Last week was a China meltdown kind of week, and this week everyone feels a little bit better and more optimistic, so the market is trading purely off of its probability that the trade war discussions with China are improving."

He said he suspects that the swings in the negotiations are in part exaggerated as U.S. President Donald Trump prepares for an election next year.

"A lot of what we're seeing is political posturing. To be able to point back at all of the efforts the U.S. put in when it's election time to say, look how much we do for the country."

The respite in rhetoric Thursday helped send the S&P/TSX composite index up 112.84 points, or 0.69 per cent, at 16,384.49.

The energy sector once again led the market on general optimism on global growth. The S&P/TSX energy index rose 2.65 per cent as the October crude contract closed up 93 cents at US$56.71 per barrel and the October natural gas contract ended up 7.4 cents at US$2.30 per mmBTU.

The swing to optimism and away from safe havens like gold pushed the December gold contract down $12.20 at US$1,536.90 an ounce, and the materials index on the TSX down 1.66 per cent.

Pressure on the metals side meant that the TSX saw much smaller gains than U.S. markets, said Pashootan.

"The Canadian market is much more heavily concentrated in commodities, and so as much as you have a commodity like oil doing well, which would lead to the Canadian market moving higher, you also have a commodity like gold, that's well represented in the TSX, selling off."

In New York, the Dow Jones industrial average closed up 326.15 points, or 1.25 per cent, at 26,362.25. The S&P 500 index was up 36.64 points, or 1.27 per cent, at 2,924.58, while the Nasdaq composite was up 116.51 points, or 1.48 per cent, at 7,973.39.

The Canadian dollar averaged 75.21 cents US, up from an average of 75.18 cents US on Wednesday.

The December copper contract was up 1.3 cents at US$2.58 a pound.