A volatile day on Wall Street ended in upbeat fashion Tuesday as a late-afternoon rally led by technology stocks pushed the market to a modest gain.

Traders work on the floor of the New York Stock Exchange during the afternoon of January 4, 2016 in New York City. (Photo by Andrew Burton/Getty Images)

The turnaround helped snap an eight-day trading slump for the Nasdaq composite, which is heavily weighted with technology stocks.

Energy stocks slumped as much as 2 percent during the day, then recovered in late trading to eke out a slight gain.

Crude oil prices declined for the seventh day in a row, the longest losing streak since July 2014. Oil has now fallen nearly 18 percent this year.

"We saw a little bit of weakness in oil and the selling just continued," said J.J. Kinahan, chief strategist at TD Ameritrade.

All told, the Dow Jones industrial average gained 117.65 points, or 0.7 percent, to 16,516.22. The Standard & Poor's 500 index added 15.01 points, or 0.8 percent, to 1,938.68. The Nasdaq composite climbed 47.93 points, or 1 percent, to 4,685.92.

Investors have been wrestling with fears about a protracted slowdown in China's economy and the potential fallout for corporate earnings. Uncertainty about Beijing's ability to manage its financial markets has also kept traders on edge after sharp losses last week.

The steep downturn in crude oil prices has also weighed on the market. The three major U.S. stock indexes are all down for the year, with the Dow and S&P 500 index off about 5 percent, while the Nasdaq is down 6.4 percent.

Trading looked to take a more positive turn early Tuesday as the major U.S. stock indexes opened higher and oil prices rose. That trend didn't last, as oil prices turned lower once more, weighing on energy stocks. The market looked like it was headed for a lower close before it reversed course in the final hour of trading.

"You're seeing very oversold conditions," said Phil Blancato, CEO of Ladenburg Thalmann Asset Management. "People here are basically buying the dip."

Eight of the 10 sectors in the S&P 500 index rose. Technology companies gained 1.2 percent. Health care and consumer discretionary stocks also notched gains of 1 percent. Utilities and telecommunications services stocks fell.

Chipmaker Intel added 62 cents, or 2 percent, to $32.68, while and Apple gained $1.43, or 1.5 percent, to $99.96. Among health care companies, UnitedHealth Group climbed 2.4 percent, the biggest gainer in the Dow Jones industrial average. It added $2.68 to $112.26.

Energy stocks rose 0.4 percent. The sector remains down 8.5 percent this year.

U.S. crude oil fell 97 cents, or 3.1 percent, to $30.44 a barrel in New York. Brent crude, a benchmark for international oils, fell 69 cents, or 2.2 percent, to $30.86 a barrel in London.

Traders continued to take their cue from oil prices by parting with stocks in energy and mining companies.

Freeport-McMoRan lost 20 cents, or 4.6 percent, to $4.11. Consol Energy shed 30 cents, or 4.3 percent, to $6.70.

"The trading in oil is particularly precarious, and because of that, everybody is selling energy-related stocks," Kinahan said. "Nobody wants to be the one holding the bag."

Investors also had their eye on company earnings season, which began Monday and runs for the next several weeks.

Alcoa sank 9 percent after the aluminum manufacturer's earnings included revenue that fell short of Wall Street's expectations. The stock dropped 72 cents to $7.28.

GameStop tumbled 5.1 percent after investors were disappointed with the video game store operator's holiday season sales. The stock lost $1.50 to $27.88.

Health insurers fared a bit better.

Traders bid up shares in Anthem, which rose $7.24, or 5.6 percent, to $135.60, and Aetna, which added $4.08, or 3.9 percent, to $109.15.

European markets moved higher.

Germany's DAX rose 1.6 percent, while the CAC-40 in France rose 1.5 percent. The FTSE 100 index of leading British shares gained 1 percent.

In Asia, China's Shanghai composite closed 0.2 percent higher, recovering some of its losses from the day before. Japan's Nikkei 225 fell 2.7 percent. Hong Kong's Hang Seng shed 0.9 percent, while South Korea's Kospi dropped 0.2 percent.

In metals trading, gold fell $11 to $1,085.20 an ounce, while silver fell 12 cents to $13.75 an ounce. Copper slipped 1 cent to $1.96 a pound.

Bond prices rose. The yield on the 10-year Treasury note fell to 2.11 percent from 2.17 percent late Monday. The euro fell to $1.0851 from $1.0871 a day earlier and the dollar rose to 117.69 yen from 117.53 yen.

In other energy trading in New York, wholesale gasoline fell 2.8 cents to close at $1.085 a gallon, heating oil fell 2.5 cents to 99 cents a gallon and natural gas fell 13.9 cents to $2.257 per 1,000 cubic feet.

(Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)

 

Sign up for the NJ1015.com Newsletter

Get the best of NJ1015.com delivered to your inbox every day.