"不是要阻止你交易,而是要确保你想清楚了再交易。"
ReflectTrade 是一个基于 SpoonOS 框架构建的 AI 交易决策验证系统,通过对抗性辩论流程帮助交易者发现逻辑盲点。
uv gives faster, reproducible installs and works as a drop-in replacement for pip:
uv venv .venv
source .venv/bin/activate # macOS/Linux
# .\.venv\Scripts\Activate.ps1 # Windows (PowerShell)
# Install published packages
uv pip install spoon-ai-sdk # core framework
uv pip install spoon-toolkits # optional: extended blockchain & data toolkitsCreate a .env file in the project root:
# LLM Provider API Keys (set at least one)
GEMINI_API_KEY=your_gemini_key_here # recommended for Quick Start
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here
DEEPSEEK_API_KEY=your_deepseek_key_here
# Optional: Default LLM Settings
DEFAULT_LLM_PROVIDER=gemini
DEFAULT_MODEL=gemini-2.5-flash
# Research Tools (optional)
DESEARCH_API_KEY=your_desearch_key_here # for web search capabilities
# Web3 Configuration (only needed for on-chain tools)
WEB3_PROVIDER_URL=your_web3_provider_url
PRIVATE_KEY=your_wallet_private_keyReflectTrade/
├── .env # Environment variables (API keys)
├── my_first_agent.py # Basic ToolCall Agent demo
├── graph_agent.py # ReflectTrade Graph Agent workflow
└── docs/
├── workflow_architecture.md # Workflow design document
└── execution_report.md # Sample execution report
Basic SpoonOS agent with tool calling capabilities:
- GreetingTool - Custom tool for personalized greetings
- MyFirstAgent - Simple agent with greeting capabilities
- ResearchAgent - Extended agent with web search (DesearchWebSearchTool) and scraping (WebScraperTool)
python my_first_agent.pyReflectTrade core workflow - adversarial debate system for trade validation:
| Node | Function |
|---|---|
| 📝 Input | Parse user's trading reason (coin, price, logic) |
| 📊 Data Fetcher | Fetch negative/risk indicators |
| 😈 Hater | Generate 3 sharp challenging questions |
| 🛡️ Defense | Collect/simulate user's rebuttal |
| ⚖️ Judge | Evaluate if defense is reasonable |
| 💰 Settlement | Generate decision ID for on-chain attestation |
python graph_agent.pyWorkflow:
Input → Data Fetcher → Hater → Defense → Judge → Settlement
↑ ↓
└──────────┘ (if not reasonable)
重要说明:当前
data_fetcher_node使用的是 LLM 模拟生成的市场数据,不是真实数据!
目前的实现中,data_fetcher_node 会让 LLM 根据币种生成模拟的负面市场指标(资金费率、鲸鱼动向、清算数据等)。这些数据看起来很真实,但实际上是 AI 编造的,仅用于演示工作流逻辑。
为了获取真实市场数据,有两种策略可以实现:
使用 Desearch API 搜索实时新闻和市场分析:
from spoon_toolkits import DesearchWebSearchTool
# 在 data_fetcher_node 中调用
search_tool = DesearchWebSearchTool()
result = await search_tool.execute(
query=f"{coin} funding rate whale movement liquidation news",
num_results=10
)优点:
- 获取最新新闻和分析师观点
- 覆盖面广,可以发现非结构化的风险信号
- 无需对接多个数据源
缺点:
- 数据可能不够精确(新闻 vs 实时指标)
- 需要 LLM 进一步解析搜索结果
- 依赖 Desearch API 可用性
所需配置:
DESEARCH_API_KEY=your_desearch_api_key直接对接交易所/链上数据 API 获取精确指标:
from spoon_toolkits.crypto.crypto_powerdata.tools import CryptoPowerDataCEXTool
# 获取 CEX 市场数据
cex_tool = CryptoPowerDataCEXTool()
result = await cex_tool.execute(
exchange="binance",
symbol=f"{coin}/USDT",
data_type="funding_rate"
)可对接的数据源:
| 数据类型 | 可用 API |
|---|---|
| 💸 资金费率 | Binance, Bybit, OKX Perpetual API |
| 🐋 巨鲸动向 | Whale Alert, Arkham Intelligence |
| 📉 清算数据 | Coinglass, CoinGecko |
| 🔗 链上数据 | Glassnode, CryptoQuant, Dune Analytics |
优点:
- 数据精确、结构化
- 实时性强
- 可定制指标
缺点:
- 需要对接多个 API
- 部分 API 需要付费订阅
- 实现复杂度较高
所需配置:
BINANCE_API_KEY=your_binance_key
BINANCE_API_SECRET=your_binance_secret
GLASSNODE_API_KEY=your_glassnode_key
# ... 其他数据源 API keysSee docs/workflow_architecture.md for detailed workflow design.
See docs/execution_report.md for a formatted execution report example.
- spoon-ai-sdk - SpoonOS core framework
- spoon-toolkits - Extended blockchain & data toolkits
- Gemini API (or OpenAI/Anthropic/DeepSeek)
MIT