TORONTO -- A strong rally in the price of oil helped Canada's main stock index stay out of the red Tuesday, as Wall Street indices hit another all-time high.

The S&P/TSX composite index was up 1.59 points to 16,319.24, with rising energy stocks offsetting losses in the materials sector.

The February crude contract surged US$1.23 to US$62.96 per barrel.

"There's been better price action within a lot of commodities, particularly within the energy complex," said Sid Mokhtari, executive director at CIBC Capital Markets.

"It may appear to be overbought but the sentiment behind it continues to improve and help the energy sector in Canada and the U.S. And that's something that had been lagging in the past."

South of the border, the U.S. stock market is marking its longest New Year's winning streak in eight years.

In New York, the Dow Jones industrial average advanced 102.80 points to 25,385.80. The S&P 500 index added 3.58 points to 2,751.29 and the Nasdaq composite index was up 6.19 points to 7,163.58.

On the Canadian corporate front, shares of Royal Bank of Canada (TSX:RY) were up 53 cents, or 0.51 per cent, to $104.84 Tuesday amid comments by RBC CEO Dave McKay that Canadian banks are expecting some short-term pain from U.S. President Donald Trump's tax overhaul but a significant lift on future earnings. McKay said RBC expects a writedown of US$150 million, plus or minus 10 or 15 per cent, in the bank's first quarter but is expecting an annual tax-positive benefit of US$150 million to US$200 million going forward.

Meanwhile, Restaurant Brands International Inc.'s stock (TSX:QSR) was down 38 cents, or 0.49 per cent, to $77.95 as a social media movement encouraged people to join "No Timmies Tuesday" and instead visit independent coffee shops. Many people are denouncing the coffee-and-doughnut chain and participating in a boycott until some Ontario franchisees and their corporate parent, RBI, come up with a different solution to offset the province's minimum wage hike than clawing back employee benefits.

In currency markets, the Canadian dollar closed at an average trading value of 80.30 cents US, down 0.20 of a U.S. cent.

Elsewhere in commodities, the February natural gas contract was up nine cents to US$2.92 per mmBTU. The February gold contract fell US$6.70 to US$1,313.70 an ounce and the March copper contract was down a cent at US$3.22 a pound.