Backtest Look Ahead In Universe Selection logo

Backtest Look Ahead In Universe Selection

Community
HimanshuJ16
backtest-look-ahead-in-universe-selection

Use when the backtest picks its universe by a rule such as top 50 by market cap or current index membership; audits membership timestamps so 2015 is not traded with 2026 constituents. Feature-level leakage belongs to lookahead-bias-elimination.

Overview

PublisherHimanshuJ16
RepositoryAlgo-Trading-Skills
Skill namebacktest-look-ahead-in-universe-selection
Stars
50
Forks
7
Bundled files
5
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by HimanshuJ16 on GitHub. Read the source before you install it.

Installation

Install the Backtest Look Ahead In Universe Selection AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtest-look-ahead-in-universe-selection
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HimanshuJ16/Algo-Trading-Skills.git /tmp/Algo-Trading-Skills
mkdir -p .claude/skills
cp -r /tmp/Algo-Trading-Skills/skills/backtest-look-ahead-in-universe-selection .claude/skills/backtest-look-ahead-in-universe-selection
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Backtest Look Ahead In Universe Selection in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Backtest Look Ahead In Universe Selection on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Backtest Look Ahead In Universe Selection is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

AxisFieldMeaning
Knowledgedata_publication_dateWhen the membership decision and its ranking inputs became public. Read at end of day when date-granular.
Effectiveadded_date, removed_dateWhen 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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Backtest Look Ahead In Universe Selection AI skill do?

Use when the backtest picks its universe by a rule such as top 50 by market cap or current index membership; audits membership timestamps so 2015 is not traded with 2026 constituents. Feature-level leakage belongs to lookahead-bias-elimination.

Why use Backtest Look Ahead In Universe Selection on TypingMind?

Because you install it once and use it with any model. Backtest Look Ahead In Universe Selection is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Backtest Look Ahead In Universe Selection in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtest-look-ahead-in-universe-selection. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Backtest Look Ahead In Universe Selection?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Backtest Look Ahead In Universe Selection?

As many as you like. As long as a model supports skills, you can use Backtest Look Ahead In Universe Selection with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Backtest Look Ahead In Universe Selection AI skill free?

Yes. It is published on GitHub by HimanshuJ16 under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇