NEW YORK — The S&P 500 is on track to close 2024 with a gain of nearly 27%, after setting 50 record highs this year. That’s on top of its 24.2% spurt the year before, a spectacular two-year run unmatched since the dot-com boom. But perhaps more importantly, it’s so far avoided a recession that many on Wall Street worried …