You don't make money buying good stocks when everyone is heaping praise on them. You make money buying when there is "blood in the streets" and investors are worried about the future. Well, that moment may have happened for Charles Schwab (SCHW 0.19%). The leading online stock brokerage has been a 100-bagger for long-term investors -- crushing the broad market returns since going public -- but has found itself off 42% from all-time highs in 2023.

Investors are worried about how rising interest rates and held-to-maturity (HTM) mortgage securities will affect Schwab's earnings power in the years to come. That's presenting a major headwind for Schwab's business right now. The company clearly made some mistakes when interest rates were at zero and was not prepared for the Federal Reserve to start hiking the Federal Funds Rate.

Short-term pain could continue for Schwab, but does this discounted price present a buying opportunity for investors focused on the long term? Let's take a look.

The good: Integrating a merger, retaining customer assets

While we started with the bad, Charles Schwab has a lot of things going for it as one of the largest online stock brokers in the world. It continues to attract funds from individuals and institutions, with organic asset growth of $248 billion through the first nine months of 2023, or 6% year-over-year growth. More assets and scale mean more fees, interest income, and other revenue streams that Schwab can earn from these customers. Growing client assets is one of the key metrics to measure the health of Schwab's business.

Outside of organic growth, Schwab is still integrating its huge acquisition of TD Ameritrade, which was closed a few years back. Last quarter, it transitioned 3.6 million retail accounts and 7,000 investment advisors over to Schwab, or a $1.3 trillion transition. Apparently, the transition went through with few hiccups, which should mean a sigh of relief for Schwab shareholders. Now, the company plans to lower its expenses with all its assets on one platform, with the potential for $1 billion in cost savings.

Wealth management fees and trading costs -- which is what these assets drive -- are a huge part of Schwab's business. Through the first nine months of 2023, the combined segments made up approximately 42% of the company's consolidated net revenue.

Where does the other 58% of revenue come from? Well, that's where the problem lies.

The bad: Rising interest rates, bad loans stuck on the balance sheet

The largest segment of Charles Schwab's business is the net interest income it earns on client deposits. Acting as a bank, Charles Schwab takes the money its customers give it and puts it in U.S. Treasuries, bonds, and other interest-earning assets. When the Federal Reserve had interest rates at zero, Charles Schwab did not have to pay its depositors much in interest income to keep them around. However, with rates shooting up to 5%, customers have been shuffling assets around in search of places with higher yields, forcing Schwab to pay more to retain customers. A lot of customers are also putting cash in money market funds.

How does this look financially? Even though the gross interest revenue Schwab earned so far in 2023 shot up to $12 billion compared to $8.4 billion in 2022, the company's net interest income fell from $7.7 billion to $7.3 billion. While that's not a huge change, it shows the headwind the company has faced and could continue to face over the next few years if interest rates stay elevated.

Perhaps a bigger headwind is the $162 billion in HTM securities sitting on its balance sheet in mortgage securities. These HTM assets are loans that Schwab isn't required to write down, but only if it decided to hold them "to maturity" and not sell them in the open market (hence the moniker).

These mortgage securities are only earning an annual interest rate of 1.72% and would likely have huge write-downs if forced to be reevaluated on the open market. This interest rate is only slightly lower than Schwab's average cost paid to depositors and is significantly lower than the loans it has taken out on its corporate balance sheet to manage its liquidity. With the long-term duration of these mortgage loans, these HTM securities will remain a headwind for Schwab for many years.

SCHW PE Ratio Chart

SCHW PE Ratio data by YCharts

Is the stock cheap?

Even though Charles Schwab has major balance sheet issues, I think shareholders will do well owning this stock if they have a five-year or longer time horizon. With trillions in assets, the government would likely never let Charles Schwab fail due to the pain it would cause across the economy. It has seen no risk of customers leaving the platform, unlike other smaller and less prestigious brokerages. Schwab is known as a safe and boring brand, which is what investors want during volatile times.

Yes, its net interest income headwinds will continue, but there are two things that should alleviate these investor concerns. First, it has a diversified business in wealth management and trading fees, on which higher interest rates have no direct effect.

Second, it looks like the Federal Reserve is done hiking interest rates, which means Schwab's headwinds may not get any worse. Inflation just came in for October much lower than analysts expected, with 0% month-over-month growth in consumer prices.

At its current stock price, Charles Schwab trades at a price-to-earnings ratio (P/E) of 18. This is only slightly below the market average, which might make you think the stock is not cheap. However, investors should remember that Charles Schwab is underearning right now due to all the factors discussed above, which could present an opportunity if you think its net income will start growing again. It is currently off around 20% from highs.

There could be some more short-term pain, but if Schwab gets through to the other side of these interest rate headwinds and can realize the cost savings from the TD Ameritrade merger, its net income should start growing again.

Add all this together, and Charles Schwab's P/E may be much lower a few years from now, making the stock a good bet at this discounted price.