The S&P 500 gave up some gains after U.S. President Donald Trump's threat to shut down the government over funding for a border wall undid the boost to markets from optimism over China-U.S. trade talks.

"The market has been whipped around by trade uncertainty and the overall equity moves today," said Erik Nelson, a currency strategist at Wells Fargo. It's "not terribly surprising to see CAD follow suit."

Canada is a major exporter of commodities, including oil, and runs a current account deficit, so its economy could benefit from an improved outlook for the global flow of trade or capital.

The price of oil also pared some of its gains amid worries of a possible U.S. government shutdown. Still, crude oil futures, which fell sharply the day before, settled 1.3 percent higher at $51.65 a barrel.

At 3:03 p.m. (2003 GMT), the Canadian dollar was up 0.1 percent at 1.3394 to the greenback, or 74.66 U.S. cents. The currency traded in a range of 1.3379 to 1.3423.

Last Thursday, the loonie touched its weakest level in nearly 18 months at 1.3445 after the Bank of Canada suggested the pace of future interest rate hikes could be more gradual.

Speculators have added to their bearish bets on the Canadian dollar for the fourth straight week, data from the U.S. Commodity Futures Trading Commission and Reuters calculations showed on Monday. As of Dec. 4, net short positions had increased to 12,936 contracts from 8,630 a week earlier.

Canadian government bond prices were lower across the yield curve, with the 10-year falling 15 Canadian cents to yield 2.077 percent.

The gap between Canada's 10-year yield and its U.S. equivalent widened by 1.2 basis points to a spread of 80.8 basis points in favor of the U.S. bond, its widest since May 2017.

(Reporting by Fergal Smith; Editing by Peter Cooney)

By Fergal Smith