close up image of stock market data on a computer

Canada’s main stock index closed higher along with U.S. markets on the final day of trading of what was a difficult year for stocks.

The S&P/TSX composite index closed up by 100.86 points at 14,322.86 on Dec. 31 as part of a late December rally, but it wasn’t enough to stave off significant losses for the year.

The index ended down by 12% for 2018 after declines that started in the summer gained momentum as trade disputes and slowing global growth stoked fears of a recession.

Declines accelerated in December, pushing the index down to as low as 13,776.90 on Christmas Eve, before staging a modest rally in the final days of the year.

The drop, especially in the final month of the year, caught most market-watchers off-guard.

“We all felt as though the market was a little ahead of itself, or maybe in some instances a lot ahead of itself,’’ said Allan Small, senior investment advisor at HollisWealth Inc.

He said the economy has slowed somewhat, but is still healthy and he expects more of a minor stock correction than a major economic crisis.

“Lot of people are talking about recession, but I don’t think a recession’s anywhere in the short-term. What I think you have is a bear market without the recession.’’

Investors, however, will have to get used to the recent volatility as a major trade dispute between the U.S. and China hits a deadline in the new year, while Democrats take hold of the House of Representatives.

“I think it just stirs the pot a little more,’’ said Small.

Investors did get some positive sentiment on the trade front after U.S. President Donald Trump tweeted that he had a positive discussion with Chinese President Xi Jinping, said Small.

“President Trump tweeted out over the weekend that he spoke with the Chinese president, everything seems positive, he seemed optimistic in his tweet that they’re working toward some sort of trade deal.’’

The news helped send the Dow Jones industrial average up by 265.06 points at 23,327.46. The S&P 500 index ended up by 21.11 points higher at 2,506.85, while the Nasdaq composite was up by 50.76 points at 6,635.28.

U.S. stocks still ended down for the year for their worst showing in a decade. The S&P 500 ended down 6.2%, the Dow down 5.6%.

The Canadian dollar averaged US73.30¢, down by 0.02 of a U.S. cent from Friday.

The February crude contract closed up by US8¢ at US$45.41 a barrel and the February natural gas contract was down by US36¢ at US$2.94 per mmBTU.

The February gold contract was down by $1.70 at US$1,281.30 an ounce and the March copper contract was down five cents at US$2.63 a pound.