Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By quantskillsGPL-3.0In 1 marketplace
Evaluates trading safeguards in offline replay with duplicate input, prompt perturbation, missing quotes, and timeout retries.
Claude hands work to one, or you mention it with @.
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
QuantSkills 社区发布维护者:abgyjaguo。
简体中文 | English
当需要评测 AI 交易员在异常数据和重复请求下是否守住交易约束时,使用此 skill。支持四类故障注入(同输入重复、提示扰动、缺失行情、超时/重试)、市场无关的约束判定器、有/无校验层前后对照,输出约束违反率、拦截率、误拦率、重复动作率与拒绝执行表现。外部系统也可只提交决策意图进行回放,无需提供订单或成交记录。
AI 交易员在正常输入下可能表现良好,但在重复下单、提示扰动、行情缺失、超时重试等异常场景下容易突破交易约束(最小交易单位、T+1、涨跌停禁单、停牌/ST 过滤、仓位上限、强平时间窗)。
本 skill 构造这一类故障场景,回放被测系统的决策链路,并对比「有约束校验层」与「无约束校验层」两种情况的违反率,给出可量化的增量价值(ARR / RRR / NNT)。
├── SKILL.md ← 技能设计书
├── README.md ← 本文件
├── README.en.md ← English version
├── LICENSE ← GPL-3.0
├── INSTALL.md ← 多平台安装指南
├── requirements.txt ← 运行依赖
├── requirements-dev.txt ← 测试依赖
├── skill.json ← Skill 元数据
├── CHANGELOG.md ← 版本记录
├── agents/ ← 运行时适配器
│ ├── cursor-rule.mdc ← Cursor
│ ├── portable-loader.md ← Hermes / OpenClaw
│ └── openai.yaml ← Codex / OpenClaw
├── config/
│ └── eval_config.yaml ← 评测阈值与案例数集中管理
├── baselines/ ← 冻结基线(.gitignore 排除)
├── scripts/
│ ├── build.py ← 标准入口 run(input_data, config=None)
│ ├── run_eval.py ← CLI 编排器(参数驱动)
│ ├── compare_baseline.py ← 冻结基线 freeze/compare/list
│ ├── constraints_evaluator.py ← 市场无关约束判定器
│ ├── replay_engine.py ← 回放引擎(有/无校验层对照)
│ ├── intent_replay.py ← 外部决策意图接入(只回放、不执行)
│ ├── injector.py ← 四类故障注入
│ ├── market_rules.py ← MarketRules 协议
│ ├── rules/ ← A股 / 港股 / 股指期货 / 商品期货 / 加密
│ ├── config.py ← 配置加载与降级
│ ├── env_check.py ← 环境自检
│ ├── validate.py ← JSONL 事件契约校验
│ ├── fixture_generator.py ← 夹具生成(消费 MCP 导出 JSON)
│ ├── mcp_source.py ← MCP 信封解析 / 截断与缺列校验
│ └── sut_adapter.py ← 被测系统接入适配器
├── tests/ ← 单元测试
├── references/
│ ├── api_guide.md ← CLI / API 与字段说明
│ ├── constraint_trigger_map.md ← 约束触发条件映射表
│ ├── validation_evidence.md ← 实测验证记录(可复现)
│ ├── intent_replay.md ← 意图接入契约、拦截/误拦指标口径
│ └── data_access.md ← 数据接入说明(MCP 取数、来源、离线边界)
└── fixtures/ ← 评测夹具(确定性、无凭证)
├── generated/ ← 自动生成夹具
├── manual/ ← 手工夹具
└── intent_replay/ ← 合成决策意图接入格式示例
运行结果写入 output/;默认忽略可再生文件,但 report.json、sut 判别臂报告、两臂事件流与逐条配对证据按 .gitignore 白名单随包交付。
# 0. 先过 SKILL.md 的「前置检查」:任一不过即停,只报告缺什么
# 1. 安装测试依赖(评测执行本身只用标准库)
pip install -r requirements-dev.txt
# 2. 运行单元测试
python3 -m pytest tests/ -v
# 3. 完整评测
python3 scripts/build.py
# 或使用 CLI
python3 scripts/run_eval.py
# 4. 环境自检
python3 scripts/env_check.py --self-check --json
from scripts.build import run
report = run({}) # 全量评测
report = run("fixtures/") # 指定夹具目录
report = run({
"cases_dir": "fixtures/",
"output_dir": "output/",
"market_id": "CN_A_STOCK",
"injection_types": ["duplicate", "missing_quote"],
})
run(input_data, config=None) 中 input_data 支持 dict 或 fixture 目录路径字符串;config 为评测配置覆盖项。输入非法时抛 InputValidationError。
python3 scripts/run_eval.py --cases-dir fixtures/ --output-dir output/
python3 scripts/run_eval.py --injection-types duplicate missing_quote
python3 scripts/run_eval.py --market-id CN_A_STOCK
python3 scripts/validate.py output/events_with_checks.jsonl --json
| 产物 | 说明 |
|---|---|
output/report.json | 默认 stub 臂聚合报告(违反率、拦截率、误拦率、假放行率、ARR/RRR/NNT),不是宿主 agent 结果 |
output/report_sut_discriminative.json | sut 判别臂聚合报告;与下列三个逐事件文件同属一次运行 |
output/report_persona_trader_v1.json | persona 判别臂聚合报告(宿主 agent 在冻结激进交易人格下盲测作答,79.44%→0%、143/143 全拦、0 误拦、p=1.603e-32) |
output/agent_decisions_persona_v1.json | persona 臂 180 条作答原件(协议 agent-decisions@1,作答率 100%) |
output/events_with_checks.jsonl | sut 判别臂有校验层事件流,was_blocked 给出实际拦截 |
output/events_without_checks.jsonl | 同批 sut 事件的无校验参照臂,hard_violations 是误拦判据参照 |
output/pairwise_comparison.jsonl | 两臂逐事件配对,含双方 event ID、输入指纹、正确拦截/误拦/级联字段 |
关键字段:run_id、total_events、model_id、config_hash、summary.*、effect_size.*。
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
constraint-stress-test@quantskills is listed by quantskills/registry — review the source before installing
npx claudepluginhub quantskills/registry --plugin constraint-stress-testPlugins from other owners that cover similar ground