U.S. stocks surrendered early gains and finished mostly lower Wednesday as energy companies skidded with the price of oil. Apple led technology companies higher. The mixed finish came after three days of big, erratic moves.

On Wednesday:

The Dow Jones industrial average fell 31.98 points, or 0.2 percent, to 18,034.77.

The Standard & Poor’s 500 index slid 1.25 points, or 0.1 percent, to 2,125.77.

The Nasdaq composite climbed 18.52 points, or 0.4 percent, to 5,173.77.

For the week:

The Dow is down 50.68 points, or 0.3 percent.

The S&P 500 is down 2.04 points, or 0.1 percent.

The Nasdaq is up 47.87 points, or 0.9 percent.

For the year:

The Dow is up 609.74 points, or 3.5 percent.

The S&P 500 is up 81.83 points, or 4 percent.

The Nasdaq is up 166.36 points, or 3.3 percent.