Stocks rose on Tuesday amid news that U.S. lawmakers had secured a tentative deal on border security funding. Improved prospects for a U.S.-China trade deal also boosted equities.
The Dow Jones Industrial Average rose 372.65 points to close at 25,425.76, led by Caterpillar and 3M. The climbed 1.3 percent to 2,744.73 as materials, consumer discretionary and financials outperformed. The S&P 500 also closed above its 200-day moving average — a closely watched level by traders — for the first time since Dec. 3. The Nasdaq Composite advanced 1.46 percent to 7,414.62.
Shares of big banks gained broadly. The SPDR S&P Bank ETF (KBE) jumped 1.2 percent. Goldman Sachs, Citigroup and Morgan Stanley all rose at least 1.6 percent. Bank of America and J.P. Morgan Chase also gained at least 1 percent.
"It appears as though the government shutdown was avoided. That's good news for the market. That headwind goes away," said Art Hogan, chief market strategist at National Securities.
On Monday night, congressional negotiators struck a deal in principle that would keep the government open and avoid a shutdown on Friday. The drafted agreement did not contain funds for President Donald Trump's border wall, however. If the government is going to avoid another shutdown, it will need support from Trump.
The government was shut down for 35 days until Jan. 25, the longest one in history, as Trump and congressional leaders could not come to terms on funding for a wall along the U.S.-Mexico border.
Investors also focused on U.S.-China trade talks as both countries try to hammer out a deal before an early March deadline. Both sides expressed hopes the new round of negotiations, which began in Beijing on Monday, would bring them closer to a comprehensive trade agreement.
Both countries can reach a "superficial agreement" that "appease the market's anxiety; that's a simple trade agreement," said Matt Lloyd, chief investment strategist at Advisors Asset Management. "That alone they can come to fairly quickly."
"The more complex and the more longstanding issue that will probably have to be tabled is the intellectual property cases. That's going to be the bigger challenge," Lloyd said.
Bloomberg News reported that some U.S. aides acknowledge the most likely scenario at this point is the deadline will be moved given how far behind both sides are on trade talks. Trump also said Tuesday he would consider pushing back the deadline but "would prefer not to." The trade dispute has already started to impact global growth, with investors worried a protracted dispute could soon severely hurt corporate earnings.
Shares of Deere, Boeing and Caterpillar all rose Tuesday. These stocks are seen as global-trade bellwethers for their exposure to overseas markets.
"If the US and China come to a meaningful trade agreement soon, investors will start to discount its positive impact with more scrutiny on geographic/sector/asset class exposures and correlations will decline," wrote Nicholas Colas, co-founder of DataTrek Research. "If that trade agreement is wishy-washy or fails to materialize, then investors will assume a global recession is inevitable."
Shares of major tech companies like Amazon, Netflix and Alphabet all rose more than 2 percent. Apple's stock also gained 0.86 percent.
—CNBC's Sam Meredith contributed to this report.