TORONTO - Canada's main stock index closed lower Wednesday even though higher crude oil prices lifted the key energy sector.

The S&P/TSX composite index was down 59.06 points at 16,312.22 after hitting an intraday high of 16,393.92.

Nine of the 11 major sectors were down, led by real estate, industrials and consumer staples. Energy rose 1.6 per cent, followed by health care.

“We should be benefiting a bit more because the energy stuff but we're getting bogged down by some other things,” said Michael Greenberg, portfolio manager, Franklin Templeton Multi-Asset Solutions.

In particular, he said defensive sectors like real estate and utilities were hit because they tend to trade inversely to bond yields, which were up on the day.

Higher crude prices helped the energy sector, led by Crescent Point Energy and Encana Corp., which were up 5.4 and 4.6 per cent respectively.

The August crude contract was up US$1.55 at US$59.38 per barrel and the August natural gas contract was down 1.8 cents at US$2.27 per mmBTU.

West-Texas Intermediate prices climbed after the U.S. government data indicated that crude inventories fell more than expected as they dropped by 12.8 million barrels last week.

Higher oil prices helped the Canadian dollar which traded for an average of 76.16 cents US compared with an average of 75.91 cents US on Tuesday.

The materials sector was also lower on the day as gold prices fell after hitting a six-year high as Kinross Gold Corp. and Goldcorp. led the declines.

The August gold contract was down US$3.30 at US$1,415.40 an ounce and the September copper contract was down 1.95 cents at US$2.72 a pound.

The technology sector fell as Blackberry shares lost more than nine per cent after reporting its latest quarterly results. However, the strong performance of chip stocks helped to lift the Nasdaq composite. It was up 25.25 points at 7,909.97.

The Dow Jones industrial average was down 11.40 points at 26,536.82. The S&P 500 index was down 3.60 points at 2,913,78, while the Nasdaq composite was up 25.25 points at 7,909.97.

U.S. markets initially gained after Treasury Secretary Steven Mnuchin was quoted saying that the U.S. and China were close to a deal that could be wrapped up by the end of the year. But they fell after U.S. President Donald Trump reiterated that he's prepared to slap on more tariffs if a deal can't be reached.

Greenberg said it's hard to forecast what will transpire as Trump and Chinese President Xi Jingping prepare to meet at the G20 summit in Japan.

He said there's still some really big hurdles to get over to reach “a really meaningful deal.”

“Now that doesn't mean we can't get a little bit more positive news out of the G20 where both sides agree to continue discussions and there's a hold on increasing tariffs now,” he said in an interview.

But he added that the situation could go downhill fast because the two sides are quite far apart on a number of important items, including U.S. demands that China change its economic strategy.

“I think at some point we do get a deal that allows Trump to kind of go back and claim a victory but I think that is still a couple of months away, whether it's before or after the election it's hard to say.”