A jump in shares of consumer companies Mondelez and Kellogg after their quarterly reports on Tuesday, along with further gains for tech stocks, helped Wall Street end October on a positive note.
The three major indexes tallied their best monthly gains since February.
Mondelez jumped 5.4 percent after the Oreo cookie maker reported better-than-expected profit and revenue, while Kellogg surged 6.2 percent following its first sales increase in more than two years.
Those stocks boosted the S&P consumer staples sector, which rose 0.8 percent to lead all major groups.
Apple rose 1.4 percent to a record high after positive reviews of its much-anticipated iPhone X. The stock provided the biggest boost to all the three major indexes.
The tech sector climbed 0.4 percent, building on gains following a batch of strong quarterly reports last week.
"You look at the earnings out of these big players and they continue to impress," said Steve Chiavarone, portfolio manager with Federated Investors in New York. "It strikes me that that leads you to a much more bullish outlook for the fourth quarter."
The Dow Jones Industrial Average rose 28.5 points, or 0.12 percent, to 23,377.24, the S&P 500 gained 2.43 points, or 0.09 percent, to 2,575.26 and the Nasdaq Composite added 28.71 points, or 0.43 percent, to 6,727.67.
Investors are also awaiting an announcement on the next Federal Reserve chair, which could come this week. President Donald Trump is likely to pick Fed Governor Jerome Powell, who is seen as more dovish on interest rates and thus relatively stock market friendly, sources have told Reuters.
The Fed started its two-day meeting in Washington on Tuesday, although the central bank is widely expected to leave interest rates unchanged in its statement on Wednesday.
"The macro data is getting better, the market is prepared for Jerome Powell, the market is also prepared for Friday’s payrolls. I also think the market is ready for what the (Fed) says tomorrow," said Ken Polcari, director of the NYSE floor division at O’Neil Securities in New York.
"I don’t think there is anything out there that could derail the market from a point of view it doesn’t already expect."
Market-watchers are also tracking developments of the tax-cut plan being developed by Trump and fellow Republicans.
Third-quarter earnings in general have come in modestly above expectations. With more than half the S&P 500 components reported, earnings are estimated to have climbed 7 percent in the quarter, up from an expectation of 5.9 percent growth at the start of October, according to Thomson Reuters I/B/E/S.
“We continue to see better-than-expected economic numbers and corporate earnings," said Peter Jankovskis, co-chief investment officer at OakBrook Investments in Lisle, Illinois. "I think fundamentally investors are really focused on those numbers more than the political noise, if you will, in the background."
But not all reports have earned a positive stock reaction. Pfizer shares slipped 0.3 percent after the drugmaker's results.
Under Armour slumped 23.7 percent after the sportswear company slashed 2017 forecasts.
Qualcomm shares plunged 6.7 percent and were the biggest drag on the S&P and the Nasdaq on news that Apple has designed iPhones and iPads that would drop its chips, according to two people familiar with the matter. Shares of chipmaker Intel rose 2.5 percent.
Rockwell Automation shares jumped 7.4 percent. The automation equipment maker said it had rejected an unsolicited acquisition bid from rival Emerson Electric for more than $27 billion. Emerson shares fell 3.6 percent.
Advancing issues outnumbered declining ones on the NYSE by a 1.68-to-1 ratio; on Nasdaq, a 1.78-to-1 ratio favoured advancers.
About 6.8 billion shares changed hands in U.S. exchanges, above the 6.1 billion daily average over the last 20 sessions.