In this tumultuous and divisive election year, it’s comforting for investors to know that — based on 50 years of Bloomberg data — elections are generally reliable for the stock market. The gain may be more short- than long-term, depending on which party ends up in office, but an optimistic investing survey from 1964 to today shows faith in the American electoral process, though with no particular party affiliation.

Elections years historically see more stock market gains than the other three years of the presidential cycle. Of the 13 elections in the past 50 or so years, the market returned positive 11 times and negative twice, a 5.5:1 gain to loss ratio. In election years from 1964 to 1996, the stock market returned gains through a mix of victorious Republican and Democratic candidates. Notably, the only recent election years that have not shown gains were 2000, due to the dot-com bubble burst, and 2008, during the recent recession.

Forbes contributor Bill Greiner observes that election year returns are lower when the incumbent is not running for reelection, like this year with Obama’s eight-year tenure expiring. Of six such recent scenarios — Eisenhower in 1953, Kennedy in 1961, Nixon in 1969, Bush Sr. in 1989, Bush Jr. in 2001, and Obama in 2009 — the average annual return was -5.6%. However, two of those election years — 2000 and 2008 — coincide with economic downturns. 2008 was particularly severe, skewing the results. In general, the pattern is a vote of confidence in the American presidential system, fool-proofed against Republican and Democratic candidates.

Election year tends to be more profitable if a Republican wins the highest office in the land, with 8.8% average annual returns on the S&P 500, compared to 5.3%. However, during the next three years of the election cycle, investors with a long-term outlook generally benefit from a Democrat tenure, since Democrats are not averse to government spending programs: for example, Obama’s auto industry bailout and the Affordable Care Act. The S&P gains faster in non-election years under a Democratic president, with average returns showing 11.7% against 5.1%.

This contrast means bondholders would prefer a Republican president to see returns of 8.7% over 6.5% in election years and 9.8% above 4.9% the subsequent three years.

The market also generally sees smaller price fluctuations under a Democratic tenure, although the market is slightly more stable during election years that reward Republican candidates.

Another Forbes contributor pushed their data set even further to suggest that the S&P 500 historically does best under the combination of the leadership of a Democratic President and Republican Congress.

In our current post-convention, end-of-summer state, we can statistically expect to see the S&P 500 up 1.4%, versus the usual decrease of 0.1% for August in non-election years. But with the Brexit vote shock still fresh in investors’ systems, one has to wonder — as many investors have in previous election cycles — if this year will be the true test of the American political system. By all accounts, Trump vs Clinton is an unusual, historically unprecedented race. If the pattern holds, it will primarily be a victory for the stock market and a testament to the resilience of American democracy.

It’s also unclear if and how the Olympics will impact the investment market, especially in conjunction with an array of other variables. The unexpected is always possible, but odds are the Bloomberg model will continue to hold true.