U.S.
U.S security transactions are reported on a trade date basis. A sale is reportable in the year it is executed not settled. In the case of security sales which take place in December but which do not settle until the following year, the sale proceeds will be reported in the year of the trade, and accrued dividend or interest, if any, will be reported the following year's 1099-DIV/INT.
Canada
The Canada Revenue Agency generally considers the settlement date basis. The settlement date for most Canadian and U.S. stock exchanges generally takes place three business days after the trade date.
A sale is reportable in the year it is settled, not traded. For example, the sale proceeds should be current year if a trade is settled on December 31.