When to Use
Invoke this skill when building or validating strategy universe selection rules. Selecting assets for a historical backtest using present-day attributes (e.g., "top 50 stocks by market cap today" or "current S&P 500 constituents" applied to 2015) introduces severe lookahead and survivorship bias. This skill audits universe membership point-in-time timestamps to guarantee zero future data leakage.
Universe membership moves on two independent time axes, and confusing them is the dominant failure mode:
| Axis | Field | Meaning |
|---|---|---|
| Knowledge | data_publication_date |
When the membership decision and its ranking inputs became public. Read at end of day when date-granular. |
| Effective | added_date, removed_date |
When membership actually started and ended. Read at start of day. |
The two are days to weeks apart. S&P DJI announced Tesla's S&P 500 addition on 2020-11-16, effective prior to the open on 2020-12-21. A backtest rebalancing on 2020-12-01 knew about the addition but must not yet hold it.
When NOT to Use
- Not a substitute for point-in-time source data. A clean audit means the timestamps you supplied are internally consistent. If every
data_publication_datewas back-filled from a current-membership table, the audit passes and the backtest is still leaking. Fix provenance first — seebacktest-database-schema-for-point-in-time-queries. - Not a ranking auditor. It does not recompute market cap, float, or ADV rankings, or verify that the values used were the as-of-date values. It only checks the timestamp you attach to them.
- Not a delisting-return model. Detecting that delisted names are missing is different from settling their terminal P&L. Use
survivorship-bias-free-universe-constructionfor construction and settlement. - Not for live universe construction. As-of machinery reconstructs the past; a live rebalance should read current membership directly.
Prerequisites
- Point-in-time historical universe constituent records with publication dates.
- Universe selection filter logic.
- A single timezone convention across snapshot and record timestamps (UTC recommended). The auditor rejects mixed naive/aware inputs rather than crashing mid-loop.
- The decision instant of each rebalance (e.g. 09:30 ET on the rebalance date), not just its calendar date.
Workflow
- Extract Constituent Timestamps: Record the exact timestamp when symbol membership became known.
- Separate Announcement From Effective Date: Populate
data_publication_datefrom the index provider's announcement and the as-of stamp of the ranking data, taking the later of the two. Never copyadded_dateinto it — that makes the look-ahead check unfalsifiable, and the auditor warns when every record does this. - Audit Filter Execution: Assert that selection criteria (market cap, volume) use data strictly preceding backtest date $T$ by passing that data's as-of stamp as
data_publication_date. The auditor checks the timestamp, not the values. - Decide the Same-Day Rule Explicitly: A publication timestamp of exactly midnight is date-granular — the real intraday instant was lost upstream, so it cannot establish that the data existed before the session's decision instant. The auditor therefore reads midnight as end of that day by default and flags same-day use as a leak, matching the same-day rule in
backtest-database-schema-for-point-in-time-queries. Override withdate_granular_publication_is_end_of_day=Falseonly when midnight genuinely means 00:00. - Flag Lookahead Violations: Alert if any constituent added to historical universe relied on post-date data. Gate CI on
result.has_violations(hard, deterministic) rather thanresult.is_clean, which also folds in heuristic warnings.
Full procedure: see
references/workflows.md. Standards reference: seereferences/standards.md. Printable pre-flight checklist: seeassets/checklist.md.
Common Pitfalls
- Retroactive Index Composition: Using 2024 S&P 500 constituents for a 2015 backtest, excluding companies that went bankrupt.
- Using Un-adjusted Historical Caps: Ranking universe by unadjusted market caps without point-in-time share counts.
- Publication Date Copied From Effective Date: The single most common way this audit is defeated. Every check passes because the two columns came from the same source column.
- Midnight Publication Timestamps: A date-only stamp read as 00:00 asserts availability at the very start of the day, which the data never supported. It silently authorises trading on a list that may not have been posted until that evening.
- Rank Date Mistaken For Knowledge Date: FTSE Russell determines 2026 Russell eligibility from market cap at the close on 30 April, but the preliminary lists are not published until 22 May and take effect after the close on 26 June. Nothing about the new membership is knowable on rank day.
- Inclusive Removal Dates: The auditor treats membership as half-open
[added_date, removed_date). A vendor that storesremoved_dateas the last day of membership will produce false "Zombie Asset" hits unless you add one session before auditing. - Duplicate Membership Intervals: Two overlapping rows for the same ticker silently double-weight the name; the auditor flags this as a violation.
- Survivorship Heuristic False Positives: A snapshot near the database build date legitimately has zero removals — nothing has been removed yet. The warning is only meaningful for snapshots well in the past.
Verification
- Submit universe selection with future-dated market caps, verify audit violation flag.
- Assert that a record published at midnight on the snapshot date is flagged, while the same record published at midnight on the prior date is not.
- Assert that a name whose
added_dateequals the snapshot date is treated as a member (changes take effect prior to the open) while one whoseremoved_dateequals it is flagged as a zombie. - Assert that a timezone-aware record audited against a naive snapshot raises
UniverseAuditErrorinstead of returning a clean result. - Run
python -m unittest discover -s skills/backtest-look-ahead-in-universe-selection/scriptsand confirm 100% pass rate.
Related Skills
backtest-database-schema-for-point-in-time-queriessurvivorship-bias-free-universe-constructionpoint-in-time-index-constituent-trackinglookahead-bias-elimination