Stocks closed higher on Monday, erasing slight losses from earlier in the session, as U.S. lawmakers reached a deal that would resume government operations. The rose 0.8 percent to close at a record of 2,832.97, with energy and telecommunications as the best-performing sectors. The Nasdaq composite also reached an all-time high, advancing 1 percent to 7,408.03, with shares of Netflix hitting a record. The Dow Jones industrial average gained 142.88 points to close at 26,214.60, an all-time high.

Major U.S. Indexes

Stocks kicked off the session trading lower, but quickly erased those losses. "The market has been through this enough times and understands Republicans and Democrats will come to an agreement," said Mark Heppenstall, CIO at Penn Mutual Asset Management. Members of the senate reached a short-term compromise to keep the government open through Feb. 8. Democratic Sen. Mark Warner said the party has the assurance it needs on the budget and immigration issues. On Saturday, the U.S. government shut down after a bill that would have kept government funded through mid-February was voted against in the Senate. The shutdown continued for a third day on Monday after the Senate on Sunday failed to reach an agreement to break an impasse before the work week began in Washington. Historically, a brief bout of volatility has hit the market following a government shutdown. The Cboe Volatility Index, also known as the VIX and considered the best gauge of fear in the market trades positive 75 percent of the time one week after a shutdown and averaged a return of 9.7 percent, according to CNBC analysis using Kensho. The S&P 500 averages a return of negative 0.3 percent.

A trader works on the floor of the New York Stock Exchange (NYSE) in New York. Brendan McDermid | Reuters