New York (CNN Business) The stock market had a miserable 2018, but some companies bucked the trend to post an exceptionally good year.

Of the 505 companies in the S&P 500, only 160 managed to post a positive year in 2018. That's less than a third — not surprising when the S&P 500 is down 7%, on its way to the worst year since the Great Recession.

Still, companies from Abiomed to Zoetis and dozens of companies in between managed to post strong gains. Businesses as diverse as Macy's and McCormick were up in 2018.

And the winner is...

Chip-maker Advanced Micro Devices ( AMD ) surged 73% this year, making it the top stock in the S&P 500.

Read More