* TSX rises 32.40 points, or 0.26 percent, to 12,736.92 * Six of the 10 main sectors advance * RBC, TD have biggest positive influence on market By John Tilak TORONTO, Aug 16 (Reuters) - Canada's main stock index advanced to its highest level in close to three months on Friday as supply worries drove gains in the price of oil and in the shares of energy companies, offsetting declines in mining stocks. The Toronto stock market index also rose 1.6 percent for the week. After trailing U.S. stocks all year, the TSX has managed to outperform the S&P 500 in August to date as a rebound in commodity prices begins to take hold. A recent wave of positive economic data from China, Europe and the United States has supported the case for a strong global recovery, which is positive for the export-focused Canadian market. "The sentiment toward China is starting to improve, the sentiment toward Europe is starting to improve," said Colin Cieszynski, senior market analyst at CMC Markets Canada. "And that's helping underpin commodities, which is helping the Canadian stocks to recover, finally." The Toronto Stock Exchange's S&P/TSX composite index was up 32.40 points, or 0.26 percent, at 12,736.92, after going as high as 12,799.99, touching its highest intraday level since May 22. A report on Friday showed U.S. consumers, bracing for higher interest rates and slightly slower economic growth, were a bit less optimistic in August as sentiment fell from last month's six-year high. Investors bracing for the U.S. Federal Reserve to begin tightening monetary policy were dissecting every piece of economic data to try to figure out when the Fed will start to move. "The initiation of (Fed) tapering is the worst-kept secret in town. The question is when," said Irwin Michael, portfolio manager at ABC Funds. Investors should look at the stimulus pullback as "a positive thing, that the economy has nursed itself back from the 2008-2009 lows," he added. Six of the 10 main sectors on the index were higher on Friday. Oil and gas shares climbed 0.9 percent as oil prices rose on concerns that violence in Egypt could affect the Suez Canal, a conduit for up to 3 million barrels per day of oil. In the group, Suncor Energy Inc rose 1 percent to C$35.33, and Enbridge Inc advanced 0.6 percent to C$43.61. Financials, the index's most heavily weighted sector, gained 0.6 percent. Royal Bank of Canada added 0.8 percent to C$64.36, and Toronto Dominion Bank was up 0.8 percent, at C$87.41. The two stocks had the biggest positive influence on the index. But the materials sector, which includes mining stocks, slipped 1 percent. Barrick Gold Corp lost 2.1 percent to C$20.01, and fertilizer producer Potash Corp fell 2.4 percent to C$31.41.