Agricultural markets rallied on Friday to end the year in style, but sharp losses in wheat, soybeans, cotton, cocoa and sugar at certain points this year weighed on commodities as a whole and left the asset class with its first annual loss in three years.

The 19-commodity