What happened

Shares of oil and gas explorer Devon Energy (DVN -0.46%), LNG terminal company Tellurian (TELL 0.44%), and energy services company Core Laboratories (CLB) were rallying today, up 7.3%, 6%, and 5.5%, respectively, as of 1:45 p.m. ET on Thursday.

Each of these companies plays in a different part of the energy sector, so it's no surprise their rally came in conjunction with a rise in oil and natural gas prices today, the result of an incrementally bullish report from the International Energy Agency (IEA).

So what

On Thursday, the IEA raised its oil-demand outlook for the rest of 2022, increasing its forecast by 380,000 barrels per day (bpd) to about 99.7 million bpd globally. In response, oil prices were up about 3%.

Unfortunately, the increased demand isn't so much a more-bullish take on the global economy, but rather the result of oil being substituted for natural gas in Europe. On that note, natural gas prices were soaring today, up about 8% late in the trading day.

The report noted that since Russia has curtailed natural gas supplies to Europe, some European countries will transition from burning natural gas to burning oil for producing electricity. The report also noted this trend could continue through the end of 2023, at least.

Although the U.S. has had some good economic news lately, the report didn't revise upward its forecast of weak demand in the rest of the world. But it does appear that with the Russia-Ukraine war continuing, there could be a floor under oil and gas prices. No doubt, oil prices have come down a lot from their highs, but are still hovering in the mid-$90 range. Meanwhile, natural gas prices are back near the highs reached in June.

That certainly bodes well for all three of these stocks. Many think of Devon as an oil driller, but its output is actually fairly balanced between oil and natural gas. This week on Tuesday, Devon also announced a $1.8 billion bolt-on acquisition in the Eagle Ford shale at what looks like an excellent price, should oil and gas prices stay in this vicinity.

Meanwhile, higher natural gas prices are essential for Tellurian, which is embarking on an ambitious and expensive construction project in its Driftwood LNG export plant, predicted to cost $12.8 billion and come on line in 2026. The company has also doubled-down on its bet on natural gas pricing, recently purchasing gas drilling assets that it believes will bring in cash flows to help fund part of the project. It received an analyst upgrade earlier this week.

Core Labs also stands to benefit from higher oil prices. In fact, it needs sustainably higher oil prices arguably even more than explorers such as Devon, as its business is dependent on new drilling activity. Core's international operations have been hurt by the strong dollar, and its business in Russia and Ukraine has been hurt by the war. The company recently reported underwhelming earnings, but forecast better times as drilling growth slowly resumes.

Now what

Just when everyone thought we were plunging into a recession two months ago, the past week has seen a surprisingly strong jobs report, as well as easing inflation. Of course, most of that relief in inflation has come from falling oil and natural gas prices, which wouldn't necessarily be good for energy stocks.

But it might not be a bad thing, either. If energy prices go too high, it could lead to demand destruction and economic turmoil; therefore, there is a happy medium for energy prices somewhere. If that ideal price settles around these levels, and the economy slows without tipping into a bad recession, oil and gas companies could still make very nice cash flows. That's likely what Warren Buffett predicts, given his big recent buys in the energy sector this year.

As always, given the importance of energy on the broader economy, I'd recommend keeping a fixed percentage of your portfolio in the volatile energy sector, adding on big declines and trimming when prices soar.