Canada's main stock index rose on Tuesday, clawing back earlier losses after North Korea had fired a ballistic missile over northern Japan, as energy and gold mining shares gained ground.

The Toronto Stock Exchange's S&P/TSX composite index closed up 30.67 points, or 0.2 per cent, at 15,082.70.

The index had hit a one-week low intraday after U.S. President Donald Trump warned "all options are on the table" after the missile test. But investors shrugged off concerns over North Korea, with Wall Street also ending higher.

"I think people are tired of the negative markets and are looking for reasons to move ahead," said Brian Pow, vice president, research and equity analyst at Acumen Capital Partners.

The materials group, which includes precious and base metals miners and fertilizer companies, added one per cent as safe-haven demand for gold helped push bullion prices further above US$1,300 per ounce.

Agnico Eagle Mines (AEM.TO) increased 3.1 per cent to $63.90, and Barrick Gold Corp (ABX.TO) ended up 1.0 per cent at $22.27.

Energy shares climbed 0.8 per cent as oil prices settled well above session lows. Suncor Energy Inc (SU.TO) rose 1.4 per cent to $39.50 and Canadian Natural Resources Ltd (CNQ.TO) added nearly one per cent to $38.98.

U.S. crude prices ended down 0.3 per cent at US$46.44 a barrel, as the market grappled with the shutdown of more than 16 per cent of refining capacity in the United States after a hurricane ripped through the heart of the country's oil industry.

Six of the index's 10 main groups ended higher, with industrials advancing 0.8 per cent as railroad stocks climbed.

Prometic Life Sciences (PLI.TO) soared 25 per cent to $1.50 after it said the U.S. Food and Drug Administration granted the company a rare pediatric disease designation for its plasminogen replacement therapy.

Toromont Industries Ltd (TIH.TO) was another bright spot, rising 9.8 per cent to $54.75 after some analysts increased their ratings on the company's shares.

Bank of Nova Scotia (BNS.TO) and Bank of Montreal (BMO.TO) posted higher-than-expected quarterly earnings, reaping the benefits of a domestic economy growing at its fastest rate in years.

Shares of Bank of Nova Scotia gained 0.2 per cent to $77.33. But Bank of Montreal fell 2.6 per cent to $90.07 and the overall financials group ended 0.2 per cent lower.

Bombardier Inc (BBDb.TO) is out of the running for an estimated US$3.2 billion New York City subway contract, in what the plane and train maker called a disappointment. Its shares fell 2.8 per cent to $2.46.