U.S. stocks rose on Tuesday in the first session of the new year, pushing the S&P 500 and Nasdaq to record closing highs, as investors were optimistic that 2018 will bring more gains for the market.

Gains were driven the most by technology, but consumer discretionary, health care, energy and materials sectors were also up more than 1 percent each.

Apple, Facebook, Alphabet and Microsoft pulled the technology index up 1.4 percent, following a 37-percent surge in 2017 that made it the best-performing S&P sector.