SAN FRANCISCO (Reuters) - U.S. President Donald Trump has warned that his favorite measure of success, the stock market, is imperiled if voters favor Democrats in next week’s congressional elections.

While not fully accurate - stocks tend to rise regardless of who controls the government - it does bear out that the market has delivered a slightly stronger performance on average when Republicans dominate in Washington.

A Reuters analysis of the past half century shows stocks fared better in the two calendar years after congressional elections when Republicans control Congress and the presidency than when Democrats controlled the two branches, and at least as well as during times of gridlock. Many investors are now hoping for a continuation of the Republican agenda.

“There is Trump ‘the person’, who is very controversial,” said Stephen Massocca, Senior Vice President at Wedbush Securities in San Francisco. “And there’s also Trump ‘the agenda’. The Trump agenda, the stock market loves. To the extent it continues, the market will like that.”

Republicans traditionally push pro-business policies such as tax cuts and deregulation, which boost stock prices. The market has, on the whole, given Trump a thumbs-up, with the market rising almost 20 percent during his presidency so far.

Polls show strong chances that the Democratic Party may win control of the House of Representatives in the Nov. 6 midterm elections after two years of wielding no practical political power in Washington, with Republicans likely to keep the Senate.

Trump warned in a tweet on Tuesday that a change in Congress would be bad for the market, saying: “If you want your Stocks to go down, I strongly suggest voting Democrat.”

Investors often favor Washington gridlock because it preserves the status quo and reduces uncertainty.

“Traditionally, gridlock is good for the markets. But I think this election is very tricky; I’m not sure that’s the preferred market outcome because a lot of the benefits of the past two years have come from not being in a gridlock environment,” said Mike O’Rourke, Chief Market Strategist at JonesTrading.

Should his fellow Republicans maintain or extend their grip on Congress, Trump may be emboldened to pursue more of his political agenda, including further tax overhauls.

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., November 1, 2018. REUTERS/Brendan McDermid

By contrast, Democratic gains that allow the party to control the House of Representatives, and possibly the Senate, could stifle Trump’s policy aims and perhaps lead to attempts to impeach him. It could also lead to resistance to increasing the government’s debt limit next year.

“Our economists believe that two likely consequences of a divided Congress would be an increase in investigations and uncertainty surrounding fiscal deadlines, which could raise equity volatility,” Goldman Sachs said in a report this week.

Over the past 50 years, gridlock has been the norm rather than the exception in Washington, with the presidency and Congress won by one party in just seven out of 25 congressional election years.

GRAPHIC: Wall Street and Washington - tmsnrt.rs/2P57hRu

Looking at the two calendar years following each congressional election, the S&P 500 had a mean annual increase of 12 percent under Republican-controlled governments, compared to an increase of 9 percent for Democrat-controlled governments and a 7 percent rise for gridlocked governments.

However, using median averages, which exclude outliers, differences are less clear, with the S&P 500 seeing annual increases of 11 percent under Republican-controlled governments and under gridlock, and 10 percent gains under Democrat-controlled governments.

An analysis by BTIG brokerage of data going back to 1928 also indicates gridlock is not necessarily ideal. It showed U.S. stocks performing better under united governments.

“While government control is by no means the sole determinant of market performance, investors clearly favor a unified regime,” BTIG strategist Julian Emanuel wrote in his report.

Interest rates, economic growth, company earnings and inflation are widely viewed as strong influences on stock prices, making the balance of power in Washington just one of many factors affecting investor sentiment.

Two Democratic presidents - Bill Clinton and Barack Obama - have presided over the strongest S&P 500 performances tmsnrt.rs/2jtEpzi since 1952, with gains of 208 percent and 166 percent, respectively.

Wall Street has applauded Trump since he took power in January 2017 and quickly pushed through measures to deregulate banks and other companies. Last December, his Republican party passed sweeping corporate tax cuts that have S&P 500 companies on track this year to grow their earnings per share by over 20 percent, the biggest jump since 2010, according to Refinitiv IBES data.

“Volatility may rise regardless of the outcome, but, based on historical relationships, equities may be more likely to rise if Republicans manage to maintain control of Congress,” Deutsche Bank said in a recent report.