Building a Shariah Equity Screener for the S&P 500

How we built a systematic Shariah compliance screener for US equities, what the AAOIFI thresholds actually mean, and why 0 compliant out of 310 was a useful debugging signal rather than a theological statement.

There is a gap in most Islamic finance writing. On one side you have dense fiqh literature on the permissibility of financial instruments. On the other you have generic fintech content that treats Shariah compliance as a checkbox rather than a framework. What rarely gets written about is the middle layer: the actual mechanics of screening, the data problems, the threshold debates, and what the results tell you about the composition of modern equity indices.

This post is about that middle layer. We built a live Shariah screener for the S&P 500. You can see the results at guinevere-analytics.com/analytics/us-shariah-screener. Here is how it works and what we learned building it.

Why systematic screening

The traditional approach to Shariah-compliant investing relies on boards of Islamic scholars who review securities and issue rulings. This works well for structured products and sukuk, where the instrument design itself is the subject of review. For listed equities at scale, it creates a bottleneck. The S&P 500 has 503 constituents. Factor in the Russell 3000 and you are looking at three thousand companies. Human review cannot keep pace with index rebalancing, corporate restructuring, and the continuous drift of company financials across thresholds.

Systematic screening does not replace scholarly oversight. It narrows the problem. You run the quantitative filter first, identify the clear passes and clear fails, and reserve human judgment for the genuinely ambiguous cases. Most serious Islamic indices work this way. S&P Shariah Indices, MSCI Islamic, and the Dow Jones Islamic Market Index all use algorithmic screens as the first pass before any scholar review.

The framework: AAOIFI Standard No. 21

The Accounting and Auditing Organisation for Islamic Financial Institutions published Shariah Standard No. 21 on Financial Papers. It is the closest thing the industry has to a universal standard for equity screening, though MSCI and S&P both deviate from it in various ways.

The standard defines two categories of screens.

The first is a business activity screen. A company is excluded if its primary activity involves something categorically prohibited: conventional banking and insurance, alcohol, tobacco, weapons manufacturing, gambling, and adult entertainment. This is a binary pass or fail. There are no partial credits and no thresholds. If a company's core business is impermissible, that is the end of the analysis.

The second is a financial ratio screen. This addresses a practical reality: almost every large company touches the conventional financial system in some way. They hold interest-bearing cash, carry debt, and earn some incidental interest income. The question is whether the degree of involvement crosses a threshold that renders the investment impermissible.

AAOIFI specifies three ratios:

Total debt / market capitalisation must be below 33%. This is the leverage test. It reflects the Islamic position that excessive debt financing is impermissible, not debt itself. A company can borrow, but if its borrowings represent more than a third of its market value, the equity ownership becomes too entangled with interest-bearing obligations.

Accounts receivable / market capitalisation must be below 49%. This addresses a more subtle issue. A company with very large receivables relative to its value is effectively an intermediary of debt claims. At the extreme, buying its equity is functionally closer to buying a credit portfolio than owning a productive business.

Interest income / total revenue must be below 5%. This is the non-permissible income tolerance. It acknowledges that most companies earn some incidental interest on cash balances. A small amount is tolerated; a significant amount is not.

The denominator choice in the first two ratios is worth pausing on. AAOIFI uses market capitalisation, not total assets. This is not obvious. Many people intuitively reach for total assets as the denominator because it appears in the balance sheet alongside the numerator. But market capitalisation is the more principled choice for a Muslim investor. What you are buying when you purchase equity is a proportional ownership of the enterprise, valued at its market price. The leverage question is therefore: what fraction of that ownership stake is encumbered by interest-bearing debt? Total assets conflate the capital structure question with the asset base question. Market cap keeps it clean.

The one acknowledged weakness of market cap as a denominator is volatility. A company can move in and out of compliance simply because its stock price fell, even if nothing changed in its underlying financials. AAOIFI recommends using a 24-month average market capitalisation to smooth this out. Our current implementation uses the spot market cap. We flag this limitation explicitly in the report and plan to add the rolling average in a future iteration.

Stage one: the business screen

We source the S&P 500 constituent list from Wikipedia, which carries each company's GICS sector and sub-industry classification. The Global Industry Classification Standard is the most widely used taxonomy for this kind of work, and Wikipedia maintains the table with reasonable accuracy. You may change the source if you have access directly to either S&P, Bloomberg, D&B, Creditlens, MSCI or etc.

The exclusions are straightforward at the sector level. The entire Financials sector is excluded. Conventional banks, insurance companies, capital markets businesses, and financial conglomerates all fail here. This is the largest single exclusion category in the S&P 500, which has a meaningful allocation to financial services.

At the sub-industry level we exclude Brewers, Distillers and Vintners, Tobacco, Aerospace and Defense, and all gambling-related sub-industries. We also flag Movies and Entertainment and Hotels, Resorts and Cruise Lines for review rather than hard exclusion. Both can be compliant or non-compliant depending on the specific company. A hotel operator without casinos is different from one that derives significant revenue from gaming.

The business screen requires no API calls. Everything needed is in the constituent table. This matters for the architecture: companies that fail here skip the financial screen entirely, saving API budget and keeping the pipeline fast.

Stage two: the financial screen

For companies that pass the business screen, we fetch financial statements via yfinance, which pulls from Yahoo Finance without requiring an API key. We extract the most recent annual balance sheet and income statement, then compute the three AAOIFI ratios against current market capitalisation.

The data retrieval has more edge cases than you would expect. The field names in Yahoo Finance's response vary by company and by when you ask. A company that reports Total Debt today might report Long Term Debt And Capital Lease Obligation tomorrow after a data provider update. We handle this with a priority lookup: for each line item, we try several plausible field names in order and take the first one that returns a non-null value. If nothing matches, the company is flagged as needing review rather than failed, because absence of data is not the same as failure.

What the results tell you

When the screener ran for the first time using the FMP data source, it returned 0 compliant companies from 310 screened. This was not a theological finding. It was a data quality signal. The free tier of Financial Modeling Prep returns empty financial statements for most tickers. Every company went into the insufficient_data bucket and got marked as review. The business screen was working correctly, the financial screen had no data to work with.

This is worth dwelling on because it illustrates something important about building quantitative systems. A result that feels obviously wrong is often your best debugging tool. If we had simply accepted 0 compliant out of 310 and shipped it, we would have built a system that misleads anyone who uses it. The anomaly pointed directly at the data layer problem.

After switching to yfinance, the compliant count moved to a number that reflects the actual composition of the index, with real technology companies, healthcare companies, and consumer discretionary names passing both screens. The financial sector exclusions account for roughly 12 to 15 percent of the S&P 500 by count. The financial screen further removes companies with heavy debt loads, which tends to hit utilities and real estate investment trusts particularly hard.

What it does not do

The screener is a first-pass quantitative filter. It is not a fatwa. Several important considerations sit outside its scope.

The 5 percent interest income threshold is a tolerance, not a permission. Scholars disagree on how to interpret it. Some hold that any interest income requires proportional purification, meaning the investor should donate the equivalent fraction of dividends to charity. Others hold that below the threshold there is nothing to purify. Our tool computes the ratio; the interpretation is yours.

We do not screen for ESG factors beyond what the business screen captures. A company can be Shariah compliant and still have practices that a Muslim investor finds objectionable on other grounds. Shariah compliance and ethical investing overlap but are not identical.

We also do not account for consolidated subsidiaries. A holding company might pass the business screen at the parent level while owning a conventional insurance subsidiary. The screening methodologies used by major Islamic indices handle this through revenue-based consolidation rules. That level of analysis requires more granular segment data than we currently pull.

The screener refreshes nightly through a GitHub Actions workflow. It is meant to be a live, maintained tool rather than a static snapshot. The methodology and source code are available in the repository.

The live tool

You can explore the results at guinevere-analytics.com/analytics/us-shariah-screener. The page shows the full S&P 500 universe with each company's status, the three financial ratios where computed, and the specific reason for any exclusion. You can filter by status and search by name or ticker.

The next iteration will add the rolling 24-month average market cap denominator, sector-level drill-down charts, and a historical compliance rate series showing how the composition has shifted over time.

Stay tune! :)