Bank of America (BAC 3.35%) 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 26% 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 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 (0.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 that banks charge each other for overnight loans in the 4.25%-to-4.5% range.

Although inflation is starting to tick down, it is nowhere near the 2% range 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 forecast to slow, and possibly even go into a recession. The bank reported fourth-quarter and year-end earnings on last Friday, and revenue and earnings topped analysts' forecasts. The company is anticipating loan growth in 2023, which along with rising interest rates, should lead to a boost in net interest income in 2023.

Investors must also consider the deposit beta. Just as banks can charge higher interest rates on loans, they must raise the interest paid on deposits. The amount a bank raises interest rates on deposits is called the deposit beta. Even though in the fourth quarter Bank of America raised its interest-bearing deposit costs from 0.40% in Q3 to 0.96%, that is still among the lowest for big banks. Nevertheless, Bank of America will likely have to continue to raise its deposit costs in 2023 to remain competitive.

Among the 10 largest banks, Bank of America had the second-lowest deposit cost in the third quarter, 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 average deposits in consumer banking by 2% year over year to over $1 trillion in the fourth quarter. This suggests 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, and they remain favorable for Bank of America. It should be able to navigate the rough waters of 2023 much as it did in 2022, with rising net interest income offsetting any losses elsewhere.

There is one other potential positive for Bank of America and that's its credit quality. Its net charge-off ratio rose in the fourth quarter, but its nonperforming loans ratio dropped. Those will be metrics worth watching 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% of the total 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.5, and a solid and sustainable dividend yield of 2.6% 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.