Technology and health care companies led a broad rally in U.S. stocks Tuesday that pulled the Standard & Poor’s 500 index into the black for the year. The gains erased the market’s losses over the previous two days, when worries over falling oil and other commodities prices dragged down stocks.

That trend snapped on Tuesday as the price of U.S. crude oil rebounded. Investors also drew encouragement from better-than-expected data on consumer confidence and housing.

advertisement | advertise on newsday

At the close on Wall Street, the Dow Jones industrial average had risen 192.7 points, about 1.1 percent, to 17,721. The S&P 500 gained nearly 22 points, about 1.1 percent, to 2,078.4. The Nasdaq composite climbed nearly 67 points, about 1.3 percent, to nearly 5,108.

CRUDE ENERGY: Monday’s news that Iran intends to increase exports by 500,000 barrels per day once economic sanctions are removed deepened concern over excess global supplies, pushing prices 3.4 percent lower. As the markets closed Tuesday, benchmark U.S. crude had risen $1.06 cents, about 2.9 percent, to $37.87 a barrel on the New York Mercantile Exchange.

ECONOMIC SNAPSHOTS: Investors got some encouraging economic data on consumers and the housing market. The Conference Board’s latest consumer confidence index increased from the previous month, reflecting positive views on the economy and job market.

Meanwhile, a key gauge of home values indicated that U.S. home prices climbed 5.5 percent in October from a year earlier. Home values have climbed at a roughly 5 percent pace during much of 2015, as strong hiring has bolstered a real estate market still recovering from a housing bust that triggered a recession eight years ago.

“Both of those set us up nicely on a low volume day to be more positive than negative,” said analysit Darrell Cronk, president of Wells Fargo Investment Institute.