Investors may fear that political upheaval and today's divided government — with a Democratic-controlled House in opposition to a Republican administration and Senate — could derail the president's agenda and put an end to the historic bull market.

But history reveals that stock markets often perform better with a divided government. Between 1901 and 2017, the Dow Jones Industrial average returned 10.1 percent annually in periods with divided government vs. 9 percent with one party in control.

Stocks also recover solidly after a U.S. president's impeachment or resignation, according to some fascinating research from Oppenheimer Funds (more on that later).

Here are some sectors that could see action after this month's midterm elections, in which Republicans gained seats in the Senate but Democrats gained the majority in the House:

  • Energy: The administration has advocated for more fossil-fuel development and rolled-back regulations. Post-election, the administration may get more aggressive with Iran and Venezuela, possibly elevating energy prices. That could reverse a bear market in oil prices.

  • Industrials/materials: Infrastructure is a priority for both Democrats and Republicans, but how will it would be funded? More important for these two sectors is the outcome of what former Trade Representative Harald Malmgren termed a WWE wrestling-style trade war between the United States and China.

  • Financials: The banking and financials sector was among the primary beneficiaries of the Trump victory. Democrats, in regaining House leadership, would be unlikely to roll back much of the administration's deregulation measures. At the same time, further deregulation would meet resistance in the House.

  • Information technology: The tech sector is flush with cash following the repatriation tax change. However, the Democrats and the president appear in favor of probing tech firms on allegations of anticompetitive behavior by such giants as Google, Facebook, and Amazon.

What about another presidential impeachment or resignation?

When President Richard Nixon resigned in the 1970s and President Bill Clinton was impeached in the 1990s, the stock market took a nosedive. Nixon's resignation exacerbated a bear market in stocks, which lasted for several years after he resigned in August 1974, but that was largely due to an oil embargo and rapidly rising inflation. Inflation, specifically the Core Consumer Price Index (CPI), increased from below 3 percent to more than 11 percent.

During Clinton's impeachment, stocks also suffered. Between July and August 1998, the S&P 500 index fell 19 percent before recovering 82 percent; the impeachment, in hindsight, served as a short-term bottom before the internet-driven dot-com bubble.

In essence, politics doesn't change much of what happens in the stock market, which is driven by earnings and underlying fundamentals in the economy.

How might another impeachment or resignation impact the financial markets?

Again, history suggests there "may be a spike in market volatility, but perhaps not a severe or extended one that could topple the current bull market," Oppenheimer Funds wrote in its market research note to clients.