Stocks ended broadly higher Thursday as investors set aside concerns, for now, about the heated trade war between the U.S. and China that roiled markets earlier in the week.

The gains erased the week’s losses for the S&P 500 index. It was the third straight gain for the market following six losses in a row. Investors snapped up technology stocks in a signal that they are more willing to take on risk.

On Thursday:

The S&P 500 index rose 54.11 points, or 1.9%, to 2,938.09.

The Dow Jones Industrial Average climbed 371.12 points, or 1.4%, to 26,378.19.

The Nasdaq composite vaulted 176.33 points, or 2.2%, to 8,039.16.

The Russell 2000 index of smaller companies picked up 31.45 points, or 2.1%, to 1,532.13.

For the week:

The S&P 500 is up 6.04 points, or 0.2%.

The Dow is down 106.82 points, or 0.4%.

The Nasdaq is up 35.08 points, or 0.4%.

The Russell 2000 is down 1.53 points, or 0.1%.

For the year:

The S&P 500 is up 431.24 points, or 17.2%.

The Dow is up 3,050.73 points, or 13.1%.

The Nasdaq is up 1,403.88 points, or 21.2%.

The Russell 2000 is up 183.57 points, or 13.6%.