AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified Apache-2.0 Self-run

Backtest Look Ahead In Universe Selection

skill-himanshuj16-algo-trading-skills-backtest-look-ahead-in-universe-selection · by HimanshuJ16

>-

— No reviews yet
0 installs
23 views
0.0% view→install

Install

$ agentstack add skill-himanshuj16-algo-trading-skills-backtest-look-ahead-in-universe-selection

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • ✓ Prompt-injection patterns
  • ✓ Secret / credential exfiltration
  • ✓ Dangerous shell & filesystem operations
  • ✓ Untrusted network calls
  • ✓ Known-malicious package signatures

What it can access

  • ✓ Network access No
  • ✓ Filesystem access No
  • ✓ Shell / process execution No
  • ✓ Environment & secrets No
  • ✓ Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-himanshuj16-algo-trading-skills-backtest-look-ahead-in-universe-selection)

Reliability & compatibility

✓ Security review passed
0 installs to date
— no reviews yet
● 14d ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Backtest Look Ahead In Universe Selection? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

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_date was back-filled from a current-membership table, the audit passes and the backtest is still leaking. Fix provenance first — see backtest-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-construction for 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

  1. Extract Constituent Timestamps: Record the exact timestamp when symbol membership became known.
  2. Separate Announcement From Effective Date: Populate data_publication_date from the index provider's announcement and the as-of stamp of the ranking data, taking the later of the two. Never copy added_date into it — that makes the look-ahead check unfalsifiable, and the auditor warns when every record does this.
  3. 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.
  4. 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 with date_granular_publication_is_end_of_day=False only when midnight genuinely means 00:00.
  5. 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 than result.is_clean, which also folds in heuristic warnings.

> Full procedure: see references/workflows.md. > Standards reference: see references/standards.md. > Printable pre-flight checklist: see assets/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 stores removed_date as 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_date equals the snapshot date is treated as a member (changes take effect prior to the open) while one whose removed_date equals it is flagged as a zombie.
  • Assert that a timezone-aware record audited against a naive snapshot raises UniverseAuditError instead of returning a clean result.
  • Run python -m unittest discover -s skills/backtest-look-ahead-in-universe-selection/scripts and confirm 100% pass rate.

Related Skills

  • backtest-database-schema-for-point-in-time-queries
  • survivorship-bias-free-universe-construction
  • point-in-time-index-constituent-tracking
  • lookahead-bias-elimination

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.