Backtest Look Ahead In Universe Selection 标志

Backtest Look Ahead In Universe Selection

社区
HimanshuJ16
backtest-look-ahead-in-universe-selection

回测按某项规则选择标的范围(例如市值排名前 50 或当前指数成分股)时使用;审核成分归属时间戳,避免用 2026 年的成分股进行 2015 年的交易。特征层面的数据泄漏请参阅 lookahead-bias-elimination。

Add to TypingMind

概览

发布者HimanshuJ16
代码仓库Algo-Trading-Skills
技能名称backtest-look-ahead-in-universe-selection
星标数
50
复刻数
7
附带文件
5
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 5 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 HimanshuJ16 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Backtest Look Ahead In Universe Selection AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtest-look-ahead-in-universe-selection
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

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
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Backtest Look Ahead In Universe Selection,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Backtest Look Ahead In Universe Selection。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Backtest Look Ahead In Universe Selection 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

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

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Backtest Look Ahead In Universe Selection AI 技能有什么作用?

回测按某项规则选择标的范围(例如市值排名前 50 或当前指数成分股)时使用;审核成分归属时间戳,避免用 2026 年的成分股进行 2015 年的交易。特征层面的数据泄漏请参阅 lookahead-bias-elimination。

为什么在 TypingMind 中使用 Backtest Look Ahead In Universe Selection?

因为您只需安装一次,就能搭配任何模型使用。Backtest Look Ahead In Universe Selection 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Backtest Look Ahead In Universe Selection?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backtest-look-ahead-in-universe-selection。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Backtest Look Ahead In Universe Selection?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Backtest Look Ahead In Universe Selection 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Backtest Look Ahead In Universe Selection 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Backtest Look Ahead In Universe Selection AI 技能免费吗?

是的。HimanshuJ16 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇