CANADA STOCKS-TSX closes higher, gains crimped by swing lower in oil price

(Adds quotes from portfolio managers, details, updates prices)

* TSX rises 15.12 points, or 0.12 percent, to 12,937.59

* Five of the TSX’s 10 main groups gain

TORONTO, Dec 9 (Reuters) - Canada’s main stock index rose on Wednesday, a day after its weakest close in more than two years, although a swing lower in crude oil prices dampened gains for the resource-linked market.

“The market appears to be following oil,” said Irwin Michael, portfolio manager at ABC Funds.

Oil prices fell for a fourth day in a row on Wednesday after the market ignored an unexpected drawdown in U.S. crude stockpiles to focus on a build in distillates.

U.S. crude prices settled at $37.16 a barrel, down 0.93 percent, while Brent crude added 0.1 percent to $40.29.

The energy group firmed 0.5 percent, helped by gains for pipeline companies, but closed well below session highs.

Enbridge Inc rose 3.0 percent to C$43.13, while TransCanada Corp was up 6.8 percent at C$43.80. Some investors view the dividends of these Canadian infrastructure stocks as well protected from commodity price weakness and the overall industry slowdown.

Railway stocks also advanced, including a 1.9 percent rise in Canadian Pacific Railway Ltd to C$174.96.

The Toronto Stock Exchange’s S&P/TSX composite index closed up 15.12 points, or 0.12 percent, at 12,937.59, with five of the index’s 10 main groups in positive territory.

“It’s a time of the year where managers are changing their portfolios, the end of tax loss selling,” said Michael Simpson, senior portfolio manager at Sentry Investments Inc, as they position themselves for the new year.

Tax loss selling often takes place at year end as investors try to reduce their capital gains tax liability.

Barrick Gold Corp rose 2.5 percent to C$10.49, although paring earlier gains as spot gold swung lower on the day.

Financials firmed 0.2 percent, with Toronto-Dominion Bank rising 1.2 percent to C$53.78.

The group had weighed heavily on Tuesday after all the major banks last week reported more bad loans in the energy sector than a year ago. Investors worry this could turn into more writedowns for the lenders.

Consumer stocks weakened, including a 7.3 percent drop in Dollarama Inc to C$81.70 despite reporting a 37 percent rise in quarterly profit. The stock had closed on Tuesday about 48 percent higher for the year.

Information technology consulting company CGI Group Inc fell 2.6 percent to C$55.89. (Additional reporting by Alastair Sharp; Editing by James Dalgleish)