Toronto stocks ended higher on Wednesday despite an earnings warning from CIBC.

The S&P/TSX composite closed up 31.75 points, or 0.24% to close at 13,389.82.

The benchmark index took a huge hit late-morning after CIBC announced it would likely face further write-downs of up to US$2 billion as a result of the S&P rating of counterparty ACA Financial Guaranty Corp.

Before the bank’s announcement, the index had been up 113.83 points.

Six of the 10 TSX main groups ended higher, but the heavyweight financials group closed down 0.18%.

CIBC share’s closed out at $71.14, losing $1.15, or 1.59% for the day.

Royal Bank shares, however, moved up 6¢, or 0.12%, to close at $50.77 after the bank’s ABCP trusts received Moody’s Investors Service’s highest rating.

The gold sub index dropped 1.40%, led by Yamana Gold Inc., which dropped 2.37% to close at $11.94.

Gold for February delivery fell US$2, but managed to keep above the US$800 mark, ending the day at US$805.40 an ounce on the New York Mercantile Exchange. Gold futures closed up US$8.10, or 1%, at US$807.40 an ounce.

The TSX energy group climbed 0.7% as February’s crude oil contract ended the session up $1.16, or 1.3%, at $91.24 a barrel on the New York Mercantile Exchange.

Nexen jumped 4.05% and closed out at $29.80.

In individual stocks, Score Media Inc. had a good day, gaining 5.93% to close at $1.43.

The junior S&P/TSX Venture composite index gained 6.2 points, or 0.24%, and ended the session at 2,601.48.

The Canadian dollar closed at US99.67¢, up 0.22 of a cent.

On Wall Street, markets closed mixed after the U.S. Federal Reserve’s plans to provide US$20 million in loans to banks to ease the global credit crisis was matched by a possible downgrade of bond insurers.

The Dow Jones industrial average lost 25.20 points, or 0.19%, shutting down at 13,207.27. The S&P 500 also moved down, losing 1.98 points, or 0.14% to settle at 1,453.

The Nasdaq composite index, however, rose 4.98 points, or 0.19%, closing at 2,601.01.