Bank of America (BAC -3.08%) was among the top performing bank stocks in the second half of 2022, returning 6.4% over the last two quarters of the year. Overall, the nation's second-largest bank was down about 24% in 2022.

As a new year begins, investors may be wondering if the bank stock's momentum from the second half of the year will continue this year amid much economic and market uncertainty. Here are several reasons why Bank of America remains a buy in 2023.

Why Bank of America outperformed in the second half of the year

Bank of America, like many banks, got a boost in 2022 as the Federal Reserve started aggressively hiking interest rates. After raising rates 25 basis points in March and 50 basis points in May, the Fed increased rates by 75 basis points at each of the four meetings that followed. It ended the year with a 50-point rate hike, which puts the Federal Funds rate in the 4.25%-to-4.5% range.

While inflation is starting to tick down, it is nowhere near the range that the Fed is targeting, so expect more interest rate hikes in 2023 and beyond -- albeit at a less aggressive pace. This should help Bank of America in 2023, perhaps more than many of its competitors, for a few reasons.

The first reason is that loan activity should remain robust for the bank, even in an economy that is expected to be slowing, and possibly even going into a recession. The bank reports fourth-quarter and year-end earnings on Friday, Jan. 13, but it expected net interest income to be $1.25 billion higher in the fourth quarter compared to the third quarter. And in the third quarter, loan balances were up 11% year over year. The company is anticipating loan growth in 2023 but tune in to the fourth-quarter earnings call for more guidance on that. The gist of it is, loan growth, combined with rising interest rates, should lead to a boost in net interest income in 2023.

But investors must also consider the deposit beta. Just as banks can charge higher interest rates on its loans, it must raise the interest it pays on deposits. The amount it raises the deposit rate is called the deposit beta. Bank of America's deposit cost, how much it pays in deposits, was among the lowest of the major banks through the third quarter. Bank of America will likely have to raise its deposit costs in 2023 to remain competitive.

Among the 10 largest banks, Bank of America had the second-lowest deposit cost, behind only Wells Fargo, according to S&P Global data. Lower deposit costs typically translate to higher net interest income. This will be something to watch in 2023, but it is a good sign that Bank of America was able to increase deposits by 4% in the third quarter year over year, showing that customers aren't going elsewhere for better interest rates.

Why the stock remains a buy

These factors all contributed to the bank's solid performance in the second half of the year. In 2023, conditions are largely the same, but they remain favorable for Bank of America. It should be able to navigate the rough waters of 2023 much like it did in 2022, with rising net interest income offsetting losses elsewhere.

There is one other positive for Bank of America and that's its credit quality. Through the third quarter it had been able to improve its credit quality in the third quarter, compared to the second quarter, with its net charge-off ratio the same as it was in the third quarter of 2021. Also, its nonperforming loans ratio was 0.4%, down from 0.52% a year ago in the third quarter. Those will be metrics worth watching in Q4 and through the first few quarters of 2023, but overall, the bank has done a good job of diversifying its loan mix over the years, reducing its overall credit risk.

Since 2009, the bank has reduced its percentage of consumer loans from 67% to 44% in 2022. In contrast, it has increased its commercial loans from 33% in 2009 to 56% in 2022.

With a low forward price-to-earnings ratio of 9.3, and a solid and sustainable dividend yield of 2.58% at a 26.9% payout ratio, Bank of America is a good buy right now. It should navigate the choppy waters of 2023 and surge when the economy turns in 2024 or beyond.