Stocks are closing out a dismal 2022 as the Fed fights inflation. Here’s what history says comes next.