* TSX down 26.08 points, or 0.17 percent, at 15,642.99
* Seven of the TSX's 10 main groups fall (Adds details, analyst quotes, updates to close)
TORONTO/OTTAWA, April 5 (Reuters) - Canada's main stock index edged lower on Wednesday, retreating from a nearly six-week high as financial shares declined and the energy sector gave up an earlier advance, although overall losses were tempered by gains in consumer-related stocks.
Banks were among the biggest drags on the index, including Toronto-Dominion Bank TD.TO , which fell 0.6 percent to C$66.85, while Canadian Imperial Bank of Commerce CM.TO lost 0.9 percent to C$114.82.
The late-day decline for the TSX was also driven by the heavyweight energy sector as oil prices LCOc1 came off one-month highs after a surprise rise in U.S. crude inventories. O/R
Although U.S. crude oil futures CLc1 settled up 12 cents at $51.15 a barrel, the commodity was down 16 cents at $50.87 in extended trading. Shares of Encana Corp ECA.TO were down 2.1 percent at C$15.65, while the TSX energy group .SPTTEN was nearly flat.
The Canadian market pulled back after hitting a record high in February but the index has climbed in recent weeks and is now just under 2 percent away from the record close.
The TSX has room to run heading into corporate earnings season and could rise to around 16,500 by the end of the year, said Bryden Teich, portfolio manager at Avenue Investment Management.
"What happened a year and a half ago as commodities collapsed, the overall earnings level on the TSX was really, really hit," said Teich.
"You now have a recovering and strengthening Canadian economy, and then you also have corporate earnings recovering and poised to have a really strong year."
The Toronto Stock Exchange's S&P/TSX composite index .GSPTSE ended down 26.08 points, or 0.17 percent, at 15,642.99. Earlier in the day, the index touched a session high of 15,758.39, its highest intraday since Feb. 23.
Just three of the index's 10 main groups ended higher, including a 0.1 percent gain for consumer discretionary stocks .GSPTTCD , helped by Hudson's Bay Co HBC.TO .
The department store retailer said it was aggressively working on fundamental changes in the business the day after it reported a quarterly loss and its shares rose 7.7 percent to C$10.45. in the sector, Dollarama DOL.TO advanced 1.7 percent to C$113.87.
China's Shandong Gold Mining Co Ltd 600547.SS is in advanced talks to buy a 50 percent stake in Barrick Gold Corp's ABX.TO Veladero gold mine in Argentina, in a deal that could fetch more than $1 billion, people familiar with the process told Reuters. shares were down 0.3 percent at C$26.01.