There are lots of reasons why employing more women to run companies is a good idea. Greater gender diversity on boards, for example, helps with managing risk, growing revenue and increasing innovation.

An ongoing project from Karen Rubin shows investors benefit too. Rubin works as the director of product for Quantopian, a crowd-sourced algorithmic trading platform backed by Khosla Ventures, Spark Capital and Bessemer Venture Partners. She was curious to figure out if you could correlate female leadership to superior stock performance and decided to create an algorithm to test the theory (h/t Fortune).

Starting in 2002 (which happens to be the data set that was available to her) Rubin manually input the start and end dates (if relevant) for each woman CEO’s tenure, through the end of 2014. Her algorithm calculated the returns to investors in every Fortune 1000 company over the period when it was run by a woman. She then compared that to the performance of S&P 500 companies. Rubin found that for the women-led companies, the performance was much better: A 340% return vs. 122% for the S&P 500 benchmark.

The correlation held up even if you stripped out the top and bottom three performers from the female CEO index. In that case it returned 319%.

Rubin acknowledges the possibility of sector bias, since many of the women who make it to the top are often hired to run companies in the consumer discretionary sector (in other words, non-essential consumer goods and services like retail, media and autos that have seen their fortunes rise as the US economy has pulled out of recession.) But when she compared how the consumer sector performed against the S&P 500, the outperformance was not nearly as great as the women CEO portfolio. (What’s more, there are a bunch of women CEOs running tech, utilities and industrial companies.)

Yet that still leaves a tantalizing question unanswered: Why?

Conventional wisdom holds that the bar is higher for women, so only the very best rise to the top. The thinking is, Rubin tells Quartz that “so few women get into these positions, that those who do are rock stars.”

Other studies show that women are disproportionately hired to run companies that find themselves in deep trouble. (Think Mary Barra at GM or Marissa Mayer at Yahoo.) In theory, if she does succeed in turning the company around, the upside for investors would be all the greater. “It’s an interesting idea,” Rubin says. ”It’s plausible, and it’s something that could be proved by numbers.”

Conversely, research shows that companies are quicker to fire women when a company is underperforming, and that would potentially limit the downside: She’s gone before the stock has fallen very far.

But the only way to really know how effective women are as company CEOs is to get more women into the pipeline and up through the executive ranks. Currently women account for an outrageously small percentage of CEOs of S&P 500 companies: 4.6%.