May 5 (Reuters) - Canada's main stock index edged lower for a third consecutive day on Tuesday as a steep decline in the shares of e-commerce company Shopify Inc weighed on the technology sector, offsetting gains for energy and financials.
The Toronto Stock Exchange's S&P/TSX composite index ended down 71.96 points, or 0.2%, at 33,566.91, adding to its declines on Friday and Monday.
"There's still a struggle over whether the market cares more about earnings or headlines around Iran and oil," said Matthew Kempton, portfolio manager at Verecan Capital Management.
The United Arab Emirates said it was under attack from Iranian missiles and drones, even as Washington said a shaky ceasefire was intact despite an exchange of fire the previous day as U.S. forces attempted to force open the Strait of Hormuz.
Shopify's lukewarm forecast failed to stem investor worries about disruptions from artificial intelligence, sending its shares down 15.6% and overshadowing comments that its own AI efforts were driving in demand and consumer traffic.
Technology lost 4.2% and real estate ended 0.6% lower. Colliers Group International Inc shares fell 5.6% after the real estate services firm missed first-quarter profit estimates.
Thomson Reuters reported a double-digit first-quarter revenue rise, boosted by gains in its "Big 3" business segments of legal professionals, corporates and tax, and audit and accounting. Still, its shares ended 0.8% lower.
All the other major sectors ended higher, including energy, which added 1.4%. The price of oil settled 3.9% lower at $102.27 a barrel, giving back much of the previous day's advance.
Canada's merchandise trade balance swung to a surprise surplus in March as elevated oil prices contributed to a jump in exports.
The consumer discretionary sector rose 1.6% and heavily weighted financials ended 0.7% higher.
(Reporting by Fergal Smith in Toronto and Tharuniyaa Lakshmi in Bengaluru; Editing by Diti Pujara and Aurora Ellis)
By Tharuniyaa Lakshmi and Fergal Smith



















