S&P, Nasdaq close higher to extend longest streak in 2 years