Canadians bought up a record amount of foreign securities at the end of last year as investors piled into U.S. stocks. 

Investment in securities outside the country hit $29.4 billion in December, according to data released Friday by Statistics Canada. That’s the largest net outflow of purchases into foreign stocks and bonds in the history of records going back to 1988.

The unprecedented outflows coincide with a sustained rally in the U.S. stock market at the end of last year. The purchase of securities abroad was driven by U.S. large-cap technology shares and investment fund shares tracking broad U.S. equity market indexes, the agency said. In total, Canadian investors bought a net $23.2 billion in U.S. stocks during the month.

The data confirm Canadian investors’ elevated demand for global securities – specifically in the U.S. – amid increased market optimism that major central banks have finished hiking interest rates and expectations for a soft landing in the North American economies. The outflow in December also follows a record level of investment into U.S. government bonds in November, as Canadian firms took positions as global bond markets rallied.

Canadian investment in non-U.S. shares also contributed to December’s record – outflows hit $6.3 billion, largely into European equities.

Foreigners had less appetite for Canadian equities at the end of the year, divesting a net $532 million shares after a $5 billion outflow in November. Still, foreign investment into Canadian debt was $11 billion, led by purchases of federal government bonds and money market paper.