US stocks mark end to ‘terrible year’ of rate hikes and inflation