Stocks gave up some early gains to finish lower Wednesday as energy companies sank with the price of oil and weak quarterly reports weighed down technology companies.

After two days of closing higher, stocks rose in the morning but couldn’t hang on to the gains. Energy companies fell after U.S. energy stockpiles shrank by a smaller amount than analysts expected, and announcements from Adobe Systems and HP hurt tech stocks. Drug companies traded higher.

advertisement | advertise on newsday

Trading was light as investors watched Federal Reserve Chair Janet Yellen’s testimony before Congress and waited for Thursday’s referendum on Britain’s membership in the European Union.

“There’s not a lot of trading out there. People are tentative,” said Randy Frederick, managing director of trading and derivatives at Charles Schwab.

Polls indicate it will be a tight race, but bookies are giving the “remain” camp a higher probability of winning. International experts, including Yellen, have said that a British exit would cause volatility in global markets and uncertainty for the world economy.

The Dow Jones industrial average dipped 48.90 points, or 0.3 percent, to 17,780.83. The Standard & Poor’s 500 index fell 3.45 points, or 0.2 percent, to 2,085.45. The Nasdaq composite edged down 10.44 points, or 0.2 percent, to 4,833.32.