If you've spent any time reading about personal finance, you've probably had the importance of building an emergency fund drilled into your head. Having an extra $1,000 or a few months' living expenses that you can quickly access when your regular paycheck can't cover the bills can prevent you from taking on high-interest debt.

But many people -- even the experts -- are thinking about emergency funds all wrong.

Emergency funds get put on a pedestal, as if they're more important than any other liquid assets a person might hold.

Sure, it's important to have funds you can access in case of emergencies, but when you get a big hospital bill, or your car breaks down, nobody's going to tell you they only accept money from your emergency fund.

Cash is fungible.

That's why it's important to consider emergency funds as part of your total asset mix. And if you're holding a significant portion of your portfolio in cash, just in case of emergencies, you're missing out on a big opportunity to invest.

A jar labeled Emergency filled with coins

Image source: Getty Images.

Emergency funds are all about safety

The reason the experts recommend sitting on a pile of cash is because it's considered safe. It would take a catastrophe for you to wake up one day and find your $20,000 emergency fund has suddenly dwindled to $10,000. If your emergency fund is held in an FDIC insured account, you can rest assured your money will be there when you need it.

Indeed, if you have no other assets and you just want to ensure your money is there when you need it, holding a bunch of cash is the way to go.

Things get more complicated, though, when you factor in that most financially savvy people are also saving for long-term goals like retirement. Long-term goals require long-term thinking, which means investing in assets with higher average returns, like stocks and bonds.

A pile of cash is a big drag on those returns.

However, while the stock and bond markets might produce better returns than cash over the long run, those returns don't follow a straight line. There's a lot more risk of having to pull money out of the market after your portfolio has seen a considerable decline in value if you're investing your emergency fund.

But there's a way to mitigate the risk involved with investing while maximizing long-term returns.

All about asset allocation

There are a whole bunch of different types of assets and investment vehicles you can buy, but to keep this article simple, I'm only going to discuss three: stocks, bonds, and cash.

In terms of safety, cash is king. But if you want long-term returns, you can't do much better than stocks. Bonds offer a middle ground of better returns than cash, and less volatility than stocks.

But what makes things really interesting is that the annual returns of stocks and bonds are, historically, negatively correlated. That means when stock market prices decline, bond prices increase, and vice versa. Meanwhile, cash remains practically unaffected by market forces.

That negative correlation between stocks and bonds makes it possible to construct a portfolio with greater safety and better average returns than holding onto cash in a lot of cases.

Meet Adam and his $20,000 emergency fund

Adam listened to the financial experts and diligently saved up six months of his expenses -- $20,000 -- in an emergency fund. That money is currently sitting in a savings account.

Adam also has an $80,000 investment portfolio, and since he has a very long investment horizon, that's all invested in stocks.

Overall, Adam's total asset mix is 80% stocks and 20% cash. If the stock market returns an average of 10% per year and the savings account offers 1% interest, Adam can expect a total return of 8.2% per year . Note, that 8.2% return carries 80% of the risk of the stock market's expected returns.

Asset class Expected return Allocation Expected return as a percentage of total portfolio
Stocks 10% 80% 8%
Cash 1% 20% 0.2%
Total     8.2%

Table source: Author

Adam could get better returns by moving his 20% cash holdings into 10-Year Treasury Bonds. Currently, 10-Year notes currently yield about 2.8%. So, the expected return on Adam's new portfolio is 8.56%.

Bonds carry more risk than cash , but since the return for bonds is negatively correlated with the return on stocks, Adam's new portfolio actually has less risk than when he was holding $20,000 of cash. That's because if the value of his $80,000 in stocks declines, he expects his $20,000 in bonds to increase in value to help offset some of those losses. If he was holding cash, the value wouldn't increase at all.

Adam can maximize his expected returns and keep the same level of risk as when he was holding $20,000 of cash by investing a bit more in stocks and a bit less in bonds. Based on the stock-bond price correlation over the past five years , Adam's optimal asset allocation would be about $82,000 in stocks and $18,000 in bonds. That would produce an expected return of 8.7% while maintaining the same risk profile as before. That's an extra $500 per year on his $100,000 portfolio compared to when he held $20,000 in cash.

The math will work out differently for each person based on their current assets and their risk tolerance.

A red box with In Case Emergency printed on top

Image source: Getty Images.

What to do in case of emergency

If your emergency funds are mixed in with all your other investments, it might make it difficult to determine how to pull out cash when you need it.

It might be tempting to only sell assets that have appreciated, because human nature makes us averse to taking losses. Or you could run the calculations to determine a new asset allocation based on what your risk profile would look like if you used a cash emergency fund to pay your bills, which would have you sell more bonds and less stock.

But the simplest way to handle an emergency is to maintain the same asset allocation you determined in your prior calculations . Sell a proportionate amount of stocks and bonds to make sure you keep the same balance between the two in your overall portfolio. So, if Adam had a $10,000 emergency, for example, he would sell $8,200 in stocks, and $1,800 in bonds to keep his allocation the same.

It's not like emergency funds are one-time use. After you deplete your emergency fund to pay unexpected bills, the next step is to build the emergency fund back up. Maintaining your asset allocation saves that step, and you can build back up to your prior balance before tilting the balance toward more stocks if you want to take on more risk.

What about when you're just starting out?

When you're first starting out and don't have any savings at all, the safest place to put your money is in a savings account. If you're truly worried about preserving capital, there's just no better option.

But you'll be sacrificing your long-term savings to build that emergency fund. And another common piece of personal finance advice is to start saving for retirement as early as possible.

For those focused on building a cash emergency fund before they start saving for retirement, they could be waiting a long time.

The average savings rate in the United States is a paltry 3.8% of their disposable income . At that rate, it would take over six years to build a three-month emergency fund. Even at the personal finance experts' suggested 15% savings rate, it'll take 17 months to build up a three-month emergency fund, or nearly three years if you go for a six-month emergency fund. That's too long to delay long-term savings, if you ask me.

However, early savers may want to use a more conservative asset allocation (more bonds, less stock) as they start out and slowly move to a more aggressive portfolio. They face the same sequence of return risk as people in their early years of retirement since they'll be using their portfolios in similar manners.

Where to keep your emergency funds

If you're going to be investing your emergency funds, you'll need to use some kind of brokerage account. But there are all kinds of different accounts with different tax implications you can use.

A taxable brokerage account is the simplest way to go. You'll be able to access your entire portfolio holdings at any time, but you may have to pay capital gains taxes when you liquidate assets to pay for an emergency or rebalance. That can provide a false sense of how much your emergency fund is actually worth.

If you otherwise wouldn't max out your IRA, a Roth IRA presents an interesting option. You can withdraw contributions to a Roth IRA tax free at any time, but the gains are locked up until you reach retirement age (when they can be withdrawn tax-free as well). The maximum contribution to a Roth IRA is $5,500 per year, and there are other limitations that may impact you as well.

Finally, if you have a high-deductible health insurance plan, you may be eligible to use a Health Savings Account with an attached brokerage account. HSAs offer tax-deductible contributions, tax-free growth, and tax-free withdrawals on medical expenses. Note, HSA funds aren't very useful for car repairs, but they can be a (literal) lifesaver if you have an unexpected medical emergency.

Is investing your emergency fund right for you?

Moving your emergency fund from cash to stocks and bonds isn't for everyone. If you don't think you'd be able to sleep at night without a pile of cash in your savings account, then by all means, keep your emergency funds in cash. A few extra points of returns isn't worth losing sleep over.

Note, if you have any outstanding high-interest debt, you should pay off the balance as quickly as possible. There's no sense of building an emergency fund to ensure you don't go into debt if you're already in debt.

If you already have a fairly conservative asset mix, holding cash may be the optimal solution to maximizing your returns while staying within your risk tolerance.

But if you think long term and want to maximize the returns of your entire asset holdings, you should consider investing the cash in your emergency fund into the right mix of stocks and bonds for your risk tolerance. It'll require you to look up some statistics and do some math, but it's not very difficult, and it could result in a much bigger portfolio balance when you're ready to retire.