Image source: Cloud Peak Energy.

The thermal coal industry has been hit hard by a shifting energy landscape. Indeed, cheap natural gas and alternative power sources, like solar, have been stealing coal's market share in electric generation for several years. So coal miners' share prices have been in the doldrums.

But not in July. Last month, the coal group had a powerful rally, with Cloud Peak Energy (NYSE:CLD) and Foresight Energy, LP (OTC:FELP) leading the way higher on 60%-plus price advances.   

Good news? Really?

The coal industry has been beaten down for so long, it's hard to imagine there's anything good going on. But the second quarter hints that a bottom may finally have been reached. For example, Cloud Peak's shares were up nicely through the month but really took off after it released earnings confirming the positive trends on July 28.

The quarter's numbers weren't great, but according to CEO Colin Marshall, "Increasing natural gas prices and a warm start to summer are beginning to improve the overall outlook toward the coal industry. After very low shipments in April and May, we started to see improved shipments in June and are optimistic that this trend will continue during the second half of the year." Add in a slight improvement in the cash margin per ton of coal mined, reflecting cost-cutting efforts, and it's no wonder that investors got excited.   

But that's not the only company that's doing better in the coal space. For example, Alliance Resource Partners LP (NASDAQ:ARLP) and its general partner, Alliance Holdings GP (NASDAQ: AHGP), both advanced around 20% last month. These two are tied at the hip, with Alliance Holdings essentially getting paid to run Alliance Resource. So when Alliance Resource released solid earnings on July 26, the limited partnerships both jumped nicely on the news.   

The big story from this pair was that Alliance Resource was able to cover its distribution by a huge 2.3 times. And, even better, it expects to cover its distribution by around two times through the rest of the year. In other words, a distribution cut earlier in the year has positioned Alliance well to weather any further weakness in the coal industry. And if Alliance Resource's ability to pay its distribution is solid, that means Alliance Holdings' incentive payments -- bonuses it gets based on the distributions Alliance Resource pays -- look increasingly secure.

CNX Coal Resources LP (NYSE:CCR), which was up 35% in July, reported solid results, too, on July 25. (Although we've been working backwards here, the news basically just got better and better as the end of the month drew near.) CNX Coal reported that coal volumes in the second quarter recovered to their highest point since the first quarter of 2015, and it reaffirmed its full-year guidance. Perhaps more exciting than that, it now has purchase commitments for all of the coal it expects to produce this year and nearly 80% of the coal it's planning for 2017.   

Clearly, there's some good news going on in coal -- finally. And it's starting to lift some of the industry's moribund stocks off the proverbial mat.

Avoiding the KO

Foresight Energy's big rise was only partly built on an improving business outlook. The company didn't report earnings in July, but it's in default on some loans. That's a problem. In fact, the partnership is something of a poster child for the problems still lingering throughout the industry, where many of the biggest names have succumbed to bankruptcy because of heavy debt loads.   

Image source: Foresight Energy.

However, a big piece of Foresight's massive 60% price advance was likely based on the fact that it looks likely that the partnership will be able to come to terms with its lenders and survive to fight another day. Although a news release explaining what happened didn't appear until Aug. 1, the company came to an agreement with its lenders, which was disclosed in an 8K filing, to do "something" on July 22. So it makes sense that the good news in coal would extend even to one of its still-troubled names.   

That's a far cry from suggesting that Foresight is a great investment option. But it looks as if it may manage to avoid the knockout punch that's taken down companies such as Alpha Natural Resources and Arch Coal.

It isn't over yet

With the news looking brighter in the coal industry, the shares of some of the key players (or at least the companies still left playing) are starting to perk up. But this is off very low bases, and July is only one month. There's still a lot of risk in the industry as utility customers increasingly look to cleaner sources of power. More aggressive investors may want to look at this still out-of-favor industry now that the silver linings on the clouds are starting to show more clearly, but conservative types should probably still avoid it.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.