The Trump rally, a trade war, and then a crippling pandemic: The four years since President Donald Trump's 2016 election victory have been a period like no other for the U.S. stock market.

Hours after Trump's unexpected win on Nov. 8, 2016, expectations of massive tax cuts and financial deregulation kicked off a stock rally that saw the S&P 500 .SPX surge 5% in a month. Wall Street continued its path higher through a trade war and impeachment, going on to new record highs following a deep slump caused by the coronavirus pandemic that continues to cripple the global economy.

Graphic: Trump timeline here

The Republican president has claimed credit for the rise, tweeting over 150 times about the stock market since he was elected, often when stocks were climbing.

Graphic: Trump tweets as Wall St climbs here

Despite recent volatility, the stock market has risen strongly during Trump's term, with the S&P 500 up over 50% since the November 2016 election, more than in the four years following Democrat Barack Obama's first election win in 2008.

The technology sector has surged over 150% since Nov. 8, 2016, by far the strongest performer during that time, while the energy sector, which Trump has championed, has lost over half of its value. In the four years following Obama's 2008 win, consumer discretionary led, up 103%, while financials dropped 2%.

Graphic: S&P 500 sectors in first terms: Trump vs Obama here

The S&P 500's performance since Trump's 2016 election has also been above average for presidents since the 1980s. Overall, the strongest stock market performance since the 1980s was under Democratic President Bill Clinton, while the weakest was under Republican President George W. Bush. However, stock market performance over the past four decades reflects no obvious benefit from Republican versus Democratic presidents.

Graphic: U.S. stocks under different Presidents here

While Trump's presidency has been a wild ride for investors, other presidential terms have seen greater volatility. Stock market volatility since the start of the 1980s hit a high during the four years after Obama's first victory, before settling down in his second four years. It did rise moderately again under Trump.

For those looking for stronger gains ahead, a Trump win may be a favored outcome. Suggesting that investors favor the certainty of presidents they are already familiar with, the S&P 500 since 1950 has on average risen 9.6% in the year after presidents win re-election, compared with an average rise of 4.8% in the year following the election of new presidents, according to LPL Financial.

The S&P 500's performance might predict the next president.

Going back to 1944, incumbent presidents, or presidents from incumbent parties, won elections 82% of the time when the S&P 500 was positive in the three calendar months prior to Election Day, according to Sam Stovall, chief investment strategist at CFRA in New York. The S&P 500 is up less than 1% from July 31, with that historical pattern barely favoring Trump winning the upcoming vote.

However, with the coronavirus pandemic, the crippled economy and pandemic relief discussions front and center on Wall Street, the S&P 500’s recent gains may be a less accurate reflection of investors' view of the election outcome this time around. The S&P 500 tumbled over 3% on Wednesday, with investors blaming a global surge in coronavirus cases.

"If the market's focus is on the recovery from COVID, then that may take precedence over retaining the current administration," Stovall said.

Graphic: Stock market swings under different Presidents here

(Reporting by Saqib Ahmed and Noel Randewich, additional reporting by Stephen Culp; editing by Megan Davies and Jonathan Oatis)