Teck Resources Ltd. (TSX:TCK.B)(NYSE:TCK) is up an astounding 340% in just six months, and investors who missed the surprise run are wondering how high the stock could go.

Let’s take a look at the reasons for the rally and try to decide if this is the right time to buy.

Commodities recovery

Teck produces zinc, copper, and metallurgical coal.

Zinc is staging an impressive recovery after a multi-year slump drove prices down to the point where major producers had to shut mines and reduce output. The cuts have finally worked their way through the system just as demand is firming up. This has analysts suggesting the market could actually tip to a shortage position by the start of next year. As a result, the price of zinc has surged nearly 40% in the past six months.

Copper’s recovery isn’t quite as obvious. The metal fell by 50% over the past five years, dropping below the US$2 per pound mark in January. The last six months have been a bit of a roller coaster with the price surging as high as US$2.30 before pulling back below US$2.10 per pound.

Analysts are split as to whether or not copper has finally bottomed, but the trend over the past six months suggests the worst could be over. At the time of writing, copper is trading at US$2.15 per pound, above Teck’s Q1 average realized selling price.

Coal is mired in its worst slump since 1950, but Teck says it is seeing signs of a recovery. The market price through Q2 moved above the contract settlement price for the quarter, and that could bode well for shipments through the end of the year.

What about oil?

Teck is a 20% partner on the Fort Hills oil sands development. The project has been a huge cash drain, and when WTI oil fell below US$30 per barrel in January most investors gave up hope that Fort Hills could ever be profitable.

Oil’s move back as high as US$50 per barrel has rekindled investor interest, and many are hoping the recovery in crude prices will continue right up to the point when Fort Hills begins production in late 2017.

Earnings and debt

Teck has done a good job of controlling costs through the downturn and managed to squeeze out an adjusted Q1 profit of $18 million.

The company is carrying about $9 billion in debt with US$600 million coming due next year. Liquidity remains above $5 billion, including US$3 billion in unused credit lines, so there are adequate funds available.

Teck expects to finish 2016 with a cash balance of at least $500 million and says it can meet its Fort Hills obligations without taking on more debt.

Should you buy or sell?

The last time Teck rallied off the $4 mark, it topped out at $60 in less than two years, so a continued move from the current price of $18 to $30 per share is certainly possible.

However, this stock remains a risky bet and the run-up has been so extreme that it would be prudent to start taking some profits.

If you want to buy now, you have to believe coal, copper, and oil are headed higher.

Just released! One top stock for 2016 and beyond

Exports of liquefied natural gas could be one of the best growth opportunities out there for long-term investors. And, we think we've identified the Canadian company to invest in. It's a global company with operations across nearly 20 countries and 70 locations. We like it so much, we've named it as 1 Top Stock for 2016 and Beyond. To find out why, click here now to learn how to access your FREE copy today!

NEW! This Stock Could Be Like Buying Amazon In 1997

For only the 5th time in over 14 years, Motley Fool co-founder David Gardner just issued a Buy Recommendation on this recent Canadian IPO.

Stock Advisor Canada’s Chief Investment Adviser, Iain Butler, also recommended this company back in March – and it’s already up a whopping 57%!

Enter your email address below to claim your copy of this brand new report, “Breakthrough IPO Receives Rare Endorsement.”

Fool contributor Andrew Walker owns shares of Teck Resources.