What happened

Financial stocks rallied on Wednesday as investors' fears of an imminent recession were lessened.

By the close of trading, shares of megabanks JPMorgan Chase (JPM 2.03%), Wells Fargo (WFC 1.61%), and Bank of America (BAC -0.34%) were up 4%, 5.8%, and 6.4%, respectively.

So what 

Events in Eastern Europe have led to a sharp rise in the prices of oil, gas, and other commodities. This, combined with the Federal Reserve's indication that it will raise interest rates to combat persistently high inflation, has sparked concerns among investors that the U.S. economy could fall into a deep and prolonged recession.

A bank building.

Image source: Getty Images.

However, oil prices retreated on Wednesday, following reports that other countries might increase oil production to offset the loss of imports from Russia. Lower energy prices would be a welcome relief for businesses and consumers. They could also help to stave off a recession by lowering costs for many companies and boosting consumer sentiment.

That would be a huge relief for the banking industry, whose profits are generally tied to the health of the economy.

Now what 

Stronger economic growth could allow the U.S. market to better withstand higher interest rates. That would be a boon for banks, which typically see their profit margins rise as rates increase. A healthier economy would likely also mean fewer loan defaults, which would further strengthen banks' earnings.

Astute investors know this, and they bid up the prices of banking giants JPMorgan, Wells Fargo, and Bank of America to reflect their more optimistic view of the industry's prospects.