The Toronto Stock Exchange barely managed to hold onto gains Tuesday afternoon as investors responded to the release of dismal economic data from south of the border.

The S&P/TSX composite index gained 62.38, or 0.8%, to finish at 8,311.91.

There was particular strength in the materials group, which advanced 3.1% throughout the day despite a drop for gold futures. Gold for February delivery ended down US$9.10, or 1.1%, at US$838.10 an ounce on the Comex division of the New York Mercantile Exchange.

Still, the sub-gold index on the TSX advanced by 3.4%.

Agnico-Eagle Mines Ltd. rallied 3.9% to $56.43 and Goldcorp Inc. gained 3.8% to close at $35.35.

Investors responded positively to news that Barrick Gold Corp. had wrapped up its nine-month search for a new president and CEO, appointing Aaron Regent to the position. Barrick shares rose 4.2% to $41.30.

Potash Corp.’s stock got a boost after it announced it bought back 2.95 million of its shares from a third-party seller. Its shares gained 4.9% to finish at $83.23.

Oil futures continued their descent on Tuesday. Crude for February delivery closed down 93 cents, or 2.3%, at US$38.98 a barrel on the New York Mercantile Exchange.

Energy companies still managed a 1.3% gain.

Canadian Natural Resources Ltd. rose 3.1% to $44.00 and Imperial Oil shares increased 2.7% to $38.50.

Others retreated, including Niko Resources Ltd., down 4.4% to $40.25, and Nexen Inc., down 2.1% to $19.09.

Shares of resource company Franco-Nevada Corp. rose 2.1% to $20.06 on news that it entered into agreements with private investors to acquire a 7.3% royalty interest on the Gold Quarry property in Nevada for US$103.5 million.

The financials group retreated 0.1%, including a 2.9% drop for shares of Toronto-Dominion Bank to $40.01 and a 3.7% decline for shares of CI Financial Income Fund to $12.60.

Gainers included Power Financial Corp., up 2.6% to $21.19 and Royal Bank of Canada, up 1.8% to $34.50.

The S&P/TSX Venture composite index rose 6.3 points, or 0.9%, to end at 698.31.

The Canadian dollar rose a third of a cent to end at US82.33¢.

In New York, stock markets sank on news that GDP declined 0.5% in the third quarter, and sales of new homes in the U.S. fell in November to a 17-year-low.

The Dow Jones industrial average fell 100.28 points, or 1.2%, to 8,419.49.

The Nasdaq composite index dipped 10.81 points, or 0.7%, to 1,521.54

The S&P 500 index slipped 8.47 points, or 1%, to 863.16.