Story updated at 4:10 p.m. EST.
U.S. stocks closed Tuesday higher, extending a rally from Friday, as investors snapped up beaten-down consumer discretionary, industrial and financial stocks.
The Dow Jones Industrial Average closed the day up 223 points, or 1.4 percent, while the Standard & Poor's 500 index was up 31 points, or 1.7 percent, and the Nasdaq composite rallied 98 points, or 2.3 percent.
Crude oil prices reversed course, with U.S. crude down just over 1 percent at the close of trading, as an agreement by four of the world's largest producers agreed to freeze output failed to satisfy investors hoping for an outright cut in supply.
Slumping oil prices, fears of a China-led slowdown in global growth and uncertainty over central bank monetary policies have roiled the markets this year. The S&P 500 is down about 7.4 percent in 2016.
"I think you can make a case that a lot of stocks are oversold, and therefore they should be drawing some buyers from the sidelines," said Bucky Hellwig, senior vice president at BB&T Wealth Management in Birmingham, Alabama. "The question is if we can sustain this rally for several days."
Even a drop in crude oil prices, which has dictated the stock market's move recently, failed to derail stocks. The energy sector was the lone laggard among the 10 major S&P sectors, as oil prices fell.
The consumer discretionary index's rise led the advancers. The industrials, financials, technology and health sectors were also up more than 1 percent.
Banks again gained, led by Wells Fargo and Citigroup's rise. The financial sector is on track to post two consecutive days of gains for just the third time this year.
Consumer discretionary, technology and health stocks are down more than 9 percent this year. Only the financials' 13 percent drop is worse.
"We are seeing some bargain hunting but it isn't enough as yet to reverse the negative sentiment," said Art Hogan, chief market strategist at Wunderlich Securities in New York.
Investors are holding the most cash since November 2001, which should be interpreted as an "unambiguous buy" signal, according to Bank of America Merrill Lynch in its February global fund managers survey.
"We are also seeing a start to the conversation around production cuts in oil, but there's some way to go regarding that. It's a mixed bag for commodities," Hogan said.
Boeing was up 4 percent at $112.60 and was the biggest boost on the Dow.
ADT surged 47 percent to $39.63 after private equity firm Apollo Global Management agreed to buy the electronic security services provider for $7 billion.
Community Health Systems slumped 22 percent to $14.56 and weighed on other hospital operators after posting an unexpected quarterly loss.
Groupon surged 41 percent to $4.08 after Alibaba disclosed a 32.9 million stake in the company. Alibaba was up 9 percent at $66.30.
Advancing issues outnumbered decliners on the NYSE by 2,387 to 633. On the Nasdaq, 2,126 issues rose and 583 fell.
The S&P 500 index showed seven new 52-week highs and three new lows, while the Nasdaq recorded 12 new highs and 52 new lows.