Some market observers think that investors may be moving to the sidelines before what could be a very close and bitter election.

“I think people just want to clear the decks and get the heck out before the midterm elections, frankly,” said Chris Rupkey, chief financial economist at MUFG Union Bank.

President Trump has repeatedly cited the strong performance of the stock market as evidence of the success of his administration’s business-friendly approach. And as the market has slid lately, he has ratcheted up his criticism of the Federal Reserve’s plan to raise interest rates as economic growth remains strong.

Low interest rates have helped support economic growth and the stock market since the financial crisis 10 years ago. But with unemployment at a 49-year low, the Fed is now raising interest rates, saying it wants to keep the economy from overheating, which could set off inflation. The Fed is expected to raise interest rates again at its next meeting in December.

The rise in interest rates has been particularly painful for some pockets of the markets. Shares of homebuilders are down more than 16 percent this month, as rising mortgage rates have made houses less affordable. Smaller companies — which are heavily exposed to floating-rate debt — have also been hurt by rising rates, which increases the cost of their debt payments. The Russell 2000 index of small-capitalization stocks has fallen more than 13 percent in October.

And the president’s trade war with China has increasingly preoccupied the markets, analysts said. Official numbers released by Beijing last week showed China’s economic growth has slowed to 6.5 percent, its lowest level since 2009.

The slowdown in China, the world’s second-largest economy, could mean falling sales for American companies that export to that market. As large consumers of metal who have invested heavily to gain access to the Chinese auto market — the world’s largest — carmakers are particularly vulnerable to such risks. On Wednesday, Ford cited weak sales in China for falling profits. Company officials said issues surrounding trade disputes — including tariffs on imported steel and aluminum — could cost Ford $1 billion this year.