But other oil and gas companies will stay beaten down for a while.
On June 16, 2014, Brent crude oil peaked at $116 a barrel. Over the next 19 months, its price dropped more than 70%, to a 13-year low of $28 on Jan. 20, 2016. How has that slide affected the energy sector? Let us count the ways.
Bankruptcies? They’ve become routine, as companies struggle to service the debt they took on to finance their drilling; there were 77 North American energy bankruptcies between the beginning of 2015 and mid-May. Profits? Evaporated, as the price of oil fell below the cost of extracting it for many companies. Collectively, the 32 oil-and-gas titans in the Fortune 500 swung from $91 billion in profits in 2014 to $46 billion in losses in 2015. And energy stocks as a whole? They endured a cover-your-eyes nosedive, as the S&P Global Oil Index fell 52% between June 2014 and this January.
Energy investors have been starved for good news—and this spring they got some. At $49 a barrel in early June, Brent crude had risen more than 70% from its January bottom. Many analysts believe prices have stabilized, and if true, that could bring a gusher of opportunity. Eric Nuttall, portfolio manager of Canada’s Sprott Energy Fund, jokes that with stocks so badly depressed, “prices can double and still be down 80%.”
That said, would-be investors should proceed under a caution flag. For starters, few analysts believe prices will keep rising at this spring’s pace. Goldman Sachs gs , for example, predicts oil will stay flat for the rest of 2016, inching up to $60 a barrel by the end of 2017. And even if the increase accelerates, not all oil and gas stocks will benefit equally.
The oil-price crash, of course, was the result of an oil glut. When prices were high, producers launched countless new projects—with U.S. companies in particular using fracking and horizontal drilling to tap previously unreachable reserves. That brought a flood of new supply to the market just as the global economy—and global demand for oil—began to weaken. Prices plummeted, but few producers were willing to slow their pumping; many needed to bring in as much cash as possible to service their debt.
“The price falls in a commodity market until someone blinks,” says Jonathan Waghorn, co-portfolio manager of the Guinness Atkinson Global Energy Fund in London. In the first quarter of this year, oil companies blinked en masse, reducing output in the face of big losses. “Big integrated oil companies are decreasing investment significantly,” says John Dowd, manager of energy-related investments including the Fidelity Select Energy Portfolio mutual fund. The result: In March, oil inventories finally fell, reversing a yearlong trend.
Demand is rising too: Goldman says China and other emerging markets are using more oil than analysts had anticipated, while low gas prices are encouraging American consumers to drive more than ever. (The average price of gasoline was $2.22 a gallon in April—cheaper than in 1931, when adjusted for inflation.)
When prices rise, the companies that do best are explorers and producers (E&P), which get most of their revenue from selling the crude they extract. But the “breakeven” points for these companies—their cost-per-barrel of producing oil—vary widely. Oil reached by conventional “vertical” drilling can cost $25 a barrel or less; oil extracted by fracking can cost from $35 to $80 a barrel. For investors, the two urgent questions are: Is a company above breakeven? And if not, can it keep up with its debt payments while it waits for profitability?
Given these criteria, Waghorn of Guinness Atkinson is a fan of Hess hes . Formerly an integrated oil company with interests in transportation and refining, Hess in 2013 spun off many of its businesses in order to focus on E&P. About two-thirds of its crude production comes from the U.S., and a third of that comes from fracking in the Bakken formation in the northern Great Plains. Hess’s Bakken wells remain below breakeven, and its Ebitda (earnings before interest, taxes, depreciation, and amortization) fell sharply in 2015. But Waghorn says Hess’s wide range of oil reserves, including fields in Guyana, will help diversify its revenue sources in case prices stall at current levels. And its current debt-to-Ebitda ratio of 2.6, below the industry average, suggests that it has more flexibility to withstand sustained low prices than many of its competitors.
Dowd of Fidelity singles out EOG Resources eog . EOG, too, gets much of its oil from fracking, but it has invested particularly heavily in scientists and technology to help it drill more accurately. That saves time and money, making EOG’s wells more productive and delivering what Dowd says are some of the “best well economies” in the Bakken and the Eagle Ford in south Texas. Recently the company told investors it could profit on some of its production at $30 a barrel—which would give it some insurance if prices fell again.
Among smaller producers, Waghorn singles out Carrizo Oil & Gas crzo . Carrizo’s breakeven point, at $60 a barrel, is relatively low among frackers, and the company holds the rights to an unusually strong portfolio of oil and gas fields, which Waghorn thinks make it a likely acquisition target. Investors who would prefer to play E&P companies more broadly could consider the iShares U.S. Oil & Gas Exploration & Production ETF, which focuses on large-cap companies and has an expense ratio of 0.43%.
A better climate for oil producers is also good news for oilfield servicers. Servicers, in essence, do the dirty work for E&P companies: The producer finds the right location to drill and finances the operation, but the servicer provides the tools and people to build, maintain, and test those wells. U.S. producers have become particularly dependent on servicers, and among such companies, Waghorn says, the best positioned is Halliburton hal . The company has absorbed a blow to revenue as the industry struggled—in 2015 it posted its first annual loss in more than a decade—and it suffered a setback this spring when an attempted merger with rival Baker Hughes fell through. But Halliburton increased its market share during the oil slump, and it should thrive when U.S. producers go into growth mode again.
For more on the energy industry, watch this Fortune video:
While E&P and service companies benefit from rising prices, the same can’t always be said for “downstream” businesses (think refiners and gas station operators) or “midstream” firms that transport oil. Downstream companies make money on the difference between the price of crude and the price of the refined petroleum extracted from it (a difference known as the “crack spread”), while midstreaming is a volume business (ship more oil, earn more money). These businesses aren’t likely to get a big earnings boost until customer demand becomes much more vigorous.
The upshot: For now investors should avoid pure-play downstream companies like Marathon Petroleum mpc , which has focused on refining, retail gas sales, and transport since being spun off from Marathon Oil mro in 2011. Managers also say it’s not the right time to boost your exposure to integrated oil giants that encompass both oil production and downstream operations. Exxon Mobil xom , for example, is a major oil producer, but experts expect its downstream businesses to drag down its growth relative to pure E&P companies. From one perspective, Exxon’s stock is a victim of its own stability: It fell only 30% during the oil slump and has already recovered much of the ground it lost, so money managers don’t expect it to rally much further. It’s a dominant company, yes—but at 20 times expected 2017 earnings, not a great buy.
Who Wins When Oil Rises?
The oil-price rebound has sparked a recovery for energy stocks. Still, until the global economy gets stronger, the rally will leave some parts of the industry behind.
Exploration and Production
The companies that extract oil and control access to reserves are the ones whose fortunes most closely track the price of oil. Many smaller “E&P” firms went bankrupt during the recent slump, but survivors with stronger balance sheets, including Hess and EOG Resources, now look good to investors.
Integrated Oil ‘Majors’
Oil giants like Shell rdsa , Exxon Mobil, and BP mro do plenty of exploration and drilling. They also have “downstream” businesses, however—think refining and gas-station operations—and higher prices hurt those units’ profits. Until consumer demand gets stronger, they won’t benefit as much from oil’s rebound.
Refiners and Transporters
Companies that refine and sell petroleum products pay market price for oil, so their costs are rising, but a shaky economy makes it harder for them to pass costs on to customers. Stocks of pipeline and trucking companies, meanwhile, won’t get much of a bump until rising demand boosts the volume they handle.
A version of this article appears in the June 15, 2016 issue of Fortune with the headline “Cleaning up After an Oil Glut.”