量化策略助手
量化策略助手:自然语言→策略生成→回测→优化→QMT模拟/实盘。三轮交互闭环。 Skill: 量化策略助手 Owner: listolany Summary: 量化策略助手:自然语言→策略生成→回测→优化→QMT模拟/实盘。三轮交互闭环。 Tags: latest:1.0.2 Version history: v1.0.2 | 2026-04-16T10:23:04.566Z | auto quant-strategy-assistant 1.0.2 - Initial public release with full OpenClaw three-round interactive workflow for quant strategy development. - Added 175 files, including backtest orchestrator, data capability guard, and extensive QGDATA API documentation. - Suppor
Rank
62
Safety
84
Downloads
1.2k
Updated
Oct 10, 2026
Version
1.0.2
Source
CLAWHUB
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 1.2K downloads reported by the source. Last updated 10/10/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
- Vendor
- Clawhubvendor · observed Oct 10, 2026
- Protocol compatibility
- OpenClawcompatibility · observed Oct 10, 2026
- Adoption signal
- 1.2K downloadsadoption · observed Oct 10, 2026
- Latest release
- 1.0.2release · observed Apr 16, 2026
- Handshake status
- UNKNOWNsecurity
Install and run
Setup complexity: low.
clawhub skill install s17a7chdzm1hkmyebcb2fd07x583g5kd:quant-strategy-assistant- Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
- Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-listolany-quant-strategy-assistant/snapshot"
Documentation
CLAWHUB
75,371 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
---
name: quant-strategy-assistant
description: "量化策略助手:自然语言→策略生成→回测→优化→QMT模拟/实盘。三轮交互闭环。"
metadata:
requires:
bins: ["python3"]
openclaw:
requires:
bins: ["python3"]
---
# 量化策略助手
> **兼容说明**:本文档既是 OpenClaw Skill,也可作为任意 AI Agent 的操作手册。只要 Agent 能读取文件、执行命令、生成代码,即可按下方协议使用。YAML 头部的 `metadata.openclaw` 为 OpenClaw 平台专用字段,其他 Agent 忽略即可。
回测三轮交互闭环 → 用户按需选择参数优化 / 模拟实盘。
## 能力分层
| 能力 | 引擎 | 依赖 | 说明 |
|------|------|------|------|
| **CTA回测** | vnpy_ctastrategy | python3 + qgdata | 单标的择时策略,任意平台 |
| **Portfolio回测** | vnpy_portfoliostrategy | python3 + qgdata | 多标的组合/轮动策略,任意平台 |
| **参数优化** | vnpy OptimizationSetting | 同回测 | 回测后由用户触发,穷举/遗传算法 |
| **模拟/实盘** | miniQMT + vnpy CTA引擎 | QMT 交易端 | `qmt-check` 检测 → `trade` 启动自动交易,含探针单验证 |
回测是核心能力,不依赖 QMT。用户请求模拟/实盘时才运行 `qmt-check`。
### CTA vs Portfolio 自动路由(强制)
| 条件 | 模式 | 策略基类 |
|------|------|----------|
| 单一标的 + 无组合关键词 | `cta` | `CtaTemplate` |
| 以下任一条件满足 | `portfolio` | `StrategyTemplate`(vnpy_portfoliostrategy) |
**portfolio 判定规则(分层,LLM 和 `parse_requirement()` 均遵循)**:
1. **强信号**(任一出现即 portfolio):`轮动/组合/多标的/全市场/等权/仓位分配/前N名`
2. **弱信号 + 多标的上下文**(二者共现才 portfolio):弱信号 `排序/筛选/选股/调仓/排列/持仓周期` 需同时存在多标的上下文(`板块/成分股/指数/行业/概念/股票池`)
3. **标的数量 > 1**:`--symbols` 含 2 只以上自动 portfolio
注意:"多头排列"中的"排列"、"均线排序"在单标的场景不触发 portfolio。
路由由 `parse_requirement()` 自动判定并写入 `parsed["mode"]`,agent 生成策略代码时必须使用对应基类。
**Portfolio 引擎驱动约束**:Portfolio 回测引擎仅支持 DAILY 和分钟级驱动。周级策略用 `--interval DAILY`,在 `on_bars(bars)` 中按 `list(bars.values())[0].datetime.weekday()==0`(周一)判断调仓日;周线指标直接用 `pro.weekly()` 获取,无需从日线合成。
**股票池所有权契约(强制)**:股票池由 `--symbols` 参数唯一定义 → 引擎加载数据 → 策略通过 `self.vt_symbols` 接收。策略代码 `__init__` 中**禁止覆盖 `vt_symbols`**,必须使用引擎传入的列表。所有标的代码使用 vnpy 格式(`600519.SSE`/`000858.SZSE`),不可使用 qgdata 格式(`.SH/.SZ`)。选股逻辑在 `on_bars(bars)` 中基于 `self.vt_symbols` 遍历和筛选。
**板块/指数成分股由引擎自动解析(强制)**:用户说"人工智能板块"/"沪深300成分股"/"银行行业"等时,引擎会自动解析出完整成分股列表到 `--symbols`。策略代码中**禁止**自行调用 `pro.ths_member()`/`pro.ths_index()`/`pro.dc_member()` 等板块 API。
**回测日期约束(强制)**:用户的回测日期意图必须由你转换为标准 `--start YYYYMMDD --end YYYYMMDD` 参数。例如用户说"最近1年"则根据当天日期计算 today-365 输出对应日期。用户未提及任何日期时,**不传** `--start/--end`(引擎默认最近1年,即 today-365 ~ today)。第1轮确认摘要中日期栏必须写"引擎默认最近1年"而非自行编造"近2年"等。**禁止**编造与用户意图不符的固定日期。
### 模拟/实盘交易(独立流程,不走三轮协议)
用户提及 `模拟`/`实盘`/`模拟交易`/`开始交易`/`QMT` 时触发。**前提:至少有一次成功的回测(status=completed)。**
**第 1 步:环境检测**(自动发现 QMT 路径,无需用户手动配置路径)
```bash
"${PYTHON_BIN}" "${QUANTCLAW_ROOT}/backtests/pipeline_orchestrator.py" qmt-check
```
输出 JSON 含 `ready`(布尔)和 `hint`(状态说明):
- `platform != Windows` → 提示用户在 Windows + QMT 环境运行
- QMT 路径自动扫描失败 → 提示确认 QMT 已安装
- QMT 终端未运行 → 提示"请先打开 QMT 并以极简模式登录"
- 缺少资金账号 → 提示通过 `--account-id` 或 `QMT_ACCOUNT_ID` 提供
- `ready=true` → 进入第 2 步
**第 2 步:启动交易**(内含自动探针验证:100股跌停价挂单→确认→撤单,可选单独跑 `probe --symbol {代码} --account-id {账号}`)
```bash
"${PYTHON_BIN}" "${QUANTCLAW_ROOT}/backtests/pipeline_orchestrator.py" trade \
--run-id "{最近成功回测的 run_id}"
```
返回 JSON 分流:
- `status=trading_started` → 告知用户:✅ 交易已启动,附带日志路径
- `status=platform_redirect` → 告知用户:需在 Windows + QMT 环境运行,QMT-TradingClaw/vnpy_qmt/README.md
# VeighNa框架的QMT数据服务与交易接口
<p align="center">
<img src ="https://vnpy.oss-cn-shanghai.aliyuncs.com/vnpy-logo.png"/>
</p>
<p align="center">
<img src ="https://img.shields.io/badge/version-2.0.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows|linux-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.10|3.11|3.12-blue.svg" />
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
</p>
## 说明
基于迅投XtQuant和qgdata封装开发的数据服务与交易接口,提供双数据源支持:
* **qgdata数据源(回测首选)**:A股日线/分钟线/周线行情,跨平台支持
* **迅投研(XT)数据源**:实时行情、Tick数据、期货/期权市场,Windows平台
支持以下中国金融市场:
* 股票、基金、债券、ETF期权:
* SSE:上海证券交易所
* SZSE:深圳证券交易所
* BSE:北京证券交易所
* 期货、期货期权(仅XT数据源):
* CFFEX:中国金融期货交易所
* SHFE:上海期货交易所
* DCE:大连商品交易所
* CZCE:郑州商品交易所
* INE:上海国际能源交易中心
* GFEX:广州期货交易所
## 安装
安装环境推荐基于3.9.0版本以上的【[**VeighNa Studio**](https://www.vnpy.com/)】。
直接使用pip命令:
```
pip install vnpy_xt qgdata
```
完成基础安装后,克隆本项目代码并替换官方文件:
```bash
git clone https://gitee.com/GuojinQuant/vnpy_qmt.git
# 将 vnpy_qmt/vnpy_xt/ 目录内文件覆盖至官方安装路径:
# Linux/Mac: /usr/local/lib/python3.x/site-packages/vnpy_xt/
# Windows: %PYTHON_HOME%\Lib\site-packages\vnpy_xt\
# 提示:可通过 pip show vnpy_xt 查询确切安装路径
```
## 使用
### qgdata数据源连接(回测首选)
qgdata为回测默认数据源,支持A股日线、分钟线、周线行情查询,无需启动本地客户端,跨平台可用。
1. 安装qgdata:`pip install qgdata`
2. 获取token:访问 [**quantgo.ai/data**](https://quantgo.ai/data) 注册获取数据服务token
3. 在VeighNa Trader的【全局配置】处进行数据服务配置:
* datafeed.name:qg
* datafeed.username:留空
* datafeed.password:填写您的qgdata token(请勿将token提交到版本控制)
4. 支持的数据周期:1分钟(MINUTE)、1小时(HOUR)、日线(DAILY)、周线(WEEKLY)
5. 支持的市场:**仅A股** — 上交所(SSE)、深交所(SZSE)、北交所(BSE)
6. 注意事项:
* qgdata暂不支持Tick数据,如需Tick请切换至迅投研(XT)数据源
* 期货/期权市场(CFFEX/SHFE/DCE/CZCE/INE/GFEX)不在qgdata覆盖范围,请使用迅投研(XT)数据源
若需切换数据源,修改 `vnpy_xt/__init__.py` 中的导入:
```python
# 切换为迅投研数据源
from .xt_datafeed import XtDatafeed as Datafeed
# 切换为qgdata数据源(默认)
# from .qg_datafeed import QgDatafeed as Datafeed
```
### 迅投研(XT)数据源连接
**Token连接**
- 请使用官方版本
**客户端连接**
- 请使用官方版本
**券商miniQMT连接**
1. 连接请先登录迅投极速交易终端,同时确保xtquant模块可以正常加载(点击【下载Python库】-【Python库下载】,下载完成后拷贝"Python库路径"下Lib\site-packages文件夹中的xtquant包到自己使用的Python环境的site_packages文件夹下)。
2. 在VeighNa Trader的【全局配置】处进行数据服务配置:
* datafeed.name:xt
* datafeed.username:client
* datafeed.password:留空
3. 连接XT中配置:
* token:留空
* QMT路径:C:\国金QMT交易端模拟
* 资金账户:填写您在券商开户的资金账号
4. 请注意以客户端方式连接时,需要保持迅投客户端的运行。
## OpenClaw 回测报告公网持久化(新增)
在 `pipeline_orchestrator.py submit` 中,除短时 `monitor_url` 外,现可同时产出长期 `report_url`(静态报告)。
### 环境变量
- `MONITOR_PUBLIC_BASE`:短时监控页公网基址(可选,优先级最高)
- `OPENCLAW_CONTROL_URL`:OpenClaw 会话入口地址(可选;当 `MONITOR_PUBLIC_BASE` 为空时,系统会自动从该地址推导监控公网基址)
- `REPORT_PUBLIC_BASE`:长期静态报告公网基址(例如 `http://8.211.147.124/reports`)
- `REPORT_PUBLIC_DIR`:静态报告落盘目录(默认 `backtests/public_reports`,需由 Nginx/Caddy 映射到 `REPORT_PUBLIC_BASE`)
推荐做法(开源友好):
- 不在代码里写死任何机器 IP/路径;
_meta.json
{
"ownerId": "kn73ayd2pc6dgzpyqhpanbgax58244zz",
"slug": "quant-strategy-assistant",
"version": "1.0.2",
"publishedAt": 1776334984566
}references/apis/adj_factor.md
# `adj_factor` 接口文档
## 接口说明
- 中文说明:复权因子
- 动态方法:`pro.adj_factor(...)`
- 默认时间字段:`trade_date`
- 典型过滤参数:`trade_date`(必填), `start_date`(必填), `end_date`
- 主要字段:`ts_code`, `trade_date`, `adj_factor`
## 调用示例
```python
df = pro.adj_factor(
trade_date="",
start_date="",
end_date="",
fields="ts_code,trade_date,adj_factor",
order_by="trade_date",
sort="desc",
limit=50,
)
```references/apis/anns_d.md
# `anns_d` 接口文档
## 接口说明
- 中文说明:上市公司全量公告
- 动态方法:`pro.anns_d(...)`
- 默认时间字段:无
- 典型过滤参数:`ann_date`(必填), `start_date`(必填), `end_date`
- 主要字段:`ann_date`, `ts_code`, `name`, `title`, `url`, `rec_time`
## 调用示例
```python
df = pro.anns_d(
ann_date="",
start_date="",
end_date="",
fields="ann_date,ts_code,name,title,url,rec_time",
order_by="ann_date",
sort="desc",
limit=50,
)
```
## 备注
该接口当前未启用,原因:抱歉,您没有接口访问权限。AionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
{
"facts": [
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/listolany/skills/quant-strategy-assistant",
"sourceUrl": "https://clawhub.ai/listolany/skills/quant-strategy-assistant",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-10T22:28:42.697Z",
"isPublic": true
},
{
"factKey": "protocols",
"category": "compatibility",
"label": "Protocol compatibility",
"value": "OpenClaw",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-listolany-quant-strategy-assistant/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-listolany-quant-strategy-assistant/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-10-10T22:28:42.697Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "1.2K downloads",
"href": "https://clawhub.ai/listolany/quant-strategy-assistant",
"sourceUrl": "https://clawhub.ai/listolany/quant-strategy-assistant",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-10T22:28:42.697Z",
"isPublic": true
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "1.0.2",
"href": "https://clawhub.ai/listolany/quant-strategy-assistant",
"sourceUrl": "https://clawhub.ai/listolany/quant-strategy-assistant",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-04-16T10:23:04.566Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"category": "security",
"label": "Handshake status",
"value": "UNKNOWN",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-listolany-quant-strategy-assistant/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-listolany-quant-strategy-assistant/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true
}
],
"events": [
{
"eventType": "release",
"title": "Release 1.0.2",
"description": "quant-strategy-assistant 1.0.2 - Initial public release with full OpenClaw three-round interactive workflow for quant strategy development. - Added 175 files, including backtest orchestrator, data capability guard, and extensive QGDATA API documentation. - Supports natural language to code generation, automatic backtesting, parameter optimization, and QMT simulated/real trading. - Comprehensive documentation provided for engine configuration, trigger words, routing rules, environment checks, and core principles. - Enforced strict separation of CTA and portfolio routes with strong compliance rules for code generation and environment validation.",
"href": "https://clawhub.ai/listolany/quant-strategy-assistant",
"sourceUrl": "https://clawhub.ai/listolany/quant-strategy-assistant",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-04-16T10:23:04.566Z",
"isPublic": true
}
]
}Record generated Oct 10, 2026.
