What happened

The recent volatility in energy stocks has been nerve-racking. This week, stocks across the board -- from oil and gas to clean energy stocks -- are soaring double digits, recouping all of their losses from last week, and then some.

As of 11 a.m. EDT Friday, here's how much some of the high-volume stocks from the two broad energy groups have gained since last Friday's closing.

Renewable energy stocks:

Ballard Power Systems (BLDP -4.18%): 10.5%.

Enovix (ENVX -2.93%): 11.3%.

Clean Energy Fuels (CLNE -4.49%): 20.3%.

Oil stocks:

Core Laboratories (CLB): 16.7%.

Centennial Resource Development (PR -0.98%): 23.5%.

Occidental Petroleum (OXY -0.94%): 16.8%.

So what

There's been a flurry of good news for investors in energy stocks this week, with oil prices dominating the headlines.

As I write this, crude oil prices are headed for their biggest weekly gains in nearly 10 months. The U.S. oil price benchmark, West Texas Intermediate (WTI), is hovering around $68.76 per barrel this morning, up nearly 10.3% from last Friday's closing price.

A news anchor in a studio with breaking news flashing behind on screen.

Image source: Getty Images.

Among the several macro factors that are driving oil prices higher, two stand out. First, China reported zero coronavirus cases earlier this week, fueling hopes of a stronger recovery in the nation. The U.S. and China are the largest oil-consuming nations in the world.

Second, a hurricane is hurtling toward key oil-producing regions in the Gulf of Mexico, forcing energy companies in the oil hub to vacate facilities. With oil majors like Phillips 66, Chevron, and Royal Dutch Shell evacuating workers, it is feared production from the oil hub could decline in coming days. This comes close on the heels of Mexico's state oil company slashing production estimates after a fire at an offshore platform. Mexico is a key oil supplier to refiners in the Gulf.

Meanwhile, weekly petroleum data from the Energy Information Administration showed crude oil inventories for the week ending Aug. 20 were 6% below the five-year average. Surging demand, depleting inventory, and declining production are the perfect recipe to drive oil prices higher.

OXY Chart

OXY data by YCharts.

Not surprisingly, oil stocks are rebounding sharply. Upstream oil stocks like Occidental Petroleum and Centennial Resource particularly stand to benefit as their average realized prices of oil will flow directly through to their bottom lines and cash flows, and are helping these companies strengthen their balance sheets.

Occidental Petroleum, for example, has a heavy debt load but repaid nearly $3 billion in debt in just the month of July thanks to strong cash flows in its second quarter. Centennial Resource also generated record free cash flow in the second quarter and used it to repay debt, such that it doesn't have any significant debt maturing until 2026.

A swelling war chest also means oil producers are better placed to spend more on capital projects as the situation demands. That directly improves prospects for oil-field services companies like Core Labs, which thrive on higher capital spending (and therefore demand for products and services) from oil producers.

There's another energy group that could benefit from rising oil prices: renewable energy companies. Lower oil prices typically erode the competitiveness for alternative energy sources, and vice versa. So with oil prices surging this week, clean energy stocks are back on investors' radar.

To add to the optimism, the House passed a blueprint of a $3.5 trillion infrastructure bill this week and set Sept. 27 as the deadline to vote on the $1 trillion bipartisan infrastructure bill that has already cleared the Senate. This development has presented investors in clean energy with the perfect opportunity to buy stocks that slumped last week, including fuel-cell stock Ballard Power and renewable natural gas producer Clean Energy Fuels.

Now what

The infrastructure bill is likely to be passed into law in the coming weeks, which should kick off long-overdue spending on America's infrastructure, including clean energy, which should benefit several stocks. Meanwhile, as long as oil prices continue to rise, oil stocks focused on cash flows will make even more money, and that should continue to be reflected in their stock prices.