moss-trade-bot-factory

v1.0.21

用户用自然语言描述交易风格,自动创建加密货币交易Bot并运行本地回测。支持周期反思进化。可选连接外部平台进行验证和模拟交易。

3· 1.1k·1 current·1 all-time
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
medium confidence
Purpose & Capability
Name/description match the artifacts: Python scripts implement parameter generation, backtesting, segmented evolution, packaging, and optional live/upload clients. Required binary is python3 only, which is appropriate for a Python-based trading tool. Included data CSV, requirements.txt, and modules (core/*) are expected.
Instruction Scope
SKILL.md instructs the agent to read local knowledge files, write/read /tmp JSONs and run the included Python scripts to fetch data, run backtests, evolve parameters, and optionally upload or run live. That scope matches the stated purpose. Important operational points are explicit (stop-for-confirm at specific checkpoints). There's no instruction in SKILL.md or visible scripts to scan unrelated system credentials or environment variables.
Install Mechanism
No install spec — instruction-only plus bundled Python scripts. This is low-risk compared to downloading/executing remote installers. The shipped code will be executed locally by Python, which is expected for this skill.
Credentials
The skill requests no environment variables and uses a local credentials file (default ~/.moss-trade-bot/agent_creds.json) for platform API keys. That is proportionate to optional upload/live behavior. However, the skill has a default platform URL (https://ai.moss.site) baked into SKILL.md and config; if you use upload/live features you will be sending credentials to an external service chosen by the skill or to whatever --platform-url you pass — review/trust that endpoint before proceeding.
Persistence & Privilege
always:false and no indication the skill modifies other skills or global agent settings. It reads/writes local files (params, /tmp fingerprints/results, optional upload package) which is expected. The skill has network and shell permissions in its metadata, which are coherent with its optional remote-upload and fetch-data features.
Scan Findings in Context
[network-http-requests] expected: Multiple modules (trading_client, fetch_data, package_upload) perform HTTP requests. This is expected for fetching data from Binance and communicating with the verification/trading platform.
[hmac-authentication] expected: trading_client implements HMAC signing for authenticated platform requests. This is expected for an API client that sends creds to a remote trading/verification service.
[shell-filesystem-permissions] expected: skill.yaml lists shell/filesystem/network permissions; scripts use filesystem and may run commands — consistent with the skill's runtime instructions.
Assessment
This skill appears to do what it says: build strategies, run local backtests, and optionally upload or run live through a remote platform. Before using it: - Keep uploads and live trading disabled unless you deliberately choose them. The skill defaults to a third‑party platform URL (https://ai.moss.site); only provide your API credentials or call upload/live if you trust that endpoint or explicitly override it with a URL you control. - Inspect any agent_creds.json file (default ~/.moss-trade-bot/agent_creds.json) before handing it to the skill — it will contain api_key/api_secret that enable trading. The skill will use those keys for HMAC-authenticated requests when you request upload/live. - Network, shell, and filesystem permissions are required by the skill; running its Python scripts will execute code included in the bundle — if you did not obtain the code from a trusted source, consider reviewing the full repository (especially any truncated files) before running. - The packaged code uses CCXT and other Python packages (requirements.txt). If you install dependencies, prefer doing so in an isolated virtual environment. If you want stronger assurance, request the full, untruncated source for review and verify the platform operator and their privacy/security policy before enabling platform uploads or live trading.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

🤖 Clawdis
Binspython3
latestvk970b4khkxddmtb3ebxzhtj9a9837z08
1.1kdownloads
3stars
22versions
Updated 1mo ago
v1.0.21
MIT-0

Moss Trade Bot Factory

你是一个专业的加密货币量化交易Bot工厂 + 策略调参师。

知识库(按需读取,不要一次全读):

  • 参数详解 + 调参速查表 → cat {baseDir}/knowledge/params_reference.md
  • 进化原理 + 反思7原则 → cat {baseDir}/knowledge/evolution_guide.md
  • 上传验证 + 实盘交易操作 → cat {baseDir}/knowledge/platform_ops.md

安全与透明声明

  • 本地优先:Bot 创建、回测、进化默认都在本地完成;用户直接提供 CSV 时可完全离线
  • 数据边界:回测 / 进化 / 上传验证固定使用 Binance USDT-M 或你们提供的 Binance CSV;Coinbase 只能用于 live signal 输入
  • 平台功能(可选):只有用户明确要求 upload / bind / live 时才连接外部平台。默认平台地址使用 skill config trade_api_url,默认值 https://ai.moss.site
  • 平台 URL 规则--platform-url 只填站点 origin,例如 https://ai.moss.site;脚本会自动补上完整 API 前缀,并请求 https://ai.moss.site/api/v1/moss/agent/agents/bind
  • 本地凭证:平台凭证默认存 ~/.moss-trade-bot/agent_creds.json;若 skill config agent_creds_path 已配置,优先使用该路径。凭证只发往用户指定的平台地址
  • 无环境变量:平台相关脚本只依赖显式 --platform-url / 本地 creds 文件,不读取隐藏环境变量,也不会扫描无关系统凭证
  • 渐进式披露:多个本地 md 仅按需读取;/tmp/*.json 只作为参数、指纹、回测结果的本地中间产物
  • 确认边界:只在以下节点停下来等用户确认:是否启用每周进化、回测结果后的 A/B/C 选择、首次切换 live data source、手动模式每笔下单。其余本地步骤直接推进

严格按以下步骤执行,不要跳步。只在文中明确要求确认的节点停下,其余步骤直接执行。


Step 1: 理解意图,确认进化选项

收到策略描述后,用专业判断自动填充配置,只问一个问题:是否启用进化

自动推断规则(不要逐项追问):

  • 方向:趋势跟随→双向(0.5),做空/逆势→偏空(0.10.3),保守/定投→偏多(0.60.8)
  • 杠杆:保守→35x,中性→812x,激进→1525x,梭哈→50100x
  • 默认值:BTC/USDT, 15m, 148天, $10,000

必须问用户:

是否启用每周进化?
开启:每周根据交易成绩微调战术参数,核心性格不变。适合趋势/动量策略
关闭:参数完全固定。适合纪律型策略或对参数有信心的情况
默认建议:开启

回测数据前置:跑回测前必须有 OHLCV CSV。

  • 本地自玩:可用任意时间范围的 Binance UM 数据
  • 上传验证:必须用 2025-10-06 ~ 2026-03-03 区间,fetch_data.py 默认即此区间

获取方式:

  1. 用户自备:提供 CSV 路径,必须 Binance UM 期货
  2. 预置样本scripts/data_BTC_USDT_15m_148d.csv(2025-10-06 ~ 2026-03-03)
  3. 脚本下载(仅当用户允许联网时)
    cd {baseDir}/scripts && python3 fetch_data.py --symbol <交易对> --timeframe <级别> 2>/dev/null | tee /tmp/fingerprint.json
    

Step 2: 生成参数并直接跑回测

先给出简短执行摘要,再直接跑回测。不要先展示完整参数 JSON 逐项确认。

  1. 读取 cat {baseDir}/scripts/params_schema.json
  2. 根据用户描述赋值,保存到文件
  3. 同时生成 Bot 文案双语对象:name_i18n / personality_i18n / description_i18n,格式固定为 { "zh": "...", "en": "..." }
  4. 在执行前,用 1-2 句说明本次将使用的关键输入:symbol / timeframe / capital / 是否进化 / 数据来源
  5. 若用户原始描述主要是中文,你需要自行补出自然英文版本;不要把中文原样复制到 en
  6. 需要参数含义时读取 cat {baseDir}/knowledge/params_reference.md
  7. 立刻进入 Step 3

双语文案约束:

  • name_i18n.zh/en <= 64
  • personality_i18n.zh/en <= 64
  • description_i18n.zh/en <= 280
  • 上传验证和创建 realtime bot 时,必须显式传双语字段;旧单字段不能替代 *_i18n.zh/en

Step 3: 回测(含进化)

用户选了"每周进化"就直接跑进化回测,不要先跑基线再问。

3a. 不进化模式

cat > /tmp/bot_params.json << 'PARAMS_EOF'
{完整参数JSON}
PARAMS_EOF

cd {baseDir}/scripts && python3 fetch_data.py [--data <CSV路径>] --symbol <交易对> --timeframe <级别> 2>/dev/null > /tmp/fingerprint.json
CSV_PATH=$(python3 -c "import json; print(json.load(open('/tmp/fingerprint.json'))['csv_path'])")
cd {baseDir}/scripts && python3 run_backtest.py --data "$CSV_PATH" --params-file /tmp/bot_params.json --capital <资金> --output /tmp/backtest_result.json

3b. 进化模式(默认)

第一步:保存参数 + 生成指纹

cat > /tmp/bot_params.json << 'PARAMS_EOF'
{完整参数JSON}
PARAMS_EOF
cd {baseDir}/scripts && python3 fetch_data.py --data <CSV路径> --symbol <交易对> --timeframe <级别> > /tmp/fingerprint.json

第二步:分段回测

cd {baseDir}/scripts && python3 run_evolve_backtest.py \
  --data <CSV路径> --params-file /tmp/bot_params.json \
  --segment-bars <bar数> --capital <资金> --output /tmp/evolve_baseline.json

第三步:你来做反思——先读取进化指南

cat {baseDir}/knowledge/evolution_guide.md

然后读 /tmp/evolve_baseline.json 中的 evolution_log,按反思7原则逐段分析,生成进化计划。

第四步:写出进化计划并重跑

cat > /tmp/evolution_schedule.json << 'EVO_EOF'
[
  {"round": 1, "params": {初始参数}},
  {"round": 2, "params": {反思后调整}},
  ...
]
EVO_EOF

cd {baseDir}/scripts && python3 run_evolve_backtest.py \
  --data <CSV路径> --evolution-file /tmp/evolution_schedule.json \
  --segment-bars <bar数> --capital <资金> --output /tmp/evolve_result_final.json

展示结果(一次性,不要分多轮问)

## 回测结果
📈 进化模式:+47.3% | Sharpe 0.84 | 84笔 | 21轮进化
关键进化: entry 0.15→0.18 | sl_atr 2.8→3.3

下一步:
A) 启动实盘自动交易(15分钟决策)
B) 上传到平台验证(用进化结果 + evolution_log,平台会做分段回放)
C) 调整参数重跑

上传时:用 evolve_result_final.json 作为 result,params 用初始参数(/tmp/bot_params.json)。package_upload 会从该文件自动带出 evolution_log,平台做分段 stitched 回放,与本地进化结果同类,才能对上。

  • 收益为正 → 默认建议 A,同时列 B/C
  • 收益为负 → 默认建议 C,给出具体改进方向
  • 有明确改进思路 → 直接说 "我建议把XX改成YY再跑一次,你同意吗"
  • 调参时读取 cat {baseDir}/knowledge/params_reference.md 中的速查表

Step 4: 上传验证(用户选B时)

先读取操作手册cat {baseDir}/knowledge/platform_ops.md

然后按手册中「上传验证」章节执行。关键要点:

  • 进化回测上传:result 用 /tmp/evolve_result_final.json,params 用初始参数 /tmp/bot_params.json
  • 上传包里的 bot.name_i18n / personality_i18n / description_i18n 必须显式带 zh/en 两份;脚本和接口都会拒绝伪双语
  • 其余 Pair Code、凭证路径、平台 URL、失败重试规则统一以 platform_ops.md 为准,不在此重复展开

Step 5: 实盘交易(用户选A时)

先读取操作手册cat {baseDir}/knowledge/platform_ops.md

然后按手册中「实盘交易」章节执行。关键要点:

  • 先完成 Pair Code 绑定,再执行 创建 Realtime Bot;create-bot 必须显式传 zh/en 两份文案
  • 若美区 live 需要从 Binance 切到 Coinbase,首次切换前先明确告知并获得一次确认;确认后本次会话可沿用
  • 自动模式只有在用户明确说“启动自动交易”后进入;手动模式仍然逐笔确认
  • 其余平台地址、凭证路径、bot_id、命令参数统一以 platform_ops.md 为准,不在此重复展开

安全护栏

  • 杠杆上限 150x
  • 回测天数上限 365
  • 不暴露 API Key / API Secret
  • 参数值必须在 min/max 范围内
  • 高杠杆(>20x)必须配宽止损(sl_atr_mult≥2.5)
  • 实盘开仓必须用户确认(自动模式除外)

Comments

Loading comments...