Shareholders of Whiting Petroleum Corp. just had a wild week. A report of a potential debt repayment problem caused such volatile buying and selling of its shares that trading had to be halted five times last Wednesday.

Things calmed down when it became clearer that the company had money and time to deal with the debt coming due, yet Whiting shares were still down near their all-time low price of less than $3 per share. That's quite a fall for a stock that touched $370 a share in 2014 at the peak of the shale oil frenzy in western North Dakota.

There's gloom throughout the shale oil business. There was a boom in it a few years ago, big enough to be felt in Minnesota. But it might have been the first profitless boom in American business history.

And the reckoning is underway.

"As of the end of 2018, so this number is a little bit old, we've spent about $1 trillion in U.S. oil shale and we've returned about $700 billion to the companies in the form of cash flow for a whopping, negative 38% cash-on-cash return," James C. West, partner and oil-services industry analyst for investment firm Evercore ISI, told me last week.

"We have a shale business ... that's been massively overcapitalized. That's of course changing now, with limited access to capital," he said.

Way too much capital also went into the oil-services sector, West said. Nonexistent returns on dollars invested had a predictable effect on stock prices.

Up until 2014, the value of oil producers in the stock market more or less tracked the price of oil. But that year was as good as it ever got for shale oil investors. Oil production has increased since then, with last year the biggest output so far for North Dakota, but the value of the companies doing that work has mostly gone sideways or down.

The total return to shareholders in the sector in the last decade was effectively zero, Evercore ISI analysts pointed out in January, vs. about 300% for the S&P 500. Meanwhile, the 15 CEOs they tracked among oil-producer companies, as a group, collected about $2 billion in pay.

Investors and industry analysts have been demanding the leaders of oil companies to take what they have come to call "the pledge." That's a promise that they are going to live within their means, pay back their loans and generate market-rate returns on the capital investors have given them.

Stop and think about that for a second and try not to laugh. A big industry had to be asked to promise to make money.

The industry did much better in 2019, West said, outspending its cash flow by only a couple of percentage points rather than the wild spending of previous years.

"They are all saying they're going to be within cash flow in 2020," he said. "We'll see. It may be a little bit harder with oil prices doing what they've been doing the last couple of weeks," as the main benchmark oil price has declined so far this year.

The gloom in the industry isn't just about the recent slip in oil prices. Instead of an opportunity to consistently pile up cash, there has been something called the Fracker's Dilemma.

Those familiar with the oil-production technique called hydraulic fracturing know that there's not really such a thing as drilling into the ground and hoping to hit a gusher.

Fracking means going after oil still in the rock, by injecting water, sand and chemicals under high pressure to basically crack it, releasing the oil. These wells can produce for years but still get much of their output relatively soon after going into production.

To keep production levels up, companies need to keep drilling new wells. That presents a tough choice.

Once they have collected the cash from selling the oil from wells that have been producing, do they give the money to shareholders or use it to pay back corporate debt? Or should they take that money and drill another oil well?

That explains why you hear oil-company executives talking about the switch to "manufacturing mode," a focus on generating consistent production from proven oil fields, hoping for the kind of consistent profit margins that a high-volume manufacturer would produce making thousands of identical products.

What that means is that the industry will see less exploration.

Two big oil-services companies, Halliburton Co. and Schlumberger Limited, both have said that the American shale industry is already past its peak. Halliburton's CEO recently said 2019 marked the watershed, as the shale industry switched from growth to what he called "capital discipline." That's another way to say that the companies have gotten serious about trying to live within their means.

A lot of smaller companies need to get merged out of existence or simply go away, said West of Evercore ISI, as consolidation and greater scale will improve efficiency. That includes lower general and administrative expense, as investors in the industry shouldn't have to pay for as many expensive CEOs, CFOs, and other corporate staff. Bigger and more diversified companies should also have lower capital costs.

The good news is that the capital markets seem to be working. That is, when investors' confidence that these projects would work out evaporated, the capital has, too.

The high-yield corporate bond market is still available to good operators, although it's mostly for refinancing and extending the terms, West said, while commercial banks have often renewed credit lines with lower borrowing limits.

And, West said, "I'd be really shocked if we were able to do an equity deal right now."