Will Democrats hang onto control, or can Republicans take Congress? If history is any guide, it won’t really matter for stocks because markets typically surge once election uncertainty is lifted.

Stocks are off to a rocky start so far this year thanks to a laundry list of challenges including inflation spikes and interest rate hikes. Midterm elections in November are going to make 2022 even trickier by adding yet another layer of uncertainty to the investing mix.

Consumer prices are surging with inflation at nearly 40-year highs, supply chain issues continue to persist and coronavirus cases are spiking due to the Omicron variant. What’s more, the Federal Reserve has started tightening monetary policy in a bid to control inflation: Once the central bank finishes tapering its monthly asset purchases in March, it intends to hike interest rates three times later this year–something it hasn’t done since 2018.

“The worst that can happen for Democrats is if they lose control over both houses of Congress. In that case the market would win by losing, and see a slightly improved average performance.”

— Sam Stovall, chief investment strategist at CFRA Research

Come November, Republicans are hoping to win back control of either the House of Representatives or the Senate. They’ll need five seats to win a majority in the House and one seat in the Senate. Pennsylvania, Wisconsin, Arizona, Georgia and Florida all have key elections that could determine whether or not Congress flips.

“The most favorable outcome for markets would be a Republican win in both the House and the Senate,” says Jeremy Siegel, the Russell E. Palmer Professor of Finance at the Wharton School of the University of Pennsylvania. “If Republicans take the House and not the Senate, that would also be a relatively favorable outcome.”

To find out how various election results would impact stocks, Forbes analyzed market data going back to 1945 with the help of CFRA Research.

In short, when it comes to stock market performance, Democratic presidents have an edge. From 1945 through the end of 2021, the compound annual growth rate for the S&P 500 has been 9.4% under Democratic presidents compared with 6.6% for Republican commanders-in-chief.

The best returns, however, have come under Democratic presidents kept in check by a split or Republican Congress. “Historically, investors prefer shared power across the Federal government,” says RSM chief economist Joe Bruseulas.

For instance, President Barack Obama faced a split Congress from November 2010 to 2014, with Republicans holding the House of Representatives while Democrats held the Senate. Equity investors weren’t complaining: The S&P 500 surged nearly 70% during that period.

Screen Shot 2022-01-19 at 12.43.39 PM.png

The S&P 500 average return in years where Democrats have simultaneously held the Oval Office and both houses of Congress is 10.5%. While those returns are nothing to balk at, the best-case scenario for investors—with a 13.6% average gain for the S&P 500—is when a Democratic president is presiding over a split Congress. The second-best performance, with a 13% average gain: A Democratic president working with a unified Republican Congress.

“The worst that can happen for Democrats is if they lose control over both houses of Congress,” says Sam Stovall, chief investment strategist for CFRA Research. “In that case the market would win by losing—meaning that Wall Street will see a slightly improved average performance.”

One thing to consider if Democrats lose: Less government spending. President Joe Biden and Democrats will be significantly less likely to pass big legislation if Republicans gain control of either the House or Senate. Markets often like big government spending. Consider that stocks surged after the Biden administration passed its $1.2 trillion infrastructure bill last November while stimulus spending gave markets room to run as the S&P 500 gained 26% in the 12 months following March 2020.

Democrats’ latest piece of budget legislation, the Build Back Better Act, includes more infrastructure and climate spending but has been stalled for months after stalwart opposition from Senator Joe Manchin (D-W.Va). With midterms looming—and Democrats’ prospects not exactly looking rosy—BBB would need to be pushed through before November since it’s unlikely to pass if Republicans take the House or Senate. That means less spending for markets to bank on.

So, how will stocks fare between now and November? Years with midterm elections tend to have weaker stock market returns overall. The second year of a presidential cycle has some “unique characteristics and none of them are favorable for investors,” says James Stack, president of InvesTech Research and Stack Financial Management.

Screen Shot 2022-01-19 at 12.43.59 PM.png

The second years of presidential terms, which Stovall refers to as the “sophomore slump,” produce the lowest average S&P 500 return—just 4.9%. Further, the second and third quarter of midterm years result in the worst returns, declining on average 1.8% and 0.5%, respectively.

2022 could be worse than average given worries about inflation, Covid variants, supply chain delays and the Federal Reserve’s tightening monetary policy. “There’s nothing that the market dislikes more than uncertainty—and that will lead to an increase in volatility, especially in 2022,” says Stack who emphasizes that monetary policy could spook markets even more than expected thanks to the Fed’s plan to rapidly shrink its balance sheet.

“Risk has seldom if ever been higher from a valuation standpoint—and now that’s significantly increasing from a monetary standpoint,” he says.

There is some good news on the horizon though. Historical data shows that the fourth quarter of midterm years and first quarter of the following year boast the two strongest returns of the entire presidential cycle, rising 6.1% and 7.5% on average, respectively. “By then we will also have had at least one if not two interest rate hikes and investors will realize the world hasn’t come to an end,” Stovall says.

Screen Shot 2022-01-19 at 12.47.01 PM.png

The equity party continues well into a president’s third year in office when there’s a push to stimulate the economy ahead of the next election. It’s no coincidence that the best market returns come during that period; the S&P 500 rises an average 16% in that third year. What’s more, in the six months after midterm elections—from November to April—the S&P 500 has gained 14.3% on average and has risen in price 95% of the time.

“Very often you'll see a positive reaction to midterm elections regardless of which party wins,” says Stack.

By Sergei Klebnikov, Forbes Staff

© 2022 Forbes Media LLC. All Rights Reserved

This Forbes article was legally licensed through AdvisorStream.