← 返回 Skills 市场
Crypto Trading Agents
作者
kriouerlia
· GitHub ↗
· v1.0.2
· MIT-0
203
总下载
1
收藏
0
当前安装
3
版本数
在 OpenClaw 中安装
/install crypto-trading-agents
功能描述
多Agent加密货币量化交易系统 — 基于 TradingAgents 多Agent框架 + Binance 执行层。 支持:技术分析、消息分析、多Agent辩论、自动化交易信号生成、Binance 现货下单。 适用场景:研究量化策略、自动交易Bot开发、加密货币组合分析。
使用说明 (SKILL.md)
Crypto Trading Agents
多Agent加密货币量化交易系统 | TradingAgents + Binance
系统架构
TradingAgents 多Agent框架
├── Technical Analyst (技术分析:RSI/MACD/Bollinger/ATR)
├── News Analyst (消息分析:市场新闻/宏观经济)
├── Sentiment Analyst (情绪分析:社交媒体情绪)
├── Fundamentals Analyst (基本面分析)
├── Bull/Bear Researcher (多空辩论)
└── Portfolio Manager (组合管理,生成交易信号)
↓
Binance Trader
├── 市价/限价下单
├── 止损/止盈
└── 仓位/挂单查询
↓
Binance 现货市场
环境要求
- Python 3.10+
- uv (推荐) 或 pip
- Binance API Key(现货权限即可,不需要合约)
- 网络连接(Binance API 访问)
快速安装
# 克隆项目
git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgents
# 创建虚拟环境
uv venv .venv --python 3.12
source .venv/bin/activate
# 安装核心依赖
pip install .
# 安装 CCXT(用于 Binance 对接)
uv pip install ccxt
# 可选:安装加密货币技术指标增强
uv pip install pandas numpy
环境变量配置
在项目根目录创建 .env 文件:
cp .env.example .env
编辑 .env,填入:
# ─── LLM API(TradingAgents 多Agent分析用)───
OPENAI_API_KEY=sk-... # OpenAI GPT
# 或
GOOGLE_API_KEY=... # Google Gemini
# 或
ANTHROPIC_API_KEY=... # Anthropic Claude
# ─── Binance API(交易执行用)───
BINANCE_API_KEY=your_api_key
BINANCE_API_SECRET=your_api_secret
# ─── 可选 ───
BINANCE_TESTNET=true # true = 使用测试网(不花真钱)
使用方法
方法一:Python API(推荐,开发用)
import tradingagents as ta
# ─── 1. 多Agent分析 ───────────────────────────
analyst = ta.CryptoAnalyst()
result = analyst.analyze("BTC/USDT", date="2026-03-24")
analyst.print_report(result)
# ─── 2. Binance 交易执行 ─────────────────────
trader = ta.BinanceTrader()
# 查询账户
print(trader.status("BTC/USDT"))
# 市价买入
print(trader.buy_market("BTC/USDT", amount=0.01))
# 限价买入
print(trader.buy_limit("BTC/USDT", amount=0.01, price=60000.0))
# 设置止损
print(trader.set_stop_loss("BTC/USDT", amount=0.01, stop_price=55000.0))
# ─── 3. 直接调用数据接口 ──────────────────────
from tradingagents.dataflows.binance_data import get_binance_ticker
from tradingagents.dataflows.crypto_indicators import get_crypto_indicators
# 实时行情(无需 API Key)
print(get_binance_ticker("BTC/USDT"))
# 技术指标(无需 API Key)
print(get_crypto_indicators("BTC/USDT", period="1d", lookback=60))
方法二:命令行(快速操作)
source .venv/bin/activate
# 分析(不需要 API Key)
python -m tradingagents.crypto_trading --symbol BTC/USDT --action analyze
python -m tradingagents.crypto_trading --symbol ETH/USDT --action analyze
# 账户状态
python -m tradingagents.crypto_trading --symbol BTC/USDT --action status
# 市价交易(需要 API Key)
python -m tradingagents.crypto_trading --symbol BTC/USDT --action trade --side buy --amount 0.01
# 限价交易
python -m tradingagents.crypto_trading --symbol BTC/USDT --action trade --side buy --amount 0.01 --price 60000
# 测试网交易
python -m tradingagents.crypto_trading --symbol BTC/USDT --action trade --side buy --amount 0.01 --testnet
方法三:直接使用 Binance Executor
from tradingagents.execution.binance_executor import (
execute_market_order,
execute_limit_order,
execute_stop_loss,
get_open_orders,
get_position,
)
# 查持仓
print(get_position("BTC/USDT"))
# 市价单
print(execute_market_order("BTC/USDT", "buy", 0.01))
# 限价单
print(execute_limit_order("BTC/USDT", "buy", 0.01, 60000.0))
# 止损单
print(execute_stop_loss("BTC/USDT", "sell", 0.01, 55000.0))
主要模块
| 模块 | 说明 |
|---|---|
tradingagents.crypto_trading |
主入口,CryptoAnalyst + BinanceTrader |
tradingagents.dataflows.binance_data |
Binance 数据源(K线/行情/订单簿) |
tradingagents.dataflows.crypto_indicators |
技术指标(RSI/MACD/Bollinger/ATR) |
tradingagents.agents.utils.binance_tools |
LangChain Tools,注入多Agent |
tradingagents.execution.binance_executor |
交易执行(市价/限价/止损) |
微信通知集成
系统内置 WeChatNotifier,当配置了企业微信 Webhook 后,所有交易活动自动推送:
export WECHAT_WEBHOOK_URL='https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX'
发送内容:
- 📡 交易信号:方向、价格、置信度、原因
- 📗 订单执行:买入/卖出、价格、数量、订单ID
- ❌ 错误报警:操作失败时即时通知
- 📊 账户状态:持仓、盈亏、挂单数
自动交易工作流
定时任务(Cron)
│
▼
AutoTradingSession.run("BTC/USDT")
│
├── CryptoAnalyst.analyze() ← 多Agent分析 + 微信推送信号
│
├── signal = 解析 agent_decision ← 信号解析(买入/卖出/观望)
│
├── trader.buy_market() ← 自动执行(可选)
│
├── trader.set_stop_loss() ← 自动设止损
│
└── WeChatNotifier 推送结果 ← 微信通知
命令行一键自动交易 + 微信通知
source .venv/bin/activate
# 自动分析 + 推送信号到微信(不交易)
python -m tradingagents.crypto_trading --symbol BTC/USDT --action analyze --notify
# 自动交易 + 微信通知
python -m tradingagents.crypto_trading --symbol BTC/USDT --action auto \
--auto-trade --amount 0.01 --stop-loss 0.05 --notify --testnet
# 手动交易 + 微信通知
python -m tradingagents.crypto_trading --symbol BTC/USDT --action trade \
--side buy --amount 0.01 --notify
Python API(带微信通知)
import tradingagents as ta
# 初始化(会自动读取 WECHAT_WEBHOOK_URL 环境变量)
notifier = ta.WeChatNotifier()
session = ta.AutoTradingSession(
auto_trade=False, # True = 自动执行交易
notify=True,
testnet=True,
)
# 运行:分析 → 信号 → 微信推送 →(可选)自动交易
result = session.run("BTC/USDT", buy_amount=0.01, stop_loss_pct=0.05)
# 单独使用通知器
notifier.notify_signal("BTC/USDT", "买入", 65000.0, "高", "RSI超卖 + MACD金叉")
notifier.notify_trade("BTC/USDT", "buy", 0.01, 65000.0, "123456", "已执行")
附:完整交易策略 Pine Script
scripts/hourly_contrarian_strategy.pine — 完整版策略(291行),包含:
- MA60 多周期方向评分系统(4H + 日线)
- 顺势信号(回踩MA60 / 回踩前低 / 回抽前高)
- K线形态过滤(锤子线 / 吞没形态 / 流星)
- 逆反思维信号(极端情绪 + 量能突增)
- 盈亏比 2:1 止损止盈
- TP1 保本移动止损
- 仪表盘(方向 / 评分 / MA60斜率 / 杠杆)
- Webhook 告警(支持 Binance 自动下单)
# 获取策略文件
cat scripts/hourly_contrarian_strategy.pine
复制内容到 TradingView Pine Editor 即可使用。
策略建议
- 先用测试网:
BINANCE_TESTNET=true,不花真钱 - 先回测:用历史数据分析策略效果
- 小资金实盘:先用最小单位(0.001 BTC)验证
- 必设止损:每次开仓都要设止损,不要裸奔
安全提示
- 不要把 API Secret 提交到 Git
- 建议使用只读 + 现货交易权限的 API Key,不要用全权限
- 生产环境建议用 VPS + Docker 部署,不要在本地电脑跑
- 这是一个研究框架,实盘风险自负
故障排除
| 问题 | 解决方法 |
|---|---|
No module named 'ccxt' |
uv pip install ccxt |
BINANCE_API_KEY not set |
检查 .env 文件是否配置 |
Insufficient data |
减少 lookback 参数 |
| API Rate Limit | CCXT 已内置限流,等待即可 |
| Network Error | 检查网络连接,确认 Binance 区域可用 |
安全使用建议
Before installing or running this skill: 1) Treat the registry metadata omission as a red flag — the SKILL.md requires sensitive keys (Binance API key/secret, optional LLM API keys, WeChat webhook). Expect to supply secrets. 2) Do NOT run scripts/setup.sh or any curl | sh commands without reviewing them; the installer fetches https://astral.sh/uv/install.sh which is not a central package host. Consider manually installing dependencies (virtualenv, pip) instead. 3) Create Binance API keys with minimal permissions (spot trading only, no withdrawals) and prefer testnet (BINANCE_TESTNET=true) while testing. 4) Inspect the upstream GitHub repository (https://github.com/TauricResearch/TradingAgents.git) and the package code before running, and verify the repository identity/maintainer. 5) Keep secrets out of shared files; use a dedicated secrets manager or environment variables scoped to the test environment. 6) If you enable auto-trading, start with very small amounts and monitor logs; consider running first in an isolated VM or container. If you want, I can list concrete checks to run on the GitHub repo's code (search for network calls, hidden webhooks, or commands that could withdraw funds) or produce safer install commands that avoid piping remote scripts.
功能分析
Type: OpenClaw Skill
Name: crypto-trading-agents
Version: 1.0.2
The skill bundle provides a framework for automated crypto trading but contains high-risk patterns. Specifically, `scripts/setup.sh` executes a `curl | sh` command to install the `uv` package manager, which is a significant security risk for remote code execution. Additionally, the `SKILL.md` instructions and the system's core functionality involve handling highly sensitive Binance API keys and LLM credentials to perform automated financial transactions, which are high-risk capabilities that could be exploited if the underlying `tradingagents` library or the environment is compromised.
能力评估
Purpose & Capability
The skill claims to be a multi‑agent crypto trading system and the SKILL.md legitimately requires Binance API keys, optional LLM API keys (OpenAI/Google/Anthropic) and a WeChat webhook for notifications — these are appropriate for the described functionality. However, the registry metadata declares no required environment variables or primary credential while the documentation clearly instructs creating a .env with multiple sensitive keys; that metadata omission is an inconsistency that reduces transparency.
Instruction Scope
The SKILL.md instructions stay within the stated domain: cloning a GitHub repo, creating a virtualenv, installing dependencies, reading a .env, calling LLMs for analysis, and executing trades via Binance. This scope is expected for an automated trading skill. Risks to note: the instructions enable automatic live trading (CLI flags and AutoTradingSession can execute market orders) so a user can accidentally trade real funds if BINANCE_TESTNET is not set or API keys have broad permissions.
Install Mechanism
There is no formal registry install spec, but scripts/setup.sh will curl a remote installer (https://astral.sh/uv/install.sh) and pipe it to sh to install 'uv'. Downloading and executing a remote install script from a non‑centralized host is higher risk and should be reviewed manually before running. The remainder of the install (creating venv, pip install .) is typical.
Credentials
The environment variables required by the runtime (OPENAI_API_KEY/GOOGLE_API_KEY/ANTHROPIC_API_KEY, BINANCE_API_KEY, BINANCE_API_SECRET, WECHAT_WEBHOOK_URL) are proportionate to the functionality. The concern is that the skill metadata does not declare these required credentials, which hides the fact that sensitive secrets will be used. Also note: providing Binance API keys grants trading capability; keys with withdrawal permissions would be dangerous.
Persistence & Privilege
The skill is not marked always:true and does not request system-level persistence or cross-skill configuration. It runs as an instruction-only package and its scripts create and use a local virtual environment and pip installs, which is normal for Python projects.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install crypto-trading-agents - 安装完成后,直接呼叫该 Skill 的名称或使用
/crypto-trading-agents触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.2
v1.0.2: 新增完整版 Pine Script 策略(291行 MA60评分系统+K线形态+逆反信号+Webhook告警),整合 Boss 原始交易策略
v1.0.1
v1.0.1: 新增微信通知集成(WeChatNotifier),支持分析信号/订单执行/错误报警自动推送,新增AutoTradingSession自动化交易会话,支持--notify参数
v1.0.0
Initial release: TradingAgents多Agent框架 + Binance执行层
元数据
常见问题
Crypto Trading Agents 是什么?
多Agent加密货币量化交易系统 — 基于 TradingAgents 多Agent框架 + Binance 执行层。 支持:技术分析、消息分析、多Agent辩论、自动化交易信号生成、Binance 现货下单。 适用场景:研究量化策略、自动交易Bot开发、加密货币组合分析。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 203 次。
如何安装 Crypto Trading Agents?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install crypto-trading-agents」即可一键安装,无需额外配置。
Crypto Trading Agents 是免费的吗?
是的,Crypto Trading Agents 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Crypto Trading Agents 支持哪些平台?
Crypto Trading Agents 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Crypto Trading Agents?
由 kriouerlia(@kriouerlia)开发并维护,当前版本 v1.0.2。
推荐 Skills