Stocks closed broadly higher on Wall Street Thursday as some solid corporate earnings and a breakthrough in negotiations over Britain’s exit from the European Union put investors in a buying mood.

Companies including Netflix, CSX and Morgan Stanley rose after reporting surprisingly good profits. Health care, communication services and industrial stocks drove much of the market’s gains, which erased modest losses from the day before.

On Thursday:

The S&P 500 index gained 8.26 points, or 0.3%, to 2,997.95.

The Dow Jones Industrial Average added 23.90 points, or 0.1, to 27,025.88.

The Nasdaq rose 32.67 points, or 0.4%, to 8,156.85.

The Russell 2000 index of smaller companies climbed 16.79, or 1.1%, to 1,541.84.

For the week:

The S&P 500 is up 27.68 points, or 0.9%.

The Dow is up 209.29 points, or 0.8%.

The Nasdaq is up 99.81 points, or 1.2%.

The Russell 2000 is up 29.94 points, or 2%.

For the year:

The S&P 500 is up 491.10 points, or 19.6%.

The Dow is up 3,698.42 points, or 15.9%.

The Nasdaq is up 1,521.58 points, or 22.9%.

The Russell 2000 is up 193.29 points, or 14.3%.