Logo: Backtest Look Ahead In Universe Selection

Backtest Look Ahead In Universe Selection

Communautéit
HimanshuJ16
backtest-look-ahead-in-universe-selection

Benotzt dëst, wann de Backtest säin Universum no enger Reegel auswielt, wéi déi 50 gréissten no Maartkapitaliséierung oder déi aktuell Indexzougëhregkeet; et iwwerpréift d'Zäitstempelen vun der Zougëhregkeet, fir sécherzestellen, datt net mat den Indexmemberen vun 2026 am Joer 2015 gehandelt gëtt. Feature-Level-Leakage gehéiert bei lookahead-bias-elimination.

Add to TypingMind

Iwwersiicht

EditeurHimanshuJ16
RepositoryAlgo-Trading-Skills
Skill-Nummbacktest-look-ahead-in-universe-selection
Stären
50
Forks
7
Matgeliwwert Dateien
5
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 5 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    HimanshuJ16 huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Backtest Look Ahead In Universe Selection an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtest-look-ahead-in-universe-selection
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Backtest Look Ahead In Universe Selection an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Backtest Look Ahead In Universe Selection automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Backtest Look Ahead In Universe Selection net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Backtest Look Ahead In Universe Selection?

Benotzt dëst, wann de Backtest säin Universum no enger Reegel auswielt, wéi déi 50 gréissten no Maartkapitaliséierung oder déi aktuell Indexzougëhregkeet; et iwwerpréift d'Zäitstempelen vun der Zougëhregkeet, fir sécherzestellen, datt net mat den Indexmemberen vun 2026 am Joer 2015 gehandelt gëtt. Feature-Level-Leakage gehéiert bei lookahead-bias-elimination.

Firwat Backtest Look Ahead In Universe Selection op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Backtest Look Ahead In Universe Selection besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Backtest Look Ahead In Universe Selection an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtest-look-ahead-in-universe-selection an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Backtest Look Ahead In Universe Selection benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Backtest Look Ahead In Universe Selection benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Backtest Look Ahead In Universe Selection domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Backtest Look Ahead In Universe Selection gratis?

Jo. HimanshuJ16 huet de Skill ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇