Stocks may like government gridlock as much as they like potential tax reform.

Investment research firm Ned Davis Research found that when the Philadelphia Federal Reserve's Partisan Conflict Index — a measure of political disagreement in the United States — rises above 100, the has risen at a 11.7 percent annual rate. In contrast, the S&P rises just 5.8 percent when the index is below 100, according to analysis published on June 27.

On Wednesday, the Philly Fed said the index reached 201.15 in June, one of only seven times it has been above 200, and close to March's record of 271.29.

Source: Ned Davis Research

"Like other sentiment gauges it works contrarily," Ed Clissold, chief U.S. strategist at Ned Davis Research, told CNBC in a phone interview Thursday. Stocks like to "climb a wall of worry."

In this case, traders may actually like the Trump-Russia headlines causing D.C. gridlock because they don't want politicians to mess up a good thing. Earnings are growing at a record pace, and economic growth is steady — two things markets like. New legislation could force businesses to change, potentially hurting their growth.

The Senate on Tuesday shortened its August recess by two weeks in order to work on health care and other legislation.

When Ned Davis Research looked at the Partisan Conflict Index's last six months of performance versus the last four years, the S&P 500's gains were even greater.

The S&P rose at a 17 percent annual rate when the index's deviation from trend was above 100. When the deviation was below 100, the S&P gained less than 1 percent annually, the study showed.

Source: Ned Davis Research

Still may investors believe stocks have surged to record highs since the election on hopes the Trump administration's proposals for tax reform, deregulation and infrastructure spending will boost economic growth. About half a year since the inauguration, Congress is still debating a new health-care bill, while discussion of tax reform seems even further away.

"Partly because the majority, particularly in the Senate, is so narrow, the gridlock has continued. Certainly a tax cut would be received favorably by the market," Clissold said. "Once the market started to [think about] the details, maybe a little less action by the government isn't necessarily a bad thing."

The Partisan Conflict Index tracks keywords in news reports using Dow Jone's Factiva search engine. The top sources of articles are The Washington Post, The New York Times, Los Angeles Times, Chicago Tribune, The Wall Street Journal, Newsday, The Dallas Morning News, The Boston Globe and Tampa Bay Times, according to the working paper behind the index. The study excludes editorials, commentaries, routine general news, reviews and interviews.

Some market strategists say the stock market's tenacious climb reflects an aging bull market, before a sharp decline. In March, Bank of America Merrill Lynch raised its S&P 500 year-end forecast by 150 points to 2,450 based on the view that bull markets often end with high optimism.

Clissold said there are other reasons — such a large part of the market moving up together — to expect stocks to remain in a bull market. But other sentiment indicators he tracks are showing optimism, which is historically a sign of a coming stock pullback.

"If you look over our broad swath of sentiment data assets, this is one of our last holdouts," Clissold said. "If political conflict goes away, there really isn't a whole lot for the markets to worry about and that could be setting up for a market top."