qmt-inner-backtest

qmt-inner-backtest is a skill for Claude Code, Codex from dfkai/xtquantai. It costs 96 tokens per session (3,719 once invoked), scanned A, original, MIT.

A procedure for turning a trading strategy or research report into a QMT daily factor backtest script. QMT is a Chinese trading-platform environment, and a backtest simulates how a strategy would have traded using historical data.

In plain words
What is it for?
Reproducing research factors, selecting stocks with cross-sectional rankings, applying industry or market-cap adjustments, and testing fixed-size equal-weight portfolios in QMT.
Why use it?
It provides a fixed structure for calculating factors and signals before executing scheduled portfolio changes, reducing the work of assembling a complete script.

Skill for Claude CodeCodex

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

Good fit Reproducing research factors, selecting stocks with cross-sectional rankings, applying industry or market-cap adjustments, and testing fixed-size equal-weight portfolios in QMT.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dfkai/xtquantai/qmt-inner-backtest
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 dfkai/xtquantai --skill qmt-inner-backtest
Clone the repo
git clone --depth 1 https://github.com/dfkai/xtquantai

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 qmt-inner-backtest

README.md
[![agentmods](https://agentmods.dev/badge/skills/dfkai/xtquantai/qmt-inner-backtest/github.svg)](https://agentmods.dev/skills/dfkai/xtquantai/qmt-inner-backtest)
Your own site
<a href="https://agentmods.dev/skills/dfkai/xtquantai/qmt-inner-backtest"><img src="https://agentmods.dev/badge/skills/dfkai/xtquantai/qmt-inner-backtest/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 qmt-inner-backtest

Your own site · 80×15
<a href="https://agentmods.dev/skills/dfkai/xtquantai/qmt-inner-backtest"><img src="https://agentmods.dev/badge/skills/dfkai/xtquantai/qmt-inner-backtest.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 96 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,719 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 pass 7 Sept 2026
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.00096 $0.03719
Opus 5.5 $0.00038 $0.01488
Sonnet 5.5 $0.00019 $0.00744
Haiku 4.5 $0.00010 $0.00372

Measured 1mo ago against content hash 1e6059072ae4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

qmt-inner-backtest 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 1mo ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/daily-factors-backtest.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.

skills/qmt-inner-backtest/SKILL.md · 278 lines

How it starts

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

QMT 内置因子回测

概述

基于 scripts/daily-factors-backtest.py 生成 QMT 策略编辑器内置回测 脚本。

核心模式:after_init 预计算全区间因子与买卖信号 → handlebar 按调仓日执行交易。

母版路径:本 skill 目录下的 scripts/daily-factors-backtest.py(相对 SKILL.md 所在目录)

适用场景

适合 不适合
日频截面因子选股(Barra 风格处理) Tick/分钟高频
固定持仓数 Top-N 等权调仓 期货开平仓(qmt-future-trade,规划中)
研报因子复现、上下影线/价值/动量等 目标持仓型期货实盘(qmt-live-strategy-template,规划中)
申万行业 + 市值中性化 仅要信号推送(qmt-live-signal-feishu,规划中)

母版架构(必须理解再改)

daily-factors-backtest.py
├── 文件头 # coding:gbk + 策略说明 docstring
├── 因子函数库          ← 【主要替换区】factor_xxx + 中性化/去极值
├── init(C)             ← 【配置区】回测区间、股票池、资金、因子参数
├── after_init(C)       ← 【信号区】拉数据 → 算因子 → 过滤 → 生成 g.buy/sell_signals
├── handlebar(C)        ← 【执行区】调仓日卖出/买入(通常保留)
├── 交易执行函数         ← 通常原样保留
└── 辅助工具函数         ← 通常原样保留(IPO/ST/涨跌停/财务宽表)

各段职责

段 函数/变量 做什么
全局状态 g = G() 跨函数共享参数、信号矩阵、持仓
因子库 factor_ubl(...) 输入 OHLCV/市值等宽表,输出因子 DataFrame(index=日期, columns=股票)
因子后处理 filter_extreme_mad_df / neutralize_by_market_cap / neutralize_by_industry_zscore / cross_section_zscore Barra 风格流水线,按研报需求保留或删减
初始化 init(C) 设 g.start_date/g.end_date、g.stock_pool、g.max_positions、g.rebalance_days 等;预定义 g.buy_signals/g.sell_signals 防空矩阵
预计算 after_init(C) 一次性拉全区间行情+财务 → 算因子 → IPO/ST/停牌过滤 → 截面排名 → shift(1) 生成 T+1 信号
执行 handlebar(C) 每 g.rebalance_days 个交易日调仓:先卖后买,开盘价成交
交易 execute_sell/buy_signals 涨停不买、跌停不卖;科创板 200 股、其余 100 股整数倍
辅助 get_ipo_mask / get_st_mask / get_financial_wide_table 上市满 120 天、ST 区间、财务字段宽表

信号时序(防未来函数)

df_rank = df_factor_filtered.rank(axis=1, ascending=g.rank_ascending)
df_is_top_n = df_rank <= g.max_positions
g.buy_signals = df_is_top_n.shift(1).fillna(False)   # T 日因子 → T+1 日买入
g.sell_signals = ~g.buy_signals

禁止去掉 .shift(1),除非用户明确要求当日收盘调仓且接受前视偏差。

Agent 工作流

1. 解读策略输入

用户可能提供:文字描述、研报 PDF、截图、已有因子公式。提取并输出 策略规格表(生成前给用户确认):

Read the full file on GitHub · 278 lines

Files

What ships with it

1 file 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. 1mo ago First seen · 278 lines · 96 tokens per session scan A 1e6059072ae4

Subscribe to this mod's changes

qmt-inner-backtest is a skill published in the GitHub repository dfkai/xtquantai (166 stars, last pushed 4mo ago), licensed MIT. It adds 96 tokens to every session and 3,719 once invoked, about $0.0004 per session on Opus 5.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-08-30.

Related

Other skills, from other repositories

quant-trading-researcher

Use when quant researchers or strategy developers need to evaluate factor ideas, backtest validity, statistical reliability, trading costs, implementation risk, and live monitoring readiness before paper trading or limited production deployment.

AndrewNgGirl/SkillLens · 45 tokens

defi-protocol-templates

Implement DeFi protocols with production-ready templates for staking, AMMs, governance, and flash loans. Use when building decentralized finance applications or smart contract protocols.

wshobson/agents · 38 tokens

stock-analyzer

Provides comprehensive technical analysis for stocks and ETFs using RSI, MACD, Bollinger Bands, and other indicators. Activates when user requests stock analysis, technical indicators, trading signals, or market data for specific ticker symbols.

FrancyJGLisboa/agent-skill-creator · 48 tokens

metronome

Guides Metronome usage-based billing integration decisions — event ingestion (single and batch, idempotency, billable metrics), contract design (rate cards, overrides, dimensional pricing, products), invoicing lifecycle (grace periods, finalization, Stripe sync), credit and commit management (prepaid, postpaid…

fcakyon/claude-codex-settings · 184 tokens

close-status

Use when reporting the evidence-backed status of a named month-end or quarter-end close, its blockers, counted completion, and dependency path. Not for explaining budget variances; use variance-analysis.

davekilleen/Dex · 41 tokens

lov-skill-pricing

A pricing workflow for creating an explanation-backed pricing card for an AI agent skill. It considers creation and maintenance effort, user value, scarcity, buyer confidence, and distribution potential.

lovstudio/skills · 78 tokens