S&P 500 and Nasdaq close at record highs