The S&P 500 closed at 7,736.52 and the Dow topped 54,000 for the first time, powered by Palantir, Caterpillar and a drop in crude prices.