The Canadian dollar closed with a gain of more than six-tenths of a cent on Monday as the price of crude oil jumped back above $40 US per barrel for the first time in three weeks.

A barrel of West Texas Intermediate gained 64 cents to close at $40.36 US a barrel on Monday as OPEC and non-OPEC members are set to meet for four days to discuss oil output in Doha next weekend.

"It now seems that among the oil producing countries, a sense of calm and price visibility is preferable to the chaotic downward spiral of a price war," Credit Suisse's chief investment officer Michael Sullivan said in a note yesterday.

The hope of a deal drove oil prices higher on Monday, which in turn was good news for the Canadian dollar for a second straight trading day.

The loonie gained 0.62 of a cent, finishing the day at 77.53 cents US. The Canadian dollar hasn't closed that high since it finished at 77.84 cents US back on Oct. 15, 2015.

After being pushed down as low as 68 cents US in January, sentiment has turned around for the Canadian dollar of late.

"While the U.S. dollar has weakened against all these currencies since 20th January, it has depreciated the most against the dollars of Canada and Australia, which are large net exporters of commodities," John Higgins of Capital Economics said.

So much so, in fact, that speculators appear to be pouring in. Data from the Commodity Futures Trading Commission shows net long positions stood at 97 contracts in the week ended April 5. That means more investors are betting on the Canadian dollar than are betting against it.

The previous week, there was a net short of 6,180 contracts. In January, the figure was as high as 66,819 shorts.

The optimism in oil and the loonie spilled into the stock market, where the S&P/TSX composite index gained 26.03 points to 13,422.76.

In New York, markets turned lower with the Dow Jones industrial average losing 20.55 points to 17,556.41, while the S&P 500 dipped 5.61 points to 2,041.99 and the Nasdaq composite retreated 17.29 points to 4,833.40.