Fears of a U.S. government shutdown loom over Wall Street as Congressional budget negotiations remain at an impasse ahead of an Oct. 1 deadline. But surprisingly, the stock market has historically gone up when the government shuts down, according to Raymond James. Despite the looming risks to the broader economy, Raymond James found that the S & P 500 has gained an average of 3.2% during the five government shutdowns since 1995, in addition to some “slight fear trade trends” in 10-year Treasurys, Raymond James analyst Ed Mills wrote in a note Wednesday. “Markets are largely unaffected in the lead up to a shutdown, and on average continue to rise in the 30 days following the resolution of a shutdown,” Mills said. Energy stocks have historically seen the largest gains during government shutdowns. Large-cap energy names added 4.9% on average, while small- and mid-cap energy stocks rose 8.1% and 7%, respectively. Other sectors in the broad market index that have had historically strong showings during shutdowns include communications services, consumer staples and technology. All three advanced 4.6% on average. Ultimately, a government shutdown will not likely create lasting effects in the market, according to Raymond James. “While the political path forward will focus attention on the impasse and potentially drive negative market sentiment, we ultimately expect little in terms of a material market impact from a potential shutdown scenario,” Mills said. Federal budget year ends Sept. 30 Of the 12 appropriations bills that need to be passed by Congress and signed by President Joe Biden, only one has been passed by the Republican-controlled House of Representatives. Government funding is set to expire Sept. 30 and, without agreement on a new budget, will lead to a government shutdown, worker furloughs and the suspension of government programs and agency closures. “The appropriations process remains far from resolution and the Republican House Freedom Caucus (HFC) appears to be preparing for a showdown over government funding to extract political concessions from Congressional Democrats/Senate Republicans,” Mills wrote. “While the Senate Democrats and Republicans seem to be largely on the same page about government funding, disaster aid and Ukraine support, the House is a horse of a different color. Not only are Democrats and Republicans on different pages, but Republicans are also not singing from the same sheet of music as other Republicans,” Mills said. The House Freedom Caucus of Republicans, in particular, “appears to be preparing for a showdown over government funding to extract political concessions from Congressional Democrats/Senate Republicans.” “Key Congressional leaders have signaled that a continuing resolution (CR) to temporarily extend government funding will be the focus, but the politics of additional policy riders on a temporary funding extension (disaster relief, border security, Ukraine’s defense) will add to the volatility potential on a final deal,” Mills added. — CNBC’s Michael Bloom contributed to this report.