(Adds portfolio manager quote and details throughout; updates prices)
* TSX closes up 78.74 points, or 0.52 percent, at 15,211.87
* Eight of the TSX's 10 main groups end higher
* Index ends August with a 0.4 percent gain
* TD rallies 3.3 percent to C$67.06
TORONTO, Aug 31 (Reuters) - Canada's main stock posted a 3-week high on Thursday as commodities rallied and data showed rapid growth in the domestic economy, while shares of Toronto Dominion Bank had its biggest one-day gain in 18 months after the company reported strong earnings.
TD Bank, Canada's second-biggest lender, was by far the biggest influence on the index. Its shares rallied 3.3 percent to C$67.06, its biggest advance since February 2016, after it reported earnings that topped expectations by a wider margin than its rivals in a quarter in which Canadian banks have outperformed market forecasts.
Canadian Western Bank advanced 1.1 percent to C$29.00 after it also reported better-than-expected results, while the overall financials group gained 0.5 percent.
Adding support for the sector, data showed that Canada's gross domestic product grew at an annualized 4.5 percent in the second quarter, far more than the 3.7 percent economists had forecast, reinforcing expectations the Bank of Canada will raise interest rates in October.
"The Canadian economy is on fire," said Barry Schwartz, portfolio manager at Baskin Financial Services. "Healthy GDP leads to healthy loan growth."
Higher rates tend to increase net interest margins of banks.
The Toronto Stock Exchange's S&P/TSX composite index closed up 78.74 points, or 0.52 percent, at 15,211.87. For the month of August, it gained 0.4 percent.
Oil and gas stocks, which climbed 1.3 percent, were helped by crude oil prices that settled 2.8 percent higher. Prices had suffered steep losses on demand concerns following record flooding from Hurricane Harvey in the United States that knocked out a quarter of the country's refining capacity.
Cenovus Energy rose 3.6 percent to C$9.77. Encana Corp gained 2.3 percent to C$11.65.
The materials group, home to resource firms, added 0.8 percent as gold miners benefited from bullion prices that rose on a weaker U.S. dollar.
Goldcorp Inc gained 1.6 percent to C$17.16.
Magna International Inc was another influential gainer, up 2.2 percent to C$60.09. The company says it is developing a new self-driving vehicle system.
Eight of the index's 10 main groups ended higher. A 0.3 percent decline in consumer staples stocks and a 0.2 percent fall in telecoms tempered gains. (Additional reporting by Solarina Ho; Editing by Dan Grebler and Sandra Maler)