The Toronto Stock Exchange's benchmark stock index closed at an all-time high of 16,899 on Friday as strong oil prices buoyed the market.

The S&P/TSX Composite Index pushed as high as 16,947 on Friday, within striking distance of 17,000 points.

While it hasn't made as many of the large jumps that other stock indexes have made in recent months, Canada's benchmark stock index has quietly put together a solid rally by stacking small gains on top of each other. It is up 18 per cent since the beginning of the year.

The TSX has gained in eight of the last nine trading sessions, based on strength in the two sectors that tend to drive its fortunes: banks and oil companies.

Together, those two sectors make up almost 50 per cent of the index, and both have been steadily marching higher for a while now.

Strong run for energy

Energy companies in particular have had a strong week after attacks on Saudi oil facilities by drones believed to have been controlled by Iranian forces prompted fears of war in the Middle East, which would lead to lower oil supplies and drive up the price of Canada's crude.

The TSX inched up despite data from Statistics Canada released Friday showing relatively weak retail sales that grew by just 0.4 per cent in August, less than expected. Ordinarily, a sign that consumers aren't opening their wallets would nudge the stock market lower, but underlying strength elsewhere is seemingly enough to offset that sentiment.

"Any disappointment from the retail sales number that may appear in the market today could be offset by improving sentiment toward energy stocks as energy commodity prices continue to climb," said Colin Cieszynski, chief market strategist at SIA Wealth Management in Toronto.

Stocks veered lower on Wall Street in afternoon trading Friday after reports that a Chinese delegation has cut short a visit to the United States fuelled speculation that upcoming talks aimed at resolving the costly trade war between Washington and Beijing are in trouble.

Contradictory signals from U.S. President Donald Trump have Chinese negotiators on edge, and traders say the uncertainty means bad news for American companies.

The Dow Industrial Average fell 160 points to 26,935.

The U.S. oil benchmark WTI was above $58 US a barrel on Friday, compared to $54.92 a week earlier. That's down from $62 earlier in the week after news of the Saudi oil attack broke, but still the highest price for benchmark contract since May.

Canadian oilsands crude oil, known as Western Canada Select, gained to $45.39 a barrel.