How to audit a stock screen before you run it | Quantery Blog
Audit a stock screen before running it by tracing each formula to its filing inputs, checking how missing values are handled, and reading the gate as a literal admission rule. Then inspect the universe and backtest settings. If you can't explain what happens to a company with a missing field, a weak score, or an odd denominator, the screen isn't ready.
This preflight catches a different class of problem from a compiler check. A valid thesis can still encode the wrong idea. The field names may exist and every expression may parse, while a mixed-period balance sheet or a rank with no absolute floor distorts the result. Take a bundled template apart first. You'll build the habit on rules that are already readable, then use the same pass on your own work.
Start with the claim, then find every proxy
Open the Greenblatt Magic Formula template and read its description before touching a formula. Its claim is that companies with strong operating returns and cheap operating earnings deserve a high combined rank. That sentence gives you an audit map:
- "Cheap operating earnings" needs an earnings measure and a valuation base.
- "Strong operating returns" needs a profit numerator and an operating-capital denominator.
- "Combined rank" needs a defined comparison universe.
- "Deserve a high rank" still needs an admission rule.
Now inspect the feature definitions. Don't begin with the final score. Begin with the rawest feature and move down in declaration order. In this template, the earnings and capital calculations feed two yields, the yields feed two percentile ranks, and those ranks feed the combined rank.
For each derived feature, say the formula aloud in business terms. market_cap + debt - cash is the template's enterprise-value definition. ebit / ev is its earnings yield. If the plain-English version doesn't match the claim you meant to test, stop there. A polished result table won't repair a mismatched proxy.
This is also where adaptations belong in the open. The template documents how it approximates operating earnings when the exact historical field isn't consistently available. That choice may be sensible for a starter screen, but it's still a choice. You can substitute another definition and rerun the work. Metric definition risk deserves a test of its own because a small-looking formula change can alter who qualifies.
Check whether the inputs belong together
A screen can use real filing values and still assemble a financial statement that never existed. Balance-sheet values are snapshots. If cash comes from one filing and debt comes from another, the resulting net-debt figure is synthetic.
Quantery's DSL makes this distinction visible. newest(field) reads the field from the newest period and leaves it null when that period doesn't report it. latest(field) scans backward to find the most recent reported value. The first is strict about period alignment. The second can improve coverage, but it can also mix dates when several balance-sheet fields are combined.
Ask these questions for every formula:
- Is the input a balance-sheet level or a period flow?
- Must all inputs come from the same filing?
- Can a scan-back pull an older value into a newer calculation?
- Does a trailing sum contain the periods the claim assumes?
There isn't one right function for every case. Revenue and operating income are period flows, so a trailing calculation often matches the claim. Cash, debt, and equity are levels at a reporting date. When a formula nets them against each other, same-period consistency matters more than filling every blank.
A null is sometimes the correct answer. Replacing it with an older observation can make the table look complete while weakening the meaning of the ratio. How to handle missing data in a stock screen covers the broader policy. During preflight, your job is narrower: identify where the thesis chooses coverage over alignment and decide whether the choice fits this formula.
Make every denominator earn its place
Ratios fail at the denominator. Equity can be negative. Operating earnings can be negative. Enterprise value can approach zero. A division that is mathematically possible may have no useful economic interpretation.
Read each ratio's guard before reading its threshold. A feature shaped like this is explicit:
earnings_yield: if(ev > 0, ebit / ev, null)
The guard says the screen won't calculate an earnings yield when enterprise value isn't positive. That doesn't label the company bad. It says this ratio can't grade that case.
Then follow the null downstream. Quantery comparisons involving null evaluate as false, so a criterion without a null rule can fall through to its default score. A good audit asks whether the fallback is visible. Look for is_null(...) near the top of the criterion and a flag that explains the miss. Missing data shouldn't receive accidental credit, and it shouldn't disappear without a trace.
Do the same with coalesce. Treating a missing cash-flow item as zero may fit a field whose absence commonly means none. Treating missing debt or operating income as zero would change the business claim. coalesce is a policy decision written as a function. Read it that way.
This pass is deliberately repetitive. Find the denominator. Find its guard. Force the guard to fail in your head. Follow the null into the criterion and then into the gate. Repeat.
Read ranks against their actual universe
A percentile rank answers, "Where does this company sit among the names being compared?" It doesn't answer whether the underlying value is attractive in absolute terms.
That distinction matters in the Magic Formula template. Its earnings-yield rank and return-on-capital rank adapt to the current universe. A company can rank well because its peers are worse. The template therefore uses positive operating earnings as an economic floor before the final admission rule can pass. A positive return on capital raises the earnings-power criterion's score, but a non-positive return on capital doesn't fail that criterion by itself.
Inspect the universe before trusting any rank. Exchange filters, market-cap constraints, sector exclusions, and data availability all affect the comparison set. Excluding financial businesses from a capital formula isn't housekeeping. It changes every remaining percentile. So does tightening a market-cap floor.
For your own thesis, write down the population the rank is supposed to represent. If the story says "among industrial companies," a market-wide rank tests another claim. If the story says "cheap compared with its own sector," a global earnings-yield rank won't do that work.
This is why a preflight should inspect rank logic before a scan produces enticing names. Once familiar companies appear near the top, it's harder to question the population that put them there. Choosing the universe your screen runs on is the companion exercise when the population itself needs redesigning.
Translate the gate into one blunt sentence
Criteria score degrees. The gate decides admission. Read it without the surrounding labels.
A strict gate means every criterion must earn a passing score. A score gate means weak performance in one criterion can be offset elsewhere until the required total is reached. Neither structure is universally better. They express different claims.
Translate yours into a sentence such as:
A company qualifies only if its combined rank passes the chosen band, its operating earnings are positive, and its trading-liquidity rule passes.
Now try to break the sentence. Can a superb valuation compensate for unusable data? Can a missing rank slip through on other points? Can a company pass the composite while failing the rule you described as essential? If the answer is yes, either the gate is wrong or your prose overstates it.
Keep data quality separate from taste. A missing price, a stale filing, or a required feature that can't be computed is a quality problem. A low earnings yield is an investment-rule outcome. Combining both into one vague low score makes the result harder to audit later.
Inspect the backtest block before the first result
A screen defines who qualifies now. A backtest adds timing decisions: when the thesis checks again, how long filings wait before becoming usable, when a simulated entry occurs, and what ends a holding period.
Those settings can change the proposition. A rank refreshed often but held for a long interval isn't the same strategy as one that exits when the gate fails. A filing available to the public shouldn't influence a simulated decision before the reporting lag permits it. Entry timing must follow the signal rather than share its closing price.
Write the sequence in calendar language: a filing becomes usable, the next scheduled evaluation sees it, the entry rule acts, and the exit rule later responds. If you can't describe that order, don't interpret the return chart yet.
Every Quantery backtest result is hypothetical and excludes costs. The preflight still needs a tradability rule where the thesis would otherwise select thinly traded names. A liquidity feature doesn't estimate slippage. It prevents the research universe from pretending every quoted price is equally usable. For the rest of the result-reading discipline, use the backtest audit checklist.
Run only after you can predict the failures
Before starting the scan, name a company-shaped case that should fail each important rule. Negative operating earnings should fail the earnings floor. A missing required feature should produce a data-quality failure. A middling combined rank should miss the rank criterion even when its raw values are positive.
Then run the screen and audit those failures first. Survivors tell you where the thesis agrees with itself. Near-misses tell you whether the plumbing behaves as designed. If a failure surprises you, trace its feature values and flags before changing a threshold.
That order protects the useful part of Quantery's flexibility. Every formula, null policy, rank, and gate is yours to inspect. Every one is also yours to get wrong. A short preflight turns the first scan from a verdict into what it should be: the first execution of rules you already understand.
Research tooling, not investment advice. Nothing here is a recommendation to buy, sell, or hold any security. Screens, scores, and backtests are informational only; backtested results are hypothetical, exclude costs such as commissions and slippage, and do not guarantee future results. Verify against primary filings and make your own decisions.
Want to try this on your own rules? Quantery is free for 14 days: the full app, no card required.
← All articles