* Rising global optimism outweighs gloomy Canadian data
* C$ trades in 77.86 U.S. cent to 79.20 U.S. cent range
* Bonds turn higher as focus back on economic data
* Canada sheds 82,600 jobs in Feb, jobless rate rises
* Canada trade deficit at C$993 mln is biggest on record (Updates to close)
By Ka Yan Ng
TORONTO, March 13 (Reuters) - The Canadian dollar closed higher against the U.S. dollar on Friday after swinging in a wide range with the market torn between mounting optimism over the world banking system and further evidence of a deteriorating domestic economy.
The currency finished at C$1.2725 to the U.S. dollar, or 78.59 U.S. cents, up from C$1.2791 to the U.S. dollar, or 78.18 U.S. cents, at Thursday's close.
That was a rebound from the session low of C$1.2844 to the U.S. dollar, or 77.86 U.S. cents, which was hit after Canadian employment data for February came in worse than expected.
The currency rose as high as C$1.2627 to the U.S. dollar, or 79.20 U.S. cents, during the day, carried by hopes that North American stock markets would build on this week's gains.
Canada posted a record trade deficit of C$993 million in January, slightly ahead of expectations for a C$1 billion trade shortfall as shrinking U.S. demand for cars led to a dramatic slide in exports. [ID:nN13254064]
Also, the country shed 82,600 jobs last month, compared with forecasts for a decline of 52,500. The unemployment rate shot up to its highest level since 2003. [ID:nN13253705]
The Canadian dollar's big swing showcased its resilience in the face of some bearish economic numbers.
"It certainly looks curious when you only examine the economic numbers," said Eric Lascelles, chief economics and rates strategist at TD Securities.
"To many it is telling that the C$1.30 level was not again breached despite of all this bad news. Perhaps it's even beginning to generate some speculation that the Canadian dollar could start heading more persistently in the opposite direction towards strength."
The currency fell to 4-1/2-year low on Monday when it hit C$1.3066 to the U.S. dollar, or 76.53 U.S. cents, but it then rebounded.
Finance Minister Jim Flaherty, in Britain for a Group of 20 finance ministers meeting, told Canadian media that Canada will continue to see job losses for several months to come. Prime Minister Harper echoed those views. [ID:nN13515816]
"It was not a hot week for the Canadian economy. (The jobs and trade reports) really do drive home just how poorly Canada is doing," said Lascelles. "But it's been a good week for the stock market and the general sense of risk in the world."
The currency was up 0.86 U.S. cents on the week.
Canadian bond prices reversed early losses to end higher as the day's economic figures reinforced an already pessimistic view of the economy in the first quarter.
Early indications of a strong open to North American stock markets took the market's attention away from the poor economic data and left it to fall. The attractiveness of safe haven government debt is often pared when riskier assets, such as stocks, are favored.
"Initially the market was inclined to sell off a bit but repeated economic figures forced otherwise. At the end of the day, I think you can justify this as a macroeconomic rally driving the bond market," Lascelles said.
The two-year bond edged up 2 Canadian cents to C$103.01 to yield 0.973 percent. The 10-year bond rose 42 Canadian cents to C$107.72 to yield 2.871 percent.
The 30-year bond gained 70 Canadian cents to C$124.70 to yield 3.599 percent. The U.S. 30-year bond yielded 3.678 percent.
Canadian bonds outperformed U.S. Treasuries across much the curve. The Canadian 30-year bond yield was about 8 basis points below its U.S. counterpart on Friday, compared with 2.6 basis points on Thursday. (Editing by Peter Galloway)