When I go to Yahoo Finance, I see that the market is moving all the time. On the top of the web page, I see S&P, Dow, and Nasdaq. Their graphs keep on moving even at midnight. I thought the market is closed. How come the graphs keep on moving?
You're right that the US stock market is not open at midnight. But those quotes you see are not those of the stock market; they are those of the futures market. The index futures markets do not necessarily have the same trading hours as the stock market. In fact, some index futures on the CME trade almost continuously. For example, the E-mini S&P 500 Futures trade 22 h 45 min each day (Sunday to Friday from 6:00 pm to 5:00 pm ET with a trading halt from 4:15 pm to 4:30 pm) (reference).