U.S. stocks ended the worst year since the financial crisis with a narrow gain in thin pre-holiday trading. Treasuries rose to a 10-month high.

The S&P 500 finished a choppy session higher and the Nasdaq Composite capped its first four-day advance since August amid optimism that President Trump will move toward a trade deal with China.

The advance trimmed the worst December rout for the S&P 500 since 1931 to 9.2 percent. That monthly rout capped a 6.2 percent slide in the year, the biggest of the record bull market.

Stocks around the world limped into the end of a dismal year that’s seen bear markets in equities from Japan to Germany. Europe’s main stock gauge fell 13 percent in the year – the biggest since 2008. The 10-year Treasury yield slid to 2.68 percent, the lowest since February. The dollar edged lower as the government shutdown continued, while the yen climbed to a four-month high.

In commodities, crude slumped to its first annual loss since 2015, completing a reversal that saw it drop from a four-year high set just three months ago.

Natural gas futures slid Friday below $3 for the first time since September, giving the front-month contract its worst December since 1991. Gold barreled into 2019 near a six-month high on haven demand.

While the glimmer of hope on the trade front sent global stocks out on a high note, plenty of event risks loom in the next 12 months, from the U.K.’s exit from the European Union to U.S.-China trade talks and the continuing showdown between Trump and Congress over the budget.

The American political landscape is also unsettling investors following departures of senior officials and Trump’s repeated criticism of Federal Reserve Chairman Jerome Powell.

Here’s how major markets performed this year:

The S&P 500 fell 6.2 percent.

The Dow Jones Industrial Average slid 5.6 percent.

The Nasdaq Composite dropped 3.9 percent.

The Russell 2000 fell 12 percent.