|
| 1 | +<p align="center"> |
| 2 | + <img src="./docs/assets/evotraders_logo.jpg" width="45%"> |
| 3 | +</p> |
| 4 | + |
| 5 | +<h2 align="center">EvoTraders: A Self-Evolving Multi-Agent Trading System</h2> |
| 6 | + |
| 7 | +<p align="center"> |
| 8 | + 📌 <a href="https://trading.evoagents.com">Visit us at EvoTraders website !</a> |
| 9 | +</p> |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +EvoTraders is an open-source financial trading agent framework that builds a trading system capable of continuous learning and evolution in real markets through multi-agent collaboration and memory systems. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Core Features |
| 18 | + |
| 19 | +**Multi-Agent Collaborative Trading** |
| 20 | +A team of 6 members, including 4 specialized analyst roles (fundamentals, technical, sentiment, valuation) + portfolio manager + risk management, collaborating to make decisions like a real trading team. |
| 21 | + |
| 22 | +You can customize your Agents here: [Custom Configuration](#custom-configuration) |
| 23 | + |
| 24 | +**Continuous Learning and Evolution** |
| 25 | +Based on the ReMe memory framework, agents reflect and summarize after each trade, preserving experience across rounds, and forming unique investment methodologies. |
| 26 | + |
| 27 | +Through this design, we hope that when AI Agents form a team and enter the real-time market, they will gradually develop their own trading styles and decision preferences, rather than one-time random inference. |
| 28 | + |
| 29 | +**Real-Time Market Trading** |
| 30 | +Supports real-time market data integration, providing backtesting mode and live trading mode, allowing AI Agents to learn and make decisions in real market fluctuations. |
| 31 | + |
| 32 | +**Visualized Trading Information** |
| 33 | +Observe agents' analysis processes, communication records, and decision evolution in real-time, with complete tracking of return curves and analyst performance. |
| 34 | + |
| 35 | +<p> |
| 36 | + <img src="./docs/assets/performance.png" width="45%"> |
| 37 | + <img src="./docs/assets/dashboard.jpg" width="45%"> |
| 38 | +</p> |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## Quick Start |
| 43 | + |
| 44 | +### Installation |
| 45 | + |
| 46 | +```bash |
| 47 | +# Clone repository |
| 48 | +git clone https://github.com/agentscope-ai/agentscope-samples |
| 49 | +cd agentscope-samples/EvoTraders |
| 50 | + |
| 51 | +# Install dependencies (Recommend uv!) |
| 52 | +uv pip install -e . |
| 53 | +# optional: pip install -e . |
| 54 | + |
| 55 | + |
| 56 | +# Configure environment variables |
| 57 | +cp env.template .env |
| 58 | +# Edit .env file and add your API Keys. The following config are required: |
| 59 | + |
| 60 | +# finance data API: At minimum, FINANCIAL_DATASETS_API_KEY is required, corresponding to FIN_DATA_SOURCE=financial_datasets; It is recommended to add FINNHUB_API_KEY, corresponding to FIN_DATA_SOURCE=finnhub; If using live mode, FINNHUB_API_KEY must be added |
| 61 | +FIN_DATA_SOURCE = #finnhub or financial_datasets |
| 62 | +FINANCIAL_DATASETS_API_KEY= #Required |
| 63 | +FINNHUB_API_KEY= #Optional |
| 64 | + |
| 65 | +# LLM API for Agents |
| 66 | +OPENAI_API_KEY= |
| 67 | +OPENAI_BASE_URL= |
| 68 | +MODEL_NAME=qwen3-max-preview |
| 69 | + |
| 70 | +# LLM & embedding API for Memory |
| 71 | +MEMORY_API_KEY= |
| 72 | +``` |
| 73 | + |
| 74 | +### Running |
| 75 | + |
| 76 | +**Backtest Mode:** |
| 77 | +```bash |
| 78 | +evotraders backtest --start 2025-11-01 --end 2025-12-01 |
| 79 | +``` |
| 80 | + |
| 81 | +**Live Trading:** |
| 82 | +```bash |
| 83 | +evotraders live # Run immediately (default) |
| 84 | +evotraders live --mock # Mock mode (testing) |
| 85 | +evotraders live -t 22:30 # Run daily at 22:30 local time (auto-converts to NYSE timezone) |
| 86 | +``` |
| 87 | + |
| 88 | +**Launch Visualization Interface:** |
| 89 | +```bash |
| 90 | +# Ensure npm is installed |
| 91 | +evotraders frontend # Default connects to port 8765, you can modify the address in ./frontend/env.local to change the port number |
| 92 | +``` |
| 93 | + |
| 94 | +Visit `http://localhost:5173/` to view the trading room, select a date and click Run/Replay to observe the decision-making process. |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## System Architecture |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +### Agent Design |
| 103 | + |
| 104 | +**Analyst Team:** |
| 105 | +- **Fundamentals Analyst**: Financial health, profitability, growth quality |
| 106 | +- **Technical Analyst**: Price trends, technical indicators, momentum analysis |
| 107 | +- **Sentiment Analyst**: Market sentiment, news sentiment, insider trading |
| 108 | +- **Valuation Analyst**: DCF, residual income, EV/EBITDA |
| 109 | + |
| 110 | +**Decision Layer:** |
| 111 | +- **Portfolio Manager**: Integrates analysis signals from analysts, executes communication strategies, combines analyst and team historical performance, recent investment memories, and long-term investment experience to make final decisions |
| 112 | +- **Risk Management**: Real-time price and volatility monitoring, position limits, multi-layer risk warnings |
| 113 | + |
| 114 | +### Decision Process |
| 115 | + |
| 116 | +``` |
| 117 | +Real-time Market Data → Independent Analysis → Intelligent Communication (1v1/1vN/NvN) → Decision Execution → Performance Evaluation → Learning and Evolution (Memory Update) |
| 118 | +``` |
| 119 | + |
| 120 | +Each trading day goes through five stages: |
| 121 | + |
| 122 | +1. **Analysis Stage**: Each agent independently analyzes based on their respective tools and historical experience |
| 123 | +2. **Communication Stage**: Exchange views through private chats, notifications, meetings, etc. |
| 124 | +3. **Decision Stage**: Portfolio manager makes comprehensive judgments and provides final trades |
| 125 | +4. **Evaluation Stage** |
| 126 | + - **Performance Charts**: Track portfolio return curves vs. benchmark strategies (equal-weighted, market-cap weighted, momentum). Used to evaluate overall strategy effectiveness. |
| 127 | + |
| 128 | + - **Analyst Rankings**: Click on avatars in the Trading Room to view analyst performance (win rate, bull/bear market win rate). Used to understand which analysts provide the most valuable insights. |
| 129 | + |
| 130 | + - **Statistics**: Detailed position and trading history. Used for in-depth analysis of position management and execution quality. |
| 131 | + |
| 132 | +5. **Review Stage**: Agents reflect on decisions and summarize experiences based on actual returns of the day, and store them in the ReMe memory framework for continuous improvement |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +### Module Support |
| 137 | + |
| 138 | +- **Agent Framework**: [AgentScope](https://github.com/agentscope-ai/agentscope) |
| 139 | +- **Memory System**: [ReMe](https://github.com/agentscope-ai/reme) |
| 140 | +- **LLM Support**: OpenAI, DeepSeek, Qwen, Moonshot, Zhipu AI, etc. |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +## Custom Configuration |
| 145 | + |
| 146 | +### Custom Analyst Roles |
| 147 | + |
| 148 | +1. Register role information in [./backend/agents/prompts/analyst/personas.yaml](./backend/agents/prompts/analyst/personas.yaml), for example: |
| 149 | + |
| 150 | +```yaml |
| 151 | +comprehensive_analyst: |
| 152 | + name: "Comprehensive Analyst" |
| 153 | + focus: |
| 154 | + - ... |
| 155 | + preferred_tools: # Flexibly select based on situation |
| 156 | + description: | |
| 157 | + As a comprehensive analyst ... |
| 158 | +``` |
| 159 | +
|
| 160 | +2. Add role definition in [./backend/config/constants.py](./backend/config/constants.py) |
| 161 | +```python |
| 162 | +ANALYST_TYPES = { |
| 163 | + # Add new analyst |
| 164 | + "comprehensive_analyst": { |
| 165 | + "display_name": "Comprehensive Analyst", |
| 166 | + "agent_id": "comprehensive_analyst", |
| 167 | + "description": "Uses LLM to intelligently select analysis tools, performs comprehensive analysis", |
| 168 | + "order": 15 |
| 169 | + } |
| 170 | +} |
| 171 | +``` |
| 172 | + |
| 173 | +3. Introduce new role in frontend configuration [./frontend/src/config/constants.js](./frontend/src/config/constants.js) (optional) |
| 174 | +```javascript |
| 175 | +export const AGENTS = [ |
| 176 | + // Override one of the agents |
| 177 | + { |
| 178 | + id: "comprehensive_analyst", |
| 179 | + name: "Comprehensive Analyst", |
| 180 | + role: "Comprehensive Analyst", |
| 181 | + avatar: `${ASSET_BASE_URL}/...`, |
| 182 | + colors: { bg: '#F9FDFF', text: '#1565C0', accent: '#1565C0' } |
| 183 | + } |
| 184 | +] |
| 185 | +``` |
| 186 | + |
| 187 | +### Custom Models |
| 188 | + |
| 189 | +Configure models used by different agents in the [.env](.env) file: |
| 190 | + |
| 191 | +```bash |
| 192 | +AGENT_SENTIMENT_ANALYST_MODEL_NAME=qwen3-max-preview |
| 193 | +AGENT_FUNDAMENTALS_ANALYST_MODEL_NAME=deepseek-chat |
| 194 | +AGENT_TECHNICAL_ANALYST_MODEL_NAME=glm-4-plus |
| 195 | +AGENT_VALUATION_ANALYST_MODEL_NAME=moonshot-v1-32k |
| 196 | +``` |
| 197 | + |
| 198 | +### Project Structure |
| 199 | + |
| 200 | +``` |
| 201 | +EvoTraders/ |
| 202 | +├── backend/ |
| 203 | +│ ├── agents/ # Agent implementation |
| 204 | +│ ├── communication/ # Communication system |
| 205 | +│ ├── memory/ # Memory system (ReMe) |
| 206 | +│ ├── tools/ # Analysis toolset |
| 207 | +│ ├── servers/ # WebSocket services |
| 208 | +│ └── cli.py # CLI entry point |
| 209 | +├── frontend/ # React visualization interface |
| 210 | +└── logs_and_memory/ # Logs and memory data |
| 211 | +``` |
| 212 | + |
| 213 | +--- |
| 214 | + |
| 215 | +## License and Disclaimer |
| 216 | + |
| 217 | +EvoTraders is a research and educational project, open-sourced under the Apache 2.0 license. |
| 218 | + |
| 219 | +**Risk Warning**: Before trading with real funds, please conduct thorough testing and risk assessment. Past performance does not guarantee future returns. Investment involves risks, and decisions should be made with caution. |
0 commit comments