U.S. stocks closed at or near records Wednesday, with the S&P 500 and the Nasdaq Composite booking back-to-back all-time highs, as investors bought financials and energy shares. The S&P 500 index /zigman2/quotes/210599714/realtime SPX -2.27% marked its 51st record high this year, matching the greatest number of closing records to this point in a calendar year since 1995, according to Dow Jones Market Data. The S&P 500 rose by about 10 points, or 0.2%, to 4,496, on a preliminary basis, just shy of a round-number level at 4,500. The Nasdaq Composite /zigman2/quotes/210598365/realtime COMP -2.23% closed 0.2% higher at around 15,042, marking its 30th record of the year. The Dow Jones Industrial Average /zigman2/quotes/210598065/realtime DJIA -2.53% , meanwhile, finished up 0.1% at 35,406, closing within shouting distance of its Aug. 16 closing record at 35,625.40.