S&P 500, Nasdaq hit record highs on recovery optimism