What a difference a month makes.

A period of relative calm on Wall Street that led to a milestone-setting September for the stock market came to a sudden, screeching halt in October.

The slide snapped a six-month winning streak for the benchmark S&P 500 index, with October clocking in as the worst month for the market since September 2011.

On Oct. 29, the S&P 500 narrowly missed closing in what Wall Street calls a correction — a drop of 10 percent or more from a recent high. The index ended the month down 7.5 percent from its all-time high set September 20 and down 6.9 percent for the month. The Nasdaq briefly entered into a correction before recouping some of its losses this week. The technology-heavy index finished October down 9.9 percent from the record set August 29 and down 9.2 percent for the month.

The market’s reversal in October came as investors grew concerned that corporate profits, which drive stock market gains, could be poised to weaken.

“Investors were worried about politics and earnings,” said Sam Stovall, chief investment strategist for CFRA. “Politics because of the upcoming midterm elections, as well as the China trade dispute … And from an earnings perspective, investors started to worry about an earnings peak.”

While profits have been extremely strong this year — earnings for the S&P 500 are estimated to have risen by 24.8 percent in the third quarter after a 25.2 percent gain in the second quarter — several big companies, including Amazon, AT&T and Alphabet, reported quarterly earnings or revenue during the month that fell short of expectations. And some company executives warned of rising costs related to the U.S.-China tariffs and inflation — factors that could weigh on earnings next year.

“While nine of 11 sectors have seen increases in third-quarter estimates, an equal number — nine of 11 — have seen full-year 2019 earnings reductions,” Stovall noted.

The disappointing company outlooks added to investors’ jitters about the health of corporate America and the economy.

The Federal Reserve has been hiking interest rates, and has indicated it’s likely to continue doing so for the next two years. The escalating U.S.-China trade dispute is adding to some companies’ costs, which could dampen profits. And on top of all that, an economic slowdown in China has traders worried about slower global economic growth.

In response, investors piled money into safe-haven, high-yield stocks like electric utility AES Corp. and household goods companies such as Hormel Foods.

Consumer staples and utilities were the only sectors in the S&P 500 to eke out gains in October, of 2.1 percent and 1.9 percent respectively. The energy sector and consumer discretionary stocks, which includes companies such as Norwegian Cruise Line and Amazon.com, took some of the heaviest losses. Both sectors lost 11.3 percent for the month.

Amazon plunged 20.2 percent in October. Netflix, another of this year’s high fliers, lost 19.3 percent during the month as investors pocketed profits from the stock’s gains this year.

Three of the most valuable U.S. companies ended October in a correction: Amazon, Alphabet and Facebook, although some of those declines began this summer.

Concerns that the U.S.-China trade dispute will drag on, hurting company profits, have made traders wary of investing in companies that depend on economic growth, like technology, industrial and consumer-focused firms — the same stocks that led the market over the last decade.

Some of October’s market volatility could also be attributed to uncertainty over the outcome of the midterm elections on November 6, although stocks finished out the month with a two-day rally.

“The question,” Stovall said, “is do you buy into this two-day rally or do you sell into this two-day rally?”

© The Associated Press. All rights reserved.