Stocks struggled to a mixed finish on Wall Street as gains in energy and technology companies were canceled out by losses in other sectors. Banks posted the largest losses Tuesday. Energy stocks bucked the downward trend as oil prices rebounded.

On Tuesday:

The Standard & Poor’s 500 index fell 1.90 points, or 0.1 percent, to 2,425.53.

The Dow Jones industrial average inched up 0.55 points, less than 0.1 percent, to 21,409.07.

The Nasdaq composite gained 16.91 points, or 0.3 percent, to 6,193.30.

The Russell 2000 index of smaller-company stocks rose 4.58 points, or 0.3 percent, to 1,413.05.

For the week:

The S&P 500 is up 0.35 points, or 0.01 percent.

The Dow is down 5.27 points, or 0.02 percent.

The Nasdaq is up 40.23 points, or 0.7 percent.

The Russell 2000 is down 2.78 points, or 0.2 percent.

For the year:

The S&P 500 is up 186.70 points, or 8.3 percent.

The Dow is up 1,646.47 points, or 8.3 percent.

The Nasdaq is up 810.19 points, or 15.1 percent.

The Russell 2000 is up 55.92 points, or 4.1 percent.