factor-backtester

factor-backtester is a skill for Claude Code, Codex from seaworld008/Commonly-used-high-value-skills. It costs 37 tokens per session (1,942 once invoked), scanned A, original, MIT.

A research tool for testing whether a financial factor can predict investment returns. It prepares historical data, measures results such as risk and hit rate, and simulates long-short portfolios, where selected assets are bought while others are sold short.

In plain words
What is it for?
Use it to screen new investment signals, compare rankings across a market, test an investment idea, or investigate whether an underperforming factor has stopped working.
Why use it?
It helps identify signals that only look good in theory and checks how trading costs, turnover, missing data, and different market periods affect the results.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to screen new investment signals, compare rankings across a market, test an investment idea, or investigate whether an underperforming factor has stopped working.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/seaworld008/commonly-used-high-value-skills/factor-backtester
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add seaworld008/Commonly-used-high-value-skills --skill factor-backtester
Clone the repo
git clone --depth 1 https://github.com/seaworld008/Commonly-used-high-value-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for factor-backtester

README.md
[![agentmods](https://agentmods.dev/badge/skills/seaworld008/commonly-used-high-value-skills/factor-backtester/github.svg)](https://agentmods.dev/skills/seaworld008/commonly-used-high-value-skills/factor-backtester)
Your own site
<a href="https://agentmods.dev/skills/seaworld008/commonly-used-high-value-skills/factor-backtester"><img src="https://agentmods.dev/badge/skills/seaworld008/commonly-used-high-value-skills/factor-backtester/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for factor-backtester

Your own site · 80×15
<a href="https://agentmods.dev/skills/seaworld008/commonly-used-high-value-skills/factor-backtester"><img src="https://agentmods.dev/badge/skills/seaworld008/commonly-used-high-value-skills/factor-backtester.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,942 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium MCP Rug Pull · line 26
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.01942
Opus 5 $0.00018 $0.00971
Sonnet 5 $0.00007 $0.00388
Haiku 4.5 $0.00004 $0.00194

Measured 5d ago against content hash 83efe2153ff5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

factor-backtester scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/backtest_factor.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

openclaw-skills/factor-backtester/SKILL.md · 134 lines

How it starts

The opening of the file, as written. The whole thing — 134 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Factor Backtester (因子回测器)

在投入重金之前,先验证你的因子(Factor)是否真的具备“阿尔法”收益。本技能旨在提供一个轻量级的因子筛选层,帮助量化研究员和投资经理快速验证信号的有效性,并识别那些仅在“理想实验室”中存在的伪因子。

安装与前提条件

# 确保已安装量化回测与数学统计库
pip install pandas numpy matplotlib scipy pyfolio
# 准备回测数据
npx clawhub install factor-backtester

触发条件 / When to Use

  • 新信号研发 (Signal Research):验证一个新的财务指标(如:研发投入强度)是否具备长期选股能力。
  • 横截面排名测试 (Cross-sectional Ranking Tests):对比不同因子在全市场范围内的预测力。
  • 投资经理思路验证 (PM Idea Review):将宏观直觉转化为可量化的因子回测。
  • 深度工程前的筛选 (Lightweight Screening):在大规模分布式回测之前,先进行快速的“可行性扫描”。
  • 因子失效诊断:当某个传统因子(如:估值因子)近期表现不佳时,进行历史回看以判断其是否已经永久失效。

核心能力 / Core Capabilities

1. 信号准备与预处理 (Signal Prep)

  • 操作步骤
    1. 准备分周期的长端收益(Long Return)、短端收益(Short Return)及基准收益(Benchmark Return)。
    2. 进行数据的去极值处理(Winsorization)和标准化(Z-score)。
    3. 处理缺失值,并标记“可交易性”过滤器(如:剔除停牌、ST 或新股)。
  • 最佳实践:始终保留至少 5-10 年的历史跨度,以覆盖完整的经济周期。

2. 核心指标计算 (Metrics Calculation)

  • 操作步骤
    1. 运行 scripts/backtest_factor.py
    2. 计算 IC/IR (Information Coefficient):衡量预测值与实际收益的相关性。
    3. 计算 夏普比率 (Sharpe Ratio)最大回撤 (Max Drawdown) 以及 胜率 (Hit Rate)
    4. 分析 换手率 (Turnover) 对最终收益的侵蚀。
  • 最佳实践:除了看总收益,更要看分年度、分行业的收益稳定性。

3. 多空对冲模拟 (Long-Short Simulation)

  • 操作步骤
    1. 模拟多空对冲(Long-Short Spread)策略,观察因子的纯净阿尔法。
    2. 识别因子的“行业暴露”:该收益是真的来自因子,还是仅仅因为重仓了某个行业?
  • 最佳实践:在计算收益时,显式扣除双边 0.1% - 0.3% 的交易成本(Transaction Costs)。

4. 稳健性与压力测试 (Robustness Check)

  • 操作步骤
    1. 在不同市场环境下(牛市、熊市、震荡市)进行分段回测。
    2. 改变回测起点或调仓周期(如:从周频改为月频),观察信号是否依然存活。
  • 最佳实践:如果一个小变化导致收益巨幅波动,该因子大概率存在“过拟合”风险。

常用命令/模板 / Common Patterns

回测输入数据 JSON 模板 (Backtest Data JSON)

{
  "factor_name": "OperatingProfitMargin",
  "periods": [
    { "date": "2025-01-31", "long_ret": 0.05, "short_ret": 0.02, "bench_ret": 0.03, "turnover": 0.12 },
    { "date": "2025-02-28", "long_ret": -0.01, "short_ret": -0.04, "bench_ret": -0.02, "turnover": 0.08 }
  ],
  "transaction_cost": 0.0015
}

回测报告摘要模板 (Backtest Summary)

### 📊 [因子名] 回测报告摘要

**1. 核心表现 (Performance)**:
- **年化收益**: [XX%]
- **夏普比率**: [1.85] (显著性阈值: > 1.5)
- **最大回撤**: [-8.2%]

**2. 统计显著性 (Significance)**:
- **平均 IC**: [0.045]
- **IC IR**: [0.65]

**3. 换手与成本分析 (Cost Analysis)**:
- **月均换手率**: [25%]
- **预估成本侵蚀**: [年化约 4.5%]
- **净收益**: [依然为正,具备实盘价值]

**4. 最终结论 (Verdict)**:
> [✓] 建议进入深度研究阶段
> [!] 信号较弱,仅可作为次要辅助
> [X] 严重过拟合或成本无法覆盖收益,拒绝

Read the full file on GitHub · 134 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago Changed 83efe2153ff5
  2. 9d ago First seen · 134 lines · 37 tokens per session scan A 668913d944c6

Subscribe to this mod's changes

factor-backtester is a skill published in the GitHub repository seaworld008/Commonly-used-high-value-skills (70 stars, last pushed 5d ago), licensed MIT. It adds 37 tokens to every session and 1,942 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.