LOS ANGELES (MarketWatch)—In case you didn’t notice, Saturday marked President Barack Obama’s 2,000th day in the Oval Office, and so it’s fitting to measure the stock market’s performance during his tenure with that of recent administrations.

Obama was sworn in amid extreme financial turmoil in January 2009, roughly six weeks before the stock markets hit bottom in the depths of the Great Recession. Pretty much the only direction for stocks to go was up.

How far up, though? More important, how do gains under Obama compare with those under other presidents who made it to 2,000 days?

Answer: He’s in the top half of the eight presidents since the Great Depression whose time in office lasted that long. That can always change, of course. And there’s considerable debate over whether he—or any president, for that matter—can influence the stock market or whether White House incumbents are just along for the ride.

“I wouldn’t be looking to give the administration a lot of credit for the stock market’s [performance],” said Sam Stovall, managing director of U.S. equity strategy at S&P Capital IQ. He noted, however, that stocks generally do better under Democrats than Republicans, particularly when stocks start out low.

As of right now, Obama ranks third behind top finisher Bill Clinton and runner-up Franklin Roosevelt in terms of stock gains, according to our calculations. After Obama, in order, it’s Ronald Reagan, Dwight Eisenhower, Harry Truman, George W. Bush and Richard Nixon. (Yes, Nixon barely made it into the club; he resigned 2,027 days into his presidency amid the Watergate scandal.)

There are a few surprises in the data. First, Obama not only finished ahead of Reagan, thought by many to be the architect of one of the greatest economic recoveries of the 20th century, but as of Friday’s trading session, the last before Obama’s 2,000th day, he was well ahead of Reagan. Major stock indexes have averaged gains of more than 142% under Obama, while they were up 88% at this same point in the Reagan years.

Pan the economic lens out, though, and the gap closes. You’ll see stock gains averaged just under 113% by the time Reagan had completed his full eight years, or 2,922 days in office. That’s still short of the market’s current advance under Obama, but all it would take is a cumulative drop of roughly 9.4% in the three indexes over the next 2 1/2 years, and Obama could fall below that mark by the time his second term ends.

Which is within the realm of possibility. Note that the Dow Jones Industrial Average DJIA, -0.87% thrived during Reagan’s last 2 ½ years despite the 1987 crash and ended up gaining more than 130% in all, well ahead of Obama’s current 105% gain. On the other hand, the Nasdaq Composite Index COMP, -1.07% has flourished under Obama: It’s up 190% thus far, compared with 94% for Reagan’s two full terms.

For now, the president seems to be basking in that glory. Obama pointed out in a speech on Thursday that Americans are doing better by “almost every measure.”

Democrats over Republicans 4-1

Another surprise, also sure to rankle the right, is that the average stock-market gain under four post-Depression Democrats through each one’s 2,000th day in office has outpaced the average gain of the four Republicans in the era by a factor of nearly 4 to 1. Democratic gains have averaged 133%, while Republican market advances have had a mean of 33%.

Stovall noted that the pattern follows historic precedent. When there’s a split Congress, Democratic presidents see four times the gains that Republicans do, as well as when Democratic administrations do battle with a unified Republican Congress. Markets, however, do better under Republicans when they control the White House and both houses of Congress than Democrats do when in the same catbird seat.

Before embarking further, a word about MarketWatch’s methodology. We averaged the changes in the Dow, Nasdaq and S&P 500 SPX, -1.11% for the first 2,000 days for four of the eight post—Great Depression presidents who made it that far: Reagan, Clinton, George W. Bush and Obama. For Eisenhower and Nixon, only Dow and S&P data were available. And for Roosevelt and Truman, it was just the Dow.

Starting with a Jan. 20 date for Inauguration Day, the 2,000th page on the office daily calendar turned for six of the presidents halfway through their sixth year on July 12. The dates were different for Roosevelt, who was first sworn in back when Inauguration Day was March 4, and Truman, who assumed power when Roosevelt died shortly into his fourth term in April 1945.

We didn’t limit our examination to 2,000-day presidents; we also looked at stock gains under all chief executives since F.D.R. In that study, Obama would remain in the top three even if stocks were flat for the rest of his term, and he would climb to second behind Clinton if they grew at their current pace. If they drop, of course, it’s anyone’s guess where the Obama presidency ends up in investing history.

A few caveats: Economists have done similar examinations that probably are more scientific than MarketWatch’s. One potential flaw is that we didn’t take dividends or inflation into account; the percentage gains are based solely on nominal numbers available.

We figure that we’re looking at percentage gains during that 5 ½-year window where inflation largely remained a constant through that period. Feel free to poke holes in that logic. Morgan Housel, senior analyst at Motley Fool, wasn’t afraid to do so.

“Including dividends is not only fair but essential, as over time they represent a large chunk of the market’s overall returns,” Housel said.

He pointed out that Gerald Ford would top the S&P list when dividend returns are entered into the mix. Those dividends were strong enough to keep him there even when you factor in the crippling inflation of the day. His immediate successor, Jimmy Carter, falls down Housel’s list mostly because inflation severely hampered returns and led to his loss after one term to Reagan.

Still, Obama does well by Housel’s measure, finishing second to Ford among presidents in the post-Depression era, one spot ahead of Clinton. That’s due mostly to extremely low inflation during Obama’s term.

Further, our time range is limited. Since the modern economy and government’s role in it took shape during and after the Great Depression, we decided to examine gains or losses dating back only to the Roosevelt administration.

The relatively small sampling of 2,000-day presidents also may skew the data. A broader look at all 13 chief executives from F.D.R. to Obama offers a more impressive view of the current president, but it also closes the gap between Democrats and Republicans on overall stock performance.

By including all seven Democrats in this category, it drops their party’s average gain to 109%, while the addition of two more Republicans brings that group of six’s average up to 46%.

“I don’t think we have a big enough sample size,” Housel said. He said other databases over a longer time frame still would show a slight advantage for Democrats, but the gap is minimal.

Yet Democrats seem to generally be doing better than Republicans in the modern era. While the gains have been meager at times, all seven Democrats have presided over stock gains. Two Republican administrations—that of the scandal-plagued Nixon and the crash-riddled George W. Bush—posted the only losses.

One thing to note is that No. 2 Roosevelt and No. 3 Obama came to power when stocks were in or near a trough. In F.D.R.’s case, his predecessor, Republican Herbert Hoover, presided over a spectacular crash in stocks that led to the Great Depression. For Obama, the George W. Bush years laid the groundwork for a big upward swing when a number of banks failed and the markets tumbled late in that presidency.

Starting from scratch

“It would have been a good time to start for any president,” said Allan Drazen, professor of economics at the University of Maryland. “Given the large drop, it’s not surprising that [Obama] does well.”

By far, though, the most impressive stock-market gains were made in the Clinton era, when the stock market far outgained the market during any other administration, leaping nearly 244%. All three stock indexes more than tripled, while the Nasdaq nearly quadrupled amid the dot-com boom.

“How much of Clinton’s over-the-moon performance was due to his ability to have pretty good policy, and how much was his ability to not mess things up?” Drazen asked. He theorized that, because Clinton was up against an uncooperative Congress, deficits came down and thus halo effect emerged over the stock market. Republicans aim to put Obama in a similar situation after the midterm elections this fall.

So, when all is said and done, how will stocks have fared under Obama as leaves office in January 2017?

If growth remains on its current pace, average gains for the three indexes should more than triple to 208%, putting Obama in second place behind Clinton. That’s a big if, though.

Another prospective surprise: It could do better.

Some economists who follow presidents and stock markets theorize that the third year of a four-year term usually is productive for investors, as the government is trying to push through programs that appeal to the public and help boost the economy. The idea is to prepare for the fourth year, when elections take place and incumbents either are trying to get re-elected or set the table for their party’s nominee.

The third year of Obama’s second term starts in January, so, under that theory, stocks could rise at an even faster pace. And if Drazen is correct, that could be amplified if Republicans seize control of both chambers of Congress.

Why a Hillary Clinton presidency wouldn’t be like a third Obama term

Peter Cohan, a management consultant and professor at Babson College in Wellesley, Mass., said there still is room for growth in stocks, if price-to-earnings ratios are any indication. “The P/E ratios aren't at speculative levels,” he said. “Even though [the market] has gone up so much, it’s not in bubble territory.”

Cohan said P/E ratios now stand at 19 or 20. At the height of the dot-com bubble, they were 40. During the 2007 housing bubble, ratios had climbed to 60.

Others aren’t so sure that Obama will follow the typical third-year path. For one, the third year of his first term, 2011, didn’t bring a remarkable bonanza for stocks; the markets were largely flat that year.

Since then, stocks have been on a tear, and many are predicting they’re due for a fall. And as this term’s third year approaches, many of the things presidents try to do in preparation for the next election, such as keeping inflation down, don’t really apply to Obama. The Federal Reserve, in fact, is looking to finally raise interest rates after so many down years.

And given Obama’s rancorous relationship with Republicans in Congress, any attempts he might make to stimulate the economy could be met with stiff resistance.

“I think there’s a fairly good presumption of, even if he wanted to do that, he couldn’t,” said Drazen.