Among real estate stocks, Walker & Dunlop (WD 0.10%) has been a top performer for years. This year, however, has been a different story with the multifamily lender's stock plummeting 45% since January. However, for long-term investors, the sell-off in Walker & Dunlop looks like an excellent buying opportunity.

Interest rates have risen at their fastest pace in decades, which has weighed on the real estate lender's business, compressing margins amid a slowdown in lending markets. Rising interest rates have been a headwind for many in real estate, and Walker & Dunlop is no exception.

Despite the short-term weakness, the company is an excellent stock at an attractive valuation. Here's why I'm bullish on the lender for the long haul.

The top multifamily lender has crushed the market for years

Walker & Dunlop finances apartment buildings and multifamily housing units, and is one of the best in the game. The company has been the top lender through Fannie Mae for three consecutive years and is on pace to retake the top spot this year.

Its eye-opening growth in the multifamily lending space makes it stand out. From 2011 through 2021, Walker & Dunlop's transaction volume, or the total amount of debt financing it provides, grew from $4 billion to over $68 billion, or 32% compounded annually. During this period, its total revenue and diluted earnings per share have compounded annually by 24% and 18%, respectively. As a result, the company has crushed the real estate sector and S&P 500 index's returns.

WD Total Return Level Chart
Data by YCharts.

Rising interest rates have put pressure on its earnings

Companies that lend money have had a tough go of it in 2022. Inflation has remained elevated for much of the year, and the Federal Reserve is using its primary tool -- interest rates -- to bring it down. Since March, the Federal Reserve has raised its benchmark rate, the federal funds rate, from near zero to an upper limit of 4%. This rapid interest rate increase has weighed on companies across different lending markets.

For Walker & Dunlop, that means its gain on sale margin, or the difference between originations and mortgage servicing margins, compressed, going from 1.65% last year to 1.23% this year. This translates into pricing pressure that has resulted in lower profits for the lender. 

Usually, the gain on sale margin shrinks due to increased competition. However, the compression this year is caused by the rapid increase in interest rates. According to CEO Willy Walker, the pressure on margins should decrease when the Federal Reserve stops raising interest rates aggressively. 

The Fed has raised its benchmark rate by 75 basis points in its last five meetings. However, based on the CME FedWatch Tool, the market expects the Fed to raise rates 50 basis points in December and 25 basis points during February and March of next year until stopping at around 5%. This leveling out of rates would remove some of the pressure Walker & Dunlop has faced this year.

Its affordable housing mission could solve a crucial problem and drive profits for the lender

Affordable housing has become a critical issue in the U.S. According to the National Low Income Housing Coalition, 6.8 million affordable housing units are needed for extremely low-income families. Not only that, but 70% of all extremely low-income families pay more than half of their income on rent. 

Fannie Mae and Freddie Mac are focused on tackling this problem, and this year 50% of their multifamily lending funds must go toward "mission-driven affordable housing units." Additionally, the Federal Housing Finance Agency has proposed that these government-sponsored agencies boost this target to 61% of their multifamily loans over the next two years. 

As the No. 1 Fannie Mae lender and the No. 5 Freddie Mac lender, Walker & Dunlop is in a prime position to capitalize. From 2019 to 2021, the multifamily lender financed 263,000 affordable units and completed $22 billion in affordable lending projects. 

Long-term, Walker & Dunlop's goal is to finance $60 billion in affordable housing by 2025. To reach this goal, it purchased Alliant Capital, the sixth-largest low-income housing tax credit syndicator in the U.S., for $700 million last year. 

An excellent stock to buy and hold

This year, Walker & Dunlop has hit a speed bump due to rapidly rising interest rates. The stock's sell-off has brought it down from a high price-to-earnings ratio of 18.7 earlier this year to 10.9 -- just under its 10-year average.

The lender is in an excellent position to capitalize on the numerous refinancings needed in the multifamily space in the coming years. Its focus on affordable housing should help fortify its already strong position as a top lender through Fannie Mae and Freddie Mac -- making this a stellar real estate stock you can buy and hold for the next decade and beyond.