Investors worried about whether a looming government shutdown could slow US stocks’ recent surge can take comfort in history: markets have tended to shrug off shutdowns despite their potentially nasty economic impact. Since 1984, the S&P 500 has averaged a 1.3% gain during government shutdowns, having edged lower in only two out of the last 10 instances. The most recent shutdown, which lasted for five weeks, shaved 0.1% and 0.2% from real US gross domestic product in the fourth quarter of 2018 and the first quarter of 2019, respectively, according to the Congressional Budget Office. It did not do much to deter stocks, however, with the S&P 500 rising more than 9% during that period. The S&P 500 and Nasdaq composite indexes touched all-time highs on Thursday as investors looked past bleak economic data, while remaining focused on a COVID-19 vaccine. “Markets understand that artificial deadlines created by governments got designed as negotiating tools,” said Jamie Cox, managing partner for Harris Financial Group. “It is nothing more than a pause … and most of the time it’s resolved in very short order,” he said. More may be at stake this time, spurring lawmakers to act more decisively while also potentially boosting investor concerns as government funding for nearly all federal agencies expires on Dec. 11. Failure by the Democratic-controlled House and Republican-controlled Senate to pass a bill on how to allocate around $1.4 trillion to be spent by Sept. 30, 2021, when the fiscal year ends, could have dire consequences. Some healthcare operations could be short-staffed or interrupted at a time when US COVID-19 cases have been spiking, with more than 270,000 fatalities so far. The massive spending bill could also be the vehicle for providing billions of dollars to state and local governments to help them handle coronavirus vaccines that are on track to be available in coming weeks and months. With the economy reeling from COVID-19 and high unemployment, “there will be tremendous political pressure … to hammer out a deal,” said Paresh Upadhyaya, portfolio manager for Amundi Pioneer Asset Management in Boston.