Canada recorded its second current account surplus in a row last quarter after a streak of deficits dating back to 2008.

Statistics Canada said Monday that Canada’s current account surplus for the second quarter was $3.6 billion, double the upwardly revised $1.8-billion Q1 total.

Higher prices drove the export gains in forestry products, energy products, and building and packaging materials, StatsCan said. The global shortage in semiconductor chips lowered motor-vehicle exports, partially offsetting the increase in exported goods.

A research note from CIBC Economics said the recent drop in commodity prices will likely lead to smaller surpluses or even modest deficits by the end of the year.

Trade in services was positive for the fifth straight quarter as the pandemic continued to restrict travel.

“Surpluses in services were rare before the pandemic and are occurring largely because travel restrictions during the pandemic have affected payments more severely than receipts,” CIBC said.

“However, with travel outside of the country starting to pick up again, a deficit in services could be re-established.”

The investment income surplus increased by $1.7 billion to $4.0 billion, StatsCan said, due to lower interest payments on loans and deposits held by non-residents.

On the investment side, Canadians acquired a record $57.2 billion in foreign securities in the second quarter — including $33.7 billion in U.S. shares — up from $36.9 billion foreign shares in the first quarter.

“Such continued and high levels of investments have never been seen in the past,” StatsCan said.

Foreign investment in Canadian securities was also strong at $50.3 billion, including $33.8 billion of federal government debt securities as the government borrows to support pandemic spending.

The Q2 totals surprised analysts and could be “slightly supportive” for the Canadian dollar, CIBC said.