We're probably already in a recession. The U.S. economy contracted for the second consecutive quarter, with the gross domestic product (GDP) falling 0.9% in Q2 after a 1.6% decline in Q1. Having two quarters in a row of GDP declines is widely viewed as the beginning of a recession.

Officially, though, the U.S. won't be in a recession until eight economists say so. These economists serve on the National Bureau of Economic Research's Business Cycle Dating Committee.

Investors won't wait until the official declaration of a recession to worry about the stock market. But how does the market perform during a recession? Here's what history shows.

An ugly chart

The S&P 500 doesn't fully represent the entire stock market. It only includes 500 of the biggest publicly traded companies listed on U.S. stock exchanges. However, the S&P 500 has long been viewed as a good proxy for the overall market. And since the index has been around for 65 years, it gives us a way to look at how the stock market has performed in most post-World War II recessions.

There have been 10 official U.S. recessions since the S&P 500 was established in 1957. The following chart shows how the index fared during those periods.

^SPX Chart

^SPX data by YCharts.

The worst S&P 500 decline occurred during the Great Recession, which began in December 2007 and went through June 2009. The index plunged as much as 55% below its previous peak in March 2009.

However, that was a much more severe recession than normal. The average S&P 500 decline during post-World War II recessions is around 29%. This average is skewed, though, in part due to the especially steep sell-off during the Great Recession. The median decline is around 24%.

Unsurprisingly, the S&P 500 has always dropped during a recession. Many companies report lower earnings as consumers tighten their purse strings. Investors often react negatively to any bad news.

The best performance for the S&P 500 during a recession was a 20% decline in 1990. That recession was a short one, lasting only eight months.

A person with hands over their face sitting in front of two screens showing declining stock charts.

Image source: Getty Images.

Two important details

There are two important details related to how the S&P 500 has performed during recessions. First, in many cases, the index declined significantly well before the official start of the recession. Second, the S&P 500 frequently began to rebound well before the end of the recession.

The S&P 500's decline before the start of a recession makes sense. Investors tend to be forward-looking. Most recessions don't come out of the blue, although the COVID-19 recession of 2020 was an outlier.

Investors usually see the signs of a potential recession well before one is officially declared and often become more cautious in advance. This risk-averse psychology can impact stocks before a recession hits.

But this same forward-looking mentality also helps stocks to begin recovering before recessions officially end. Again, the economic improvement that leads to the ending of a recession doesn't usually happen overnight.

Investors watch for hints that a turnaround could be on the way. When they see positive indicators, they begin buying stocks more aggressively. This often causes a bandwagon effect, with even more investors jumping into the stock market.

Reasons for optimism

Looking at the past performance of the S&P 500 should give investors reasons to be cautiously optimistic right now. The index is currently down around 18% and was more than 20% below its previous peak just a few weeks ago. There's not much more room to fall for the S&P 500 to reach the median level of decline during a recession.

More importantly, the S&P 500 has bounced back sharply after every recession we've had. And it often began a major rebound well before the end of the recession.

This bodes well for long-term investors. The current market downturn should provide an excellent buying opportunity for anyone with the patience to hold on for a few years. That's true whether a recession is really on the way or not.