As shareholders of BP (BP 0.71%) are well aware, the company has experienced numerous setbacks over the last decade. First, there was the disastrous Deepwater Horizon oil spill in the Gulf of Mexico, and then the oil-price slump of 2014-17.

But in 2018, BP's stock has come roaring back. Oil prices are high, production is up, and the company is offering a fat dividend yield. Of course, BP's peers like Royal Dutch Shell (RDS.A) (RDS.B) are likewise outperforming. Nevertheless, let's take a peek under the hood to make sure BP can sustain this momentum, so we can tell whether the stock is a buy.

A smiling young man stands with his arms up next to an oil drum from which is erupting a cloud of paper currency

2018 has been great for oil industry investors so far. But can BP continue to outperform? Image source: Getty Images.

The power of price

To see how much the price of oil affects BP's performance, look no farther than the company's profit margins. This five-year chart of BP's and Shell's profit margins on a trailing-12-month basis is overlaid with the per-barrel price of Brent Crude (the red line), and shows how profitable the big oil companies were prior to the oil-price slump, and how well they've recovered from its depths in early 2016:

BP Profit Margin (TTM) Chart

BP Profit Margin (TTM) data by YCharts.

What you may notice about this chart is that even though oil prices haven't yet returned -- and may never return -- to their $100-plus per barrel highs, Shell's profit margin is now higher than it was immediately prior to the price crash, and BP's has almost recovered.

That's thanks to the cost-cutting measures that big oil companies took during the price downturn. By streamlining their operations in an attempt to be profitable with oil prices hovering around $50 per barrel, as they were through much of 2016 and 2017, BP and Shell were positioned to outperform when oil prices finally jumped above $60 per barrel in late 2017.

Breaking even

BP's CFO Brian Gilvary has stated that the company's break-even point -- the per-barrel oil price at which it will cover its production expenses -- is about $50, but BP expects to continue to cut costs and bring its break-even point to a range of $35 per barrel to $40 per barrel by 2021. If BP can be this profitable at its current breakeven, imagine how well it will do with an additional $10-$15 in per-barrel profit, given that it produces 2.5 million barrels of oil equivalent per day. 

Of course, this assumes that oil prices don't tumble again, which is far from a guarantee. However, even in the depths of the oil-price slump, per-barrel oil prices stayed mostly above $40, only dipping below that point for about four months, from December 2015 to April 2016.

Hypotheticals have limited value, but if BP had had a break-even point of $35 per barrel or $40 per barrel during the downturn, it probably would have been operating in the black for both 2015 and 2016, thanks to its lucrative refining and marketing business, which isn't directly affected by oil prices. That bodes well for how it might fare even in the event of a future oil-price downturn.

Flying high

BP's high profit margins were on display in the most recent quarter, Q2 2018, as the company reported impressive numbers both financially and operationally.

Revenue was up 34.2% year over year, to $76.9 billion. BP turned that revenue into $2.9 billion (with a "b") of net income, up from just $156 million (with an "m") in the prior year's Q2. Operationally, BP was firing on all cylinders, with total production up 3.3% over the year-ago quarter. Production is likely to continue to increase thanks to BP's purchase of the U.S. shale assets of Anglo-Australian company BHP Billiton.

In addition, the company raised its dividend for the first time in four years and executed a $200 million share buyback. If BP can keep executing this well, shareholders should have no cause for complaint in the coming months and years. 

And the answer is...

BP seems to have fully recovered from the oil-price downturn, and has been making constant progress toward improving its operations and rewarding its shareholders. With oil prices showing no signs of weakening, it's likely that BP will continue to outperform. BP looks like a solid buy.