Image source: Getty Images.

What: Shares of SM Energy (NYSE:SM) were up 10% at 11:15 a.m. EDT on Wednesday.

So what: Fueling SM Energy's rally was its better-than-expected second-quarter results. While the company reported an adjusted loss of $30.2 million, or $0.44 per share, that was $0.24 per share better than the consensus estimate.

Three things drove this solid result. First, a 29% rebound in oil and NGL prices enabled SM Energy to capture a higher realized price per barrel of oil equivalent than the prior quarter. In addition to that, the company cut its lease operating expenses by 14% sequentially. Finally, total production exceeded guidance by 1 million barrels of oil equivalent, or BOE, for the quarter. In the oil patch, higher prices plus lower costs plus higher production is the formula for success.

Because SM Energy is getting more production for less money, it is cutting its full-year spending guidance while boosting its production outlook. As a result, its capex budget is declining from $705 million to $670 million while production is expected to be between 53 million BOE and 57 million BOE, which is up from its prior range of 51 million BOE to 55 million BOE.

Finally, the company announced the sale of two non-core asset packages for $172.5 million. Those asset sales will enable the company to trim debt.

Now what: SM Energy did everything an investor could hope an oil company could accomplish during the second quarter given how harsh conditions are in the oil market right now. It is getting more oil out of its wells at a lower cost, which will improve returns over the long-term. Meanwhile, it boosted its balance sheet by shedding non-core assets. These moves are strengthening the company's ability to weather the downturn and should position it to thrive when conditions finally improve.

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.