Times are tough for Teck Resources Ltd. (TSX:TCK.B)(NYSE:TCK) and its shareholders.

The stock has plummeted more that 80% in the past five years, and the company is facing a perfect storm in the commodity markets with all of its main operating segments facing a prolonged slump.

That’s not exactly the scenario that reels investors in, but there could be some light at the end of the tunnel as well as some serious upside.

Earnings resilience

Teck recently took a whopping $2.2 billion write-down on assets in its Q3 2015 earnings statement, including a $1.5 billion hit on the coal division. Teck is one of the world’s largest producers of steel-making coal, and that market is really struggling to find some price support.

Write-downs are never good, but it is important to keep in mind that they are non-cash charges made in order to align the value of the assets with the outlook for the commodity market.

When we take a look at the operating performance of the coal, zinc, and copper divisions, we can see that Teck is holding its own in a brutal market.

Many of its peers are losing money, but Teck still managed to squeeze out an adjusted Q3 profit of $29 million, or $0.05 per share.

Coal

The company’s average realized price for steel-making coal hit US$88 per tonne in the third quarter, down 20% from the same period last year. Production costs fell 10%, so that helped mitigate some of the pain, and the division actually saw year-over-year gross profits increase to $27 million from $10 million.

Copper and zinc

The copper market is also taking it on the chin. Teck’s average realized price for Q3 was US$2.39 per pound, significantly lower than the US$3.17 it received in 2014. Gross profits came in at $82 million, down from $169 million the year before.

Zinc production delivered gross profits of $231 million, about the same as the results from Q3 2014.

The numbers are not pretty, but Teck is still making money, which is a credit to management for its ability to control costs in a weak environment.

Oil

Teck owns 20% of the Fort Hills oil sands development. The project is moving along as planned, but the plunge in oil prices has investors concerned that the facility will struggle to make money once it is completed. Teck is required to pony up $1.5 billion over the next two years to get Fort Hills completed. The project is expected to hit full production sometime in 2018. Teck’s share of the output is about 36,000 barrels per day.

Teck had $1.8 billion in cash on its balance at the end of Q3, so there should be adequate funds to get it through the last leg of the Fort Hills project.

Should you buy?

Teck is sitting on $8.2 billion in long-term debt, so the clock is ticking.

The company is a low-cost producer in all of its operations, and Fort Hills could turn out to be a cash machine. If you have a contrarian investing style and believe the commodity markets are near the bottom of the cycle, Teck is a compelling bet, but it isn’t for the faint of heart.

Two energy plays for your watch list

Check out our special FREE report "2 Canadian Energy Stocks on the Cusp of a Powerful Long-Term Trend". In this report, you'll find that Canada is rich in other energy sources that are poised to take off.

Today, you can get the full analysis for free! Simply click here now to see the complete report.

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 Ltd.