We're officially in a recession due to the COVID-19 pandemic, and while that news may not be shocking, it's unsettling nonetheless. Right now, unemployment levels are at a high, and while the stock market has recovered a lot of the value it lost back in mid-March, when it plunged into bear market territory, we've seen more recent volatility that's left even seasoned investors rattled.

Speaking of investing, you'd think buying stocks would be off the table at a time when the country is deep in the throes of a crisis, but actually, that's not true at all. It often pays to invest during a recession, because that's when stock prices tend to drop, making otherwise out-of-reach investments suddenly affordable. But if you're going to invest during a recession, you need to do it under the right set of circumstances, which is why there's one important item you must check off your list before buying stocks when the economy is down: Complete your emergency fund.

Stack of hundred-dollar bills on wooden surface

Image source: Getty Images.

Before you invest, have near-term cash on hand

You never know when a personal financial emergency can strike, so as a general rule, it's wise to have three to six months' worth of living expenses tucked away in a savings account. During a recession, it's smart to aim for the higher end of that range so that if you lose your job and it takes a long time to find a paycheck again, you won't risk resorting to debt or other drastic measures, like liquidating stocks at a loss.

Imagine you don't have much money set aside for emergencies, and you find yourself out of work. Suddenly, you may be forced to cash out investments from your stock portfolio to get your hands on money to pay your bills. That's not such a terrible thing if your investments aren't down, but if they've lost value and you liquidate them, you lock in those losses permanently.

That's why you must have a solid emergency fund before investing in general, and this especially holds true during a recession, when jobs are more likely to be lost and stock market declines can take longer to recover from. In fact, any money you invest in stocks should be money you don't plan to access within the next seven years. That way, if your portfolio loses value, you'll be better positioned to ride it out.

Set yourself up for success

Though recessions go hand in hand with economic uncertainty, they're also a good time to invest -- if you set yourself up with enough near-term savings first. Make sure your emergency fund is complete, and once it is, feel free to load up on stocks. At the same time, though, take a long-term, patience-driven approach to investing, because during a recession, stocks' values can flip-flop enough to drive you crazy. Buying quality stocks and holding them for years is a good way to come out ahead in the stock market and avoid losses, and that mentality is especially important at a time when things are anything but stable.