In this year's first quarter, the U.S. financial system endured the second- and third-largest bank failures in its history. Troubled global bank Credit Suisse was forced into a sale. Finally, the yield curve became more inverted than at any time since 1981, a sign of market pessimism and a very unfavorable setup for banks.

But none of that stopped JPMorgan Chase (JPM 3.55%), the largest bank by assets in the U.S., from generating record revenue, superb profitability, and an absolutely blowout quarter. Diluted earnings per share of $4.10 on revenue of more than $38.3 billion blew past analysts' estimates. Here's how the bank managed to pull off this impressive feat.

Deposits fared better than expected

The big concern for all banks heading into this earnings season was deposit outflows and deposit costs, because risk-free assets like U.S. Treasury bills are yielding 4% to 5% and customers have been shaken by the recent banking crisis.

But as the largest bank in the country and one that is certainly too big to fail, JPMorgan Chase became a port in the storm, one where commercial, business banking, and wealth management clients sought a safe haven. 

While average deposits in the quarter fell 3% from the prior quarter, period-end deposits grew 2%, which shows that the bank saw a reversal in deposit trends toward the end of Q1, when the banking crisis occurred. CFO Jeremy Barnum said on the company's earnings call that the bank retained about $50 billion of these inflows, although how long these deposits stick around is a bit of an unknown at this point.

The better-than-expected deposit trends allowed the bank to generate better net interest income (NII), which is the money banks make on loans and securities after funding those assets with funding such as deposits. NII grew 3% in the quarter and was up a whopping 49% year over year. JPMorgan Chase's consumer and community bank (CCB) had roughly $1.4 billion of credit costs for expected loan losses and reserve building and still managed to generate an astounding 40% return on equity.

Tailwinds from trading

What makes JPMorgan such a great company is the balance it has between its CCB and the corporate and investment bank (CIB).

CIB houses JPMorgan's investment banking and trading operations and has helped make the bank incredibly resilient during various cycles because at least parts of this business tend do well when there is extreme market volatility, which can make life difficult for CCB. For instance, during the early part of the pandemic, JPMorgan had to set aside billions for potential loan losses that might arise from the economy shutting down. This cut into earnings at CCB, but all of the market volatility at the time led to a boom in trading and investment banking, which helped power the bank through some of the most difficult parts of the pandemic.

While CCB performed very well in the first quarter, JPMorgan also got another boost from its trading business. Fixed-income trading jumped 52% and was flat on a year-over-year basis, while equity trading was up 39% from the prior quarter and down about 12% year over year. The year-over-year numbers don't look as good but that's because trading in Q1 of 2022 was so strong.

The surge in trading during the period looks to be a result of the market rally early in the quarter, as well as changing interest rates that drove activity in fixed-income trading.

An improved outlook

The better-than-expected quarter from JPMorgan also came with raised guidance. It now believes deposit pressure will be more manageable and has significantly boosted its projections for full-year NII.

Furthermore, while management is keeping a watchful eye on credit, which is expected to continue to normalize, there are no meaningful signs of deterioration yet, at least based on last quarter's numbers.

Although there is still a lot that can happen in the banking sector, the fact that JPMorgan could have this strong of a quarter during such a difficult time for the sector shows why it is best-in-breed. If you are looking for a sturdy bank stock that has the ability to thrive in many different economic environments, then look no further than JPMorgan Chase.