Predicting what will happen in the stock market is hard.

Nope, scratch that. It’s pretty much impossible.

But in light of the looming November vote, we took a look at what happened in the markets over the past few decades in relation to US presidential elections.

However, before we get to that, we would like to emphasize that when it comes to markets, the past does not predict the future.

And so we are not making any predictions here about what will happen on the morning of November 9, 2016, or thereafter. (And if someone says they have a foolproof way of doing that, that’s a sign to run. Quickly.)

Still, it's an interesting exercise to sift through historical data.

How stocks reacted after previous elections

Princeton economics professors Alan Blinder and Mark Watson wrote a paper exploring the US economy's performance with respect to US presidents, dating back to Harry Truman. One thing they looked at was what happened in the markets during the lame duck session between an election and the inauguration of the new president.

"The performance of the stock market between Election Day and Inauguration Day might be taken, in part, as a statement of investor confidence - or lack thereof - in the incoming administration," they wrote.

As for the numbers, they noted:

"It gives a slight edge to incoming Republicans, despite the fact ... that stock prices actually rise much faster under Democratic presidents than under Republican presidents. Specifically, the S&P 500 gained a minuscule 0.15%, on average, during the four Democrat-to-Republican transitions, but lost an average of 1.38% during the four Republican-to-Democrat transitions.

"However, more than 100% of the average Democratic transition loss came because stock prices were crashing during the Obama transition. Since the economy was collapsing at the time, it is hard to attribute this drop to lack of confidence in Barack Obama."

Which brings us to the next topic: Democrats vs. Republicans

The stereotypical line of thinking is that Republicans are "better for the markets" because they tend to push for more pro-business policies, such as lower taxes and less regulation. However, as Blinder and Watson noted, the stock market has historically performed better under Democratic presidents.

In fact, analysts at S&P Capital IQ have looked at the average annual returns of the S&P 500 under American presidents since 1945 and found that the average annual gain under the blues was 9.7%, while under the reds it was 6.7%.*

Moreover, according to the analysts, the only two presidents who saw negative market returns during their tenure were Republicans: Richard Nixon, who was in office during the Arab oil embargo, and George W. Bush, who closed out his second term as the financial crisis of 2007-08 mutated into the Great Recession.

Screen Shot 2016 09 26 at 2.15.11 PM

Foto: sourceCapital Economics

Taking it a step further, John Higgins, Capital Economics' chief markets economist, argued in a note to clients a few weeks ago that both poor and good stock performance in the year before or after an election had less to do with the president's party and more to do with what was going on in the actual economy.

After all, no president inherits a blank canvas.

"The poor performance of the S&P 500 in the year after each of the four presidential elections that took place between 1968 and 1980 can largely be attributed to the weakness of the economy during this period, rather than to the domination of the branches of US government by one political party," Higgins wrote.

"By the same token, the strong performance of the stock market in the year after each of the last two presidential elections in the 1980s was not due to a big shift in the balance of political power. Rather, it reflected a rebound in its valuation from a depressed level, as economic fortunes improved," he added.

spx vs obama

Foto: sourceAndy Kiersz/Business Insider

As for Obama, he took office the year after stocks lost nearly 40%. And notably, days before stocks touched an intraday low of 666 in early March 2009, the president noted, "What you're now seeing is profit and earnings ratios are starting to get to the point where buying stocks is a potentially good deal if you've got a long-term perspective on it."

Stocks are up by about 209% since he said that.

"The strong performance of the index in 2009 was not due to the election of President Obama and retention of a Democrat-controlled Congress in 2008," Higgins wrote. "It resulted instead from a recovery in the economy after the Great Financial Crisis."

So what does this mean for November 8?

"The result of that election is unlikely to have a major bearing on the performance of the US stock market, if history is a useful guide," Higgins wrote. "Economics will matter more than politics."

OK, but Donald Trump is an atypical candidate who has unorthodox economic ideas...

It's a truism that markets don't like uncertainty. As the market sees it, Hillary Clinton is a known player whose policies are expected to be largely a continuation of the current administration.

Trump and his economic positions, however, are less predictable and do not always follow party orthodoxy: He is for tax cuts and deregulation, but against free trade. Thus, he is perceived as more of a "political risk" in the market.

Notably, The Wall Street Journal's Justin Lahart recently reported that the forecasting firm Macroeconomic Advisers "found that investor perception of stock-market risk rose with Mr. Trump's estimated chance." The firm even suggested that should Trump win, the S&P 500 could tumbled by 7%, while if Clinton wins, it would rise by 4%.

However, it's perhaps useful to also consider what happened in the markets after other political shocks, as opposed to looking only at what happened after so-called typical US elections. Specifically, we focus on Brexit - whose populist-movement underpinning draws at least some parallels to the rise of Trump - as well as the Tiananmen Square protests.

screen shot 2016 06 27 at 7.53.40 am

Foto: sourceCredit Suisse

In the immediate aftermath of both Brexit, in June, and the Tiananmen Square protests, in 1989, markets were in chaos.

On the Friday after Britain voted to leave the EU, the S&P 500 and the Dow both wiped out all of their gains for 2016, while Nasdaq fell by over 4% -the biggest one-day drop since 2011.

During the Tiananmen Square protests, the Hang Seng fell 22% in a single day, and lost 37% from its peak.

That sort of emotional response to a political shock is actually quite typical of investor (and, more broadly, human) behavior. Unexpected and potentially destabilizing political events tend to make traders and investors nervous, which then sometimes leads to volatility in financial markets. But as history has shown time and time again, these events generally do not have a sustained impact on markets.

Last year, Credit Suisse's head of research and deputy global CIO, Giles Keating, and his team reviewed data on major geopolitical events in the previous 100-plus years and found that stocks generally bounced back up after these shocks.

"The large majority of individual major events - ranging from the assassination of Archduke Ferdinand 100 years ago through to 9/11 and recent events in Iraq and Ukraine - impact major stock markets by around 10% or less, with the effect being fully reversed within a month or so," he wrote in a note to clients. "This suggests that the most profitable strategy has usually been the contrarian one of buying into price falls caused by such incidents."

For what it's worth, stocks ultimately bounced back after the Brexit crumble, which you can see below. Meanwhile, the Hang Seng climbed back to its peak over the year after the Tiananmen Square protests.

brexit

Foto: source Andy Kiersz/Business Insider

But let's be real: There's no magic button, regardless of who wins

Yes, investor sentiment in the immediate aftermath of the election can affect the market. And, yes, presidential policies affect the economy, which then in turn can affect the markets.

However, there are a bunch of other factors not wholly connected to presidential policies - such as oil-price shocks, productivity shocks, and things like China's devaluation of its currency - that all influence what happens with the stock market. Plus, we should note that the US stock market is not the US economy.

In any case, as an endnote, perhaps the most telling historical nugget with respect to the relationship between presidents and the stock market (or lack thereof) is the following, via the S&P Capital IQ's analysis:

Stocks saw their best gains under Republican Gerald Ford - but he wasn't elected president, and he wasn't even the original vice president on Richard Nixon's ticket in 1972.

*We should note that different studies have yielded slightly different numbers for returns, depending on start date and other factors, but we decided to go with the S&P Capital IQ because it's a division of S&P Global.