US stocks close midweek with continued rise; S&P 500, Nasdaq hit new record highs