File: README.md
๐ฆ OWL: Optimized Workforce Learning for General Multi-Agent Assistance in Real-World Task Automation
๐ Table of Contents
- ๐ Table of Contents
- ๐ฅ News
- ๐ฌ Demo Video
- โจ๏ธ Core Features
- ๐ ๏ธ Installation
- ๐ Quick Start
- ๐งฐ Toolkits and Capabilities
- ๐ Web Interface
- ๐งช Experiments
- ๐ License
- ๐ค Contributing
- ๐ฅ Community
- โ FAQ
- ๐ Exploring CAMEL Dependency
- ๐๏ธ Cite
- โญ Star History
๐ฅ News
- [2025.09.22]: Exicited to announce that OWL has been accepted by NeurIPS 2025!๐ Check the latest paper here.
- [2025.07.21]: We open-sourced the training dataset and model checkpoints of OWL project. Training code coming soon. huggingface link.
- [2025.05.27]: We released the technical report of OWL, including more details on the workforce (framework) and optimized workforce learning (training methodology). paper.
- [2025.05.18]: We open-sourced an initial version for replicating workforce experiment on GAIA here.
- [2025.04.18]: We uploaded OWL's new GAIA benchmark score of 69.09%, ranking #1 among open-source frameworks. Check the technical report here.
- [2025.03.27]: Integrate SearxNGToolkit performing web searches using SearxNG search engine.
- [2025.03.26]: Enhanced Browser Toolkit with multi-browser support for "chrome", "msedge", and "chromium" channels.
- [2025.03.25]: Supported Gemini 2.5 Pro, added example run code
- [2025.03.21]: Integrated OpenRouter model platform, fix bug with Gemini tool calling.
- [2025.03.20]: Accept header in MCP Toolkit, support automatic playwright installation.
- [2025.03.16]: Support Bing search, Baidu search.
- [2025.03.12]: Added Bocha search in SearchToolkit, integrated Volcano Engine model platform, and enhanced Azure and OpenAI Compatible models with structured output and tool calling.
- [2025.03.11]: We added MCPToolkit, FileWriteToolkit, and TerminalToolkit to enhance OWL agents with MCP tool calling, file writing capabilities, and terminal command execution.
- [2025.03.09]: We added a web-based user interface that makes it easier to interact with the system.
- [2025.03.07]: We open-sourced the codebase of the ๐ฆ OWL project.
- [2025.03.03]: OWL achieved the #1 position among open-source frameworks on the GAIA benchmark with a score of 58.18.
๐ฌ Demo Video
https://github.com/user-attachments/assets/2a2a825d-39ea-45c5-9ba1-f9d58efbc372
This video demonstrates how to install OWL locally and showcases its capabilities as a cutting-edge framework for multi-agent collaboration: https://www.youtube.com/watch?v=8XlqVyAZOr8
โจ๏ธ Core Features
- Online Search: Support for multiple search engines (including Wikipedia, Google, DuckDuckGo, Baidu, Bocha, etc.) for real-time information retrieval and knowledge acquisition.
- Multimodal Processing: Support for handling internet or local videos, images, and audio data.
- Browser Automation: Utilize the Playwright framework for simulating browser interactions, including scrolling, clicking, input handling, downloading, navigation, and more.
- Document Parsing: Extract content from Word, Excel, PDF, and PowerPoint files, converting them into text or Markdown format.
- Code Execution: Write and execute Python code using interpreter.
- Built-in Toolkits: Access to a comprehensive set of built-in toolkits including:
- Model Context Protocol (MCP): A universal protocol layer that standardizes AI model interactions with various tools and data sources
- Core Toolkits: ArxivToolkit, AudioAnalysisToolkit, CodeExecutionToolkit, DalleToolkit, DataCommonsToolkit, ExcelToolkit, GitHubToolkit, GoogleMapsToolkit, GoogleScholarToolkit, ImageAnalysisToolkit, MathToolkit, NetworkXToolkit, NotionToolkit, OpenAPIToolkit, RedditToolkit, SearchToolkit, SemanticScholarToolkit, SymPyToolkit, VideoAnalysisToolkit, WeatherToolkit, BrowserToolkit, and many more for specialized tasks
๐ ๏ธ Installation
**Prerequisites**
Install Python
Before installing OWL, ensure you have Python installed (version 3.10, 3.11, or 3.12 is supported):
Note for GAIA Benchmark Users: When running the GAIA benchmark evaluation, please use the
gaia58.18branch which includes a customized version of the CAMEL framework in theowl/cameldirectory. This version contains enhanced toolkits with improved stability specifically optimized for the GAIA benchmark compared to the standard CAMEL installation.
# Check if Python is installed
python --version
# If not installed, download and install from https://www.python.org/downloads/
# For macOS users with Homebrew:
brew install [email protected]
# For Ubuntu/Debian:
sudo apt update
sudo apt install python3.10 python3.10-venv python3-pip**Installation Options**
OWL supports multiple installation methods to fit your workflow preferences.
Option 1: Using uv (Recommended)
# Clone github repo
git clone https://github.com/camel-ai/owl.git
# Change directory into project directory
cd owl
# Install uv if you don't have it already
pip install uv
# Create a virtual environment and install dependencies
uv venv .venv --python=3.10
# Activate the virtual environment
# For macOS/Linux
source .venv/bin/activate
# For Windows
.venv\Scripts\activate
# Install CAMEL with all dependencies
uv pip install -e .Option 2: Using venv and pip
# Clone github repo
git clone https://github.com/camel-ai/owl.git
# Change directory into project directory
cd owl
# Create a virtual environment
# For Python 3.10 (also works with 3.11, 3.12)
python3.10 -m venv .venv
# Activate the virtual environment
# For macOS/Linux
source .venv/bin/activate
# For Windows
.venv\Scripts\activate
# Install from requirements.txt
pip install -r requirements.txt --use-pep517Option 3: Using conda
# Clone github repo
git clone https://github.com/camel-ai/owl.git
# Change directory into project directory
cd owl
# Create a conda environment
conda create -n owl python=3.10
# Activate the conda environment
conda activate owl
# Option 1: Install as a package (recommended)
pip install -e .
# Option 2: Install from requirements.txt
pip install -r requirements.txt --use-pep517Option 4: Using Docker
**Using Pre-built Image (Recommended)**
# This option downloads a ready-to-use image from Docker Hub
# Fastest and recommended for most users
docker compose up -d
# Run OWL inside the container
docker compose exec owl bash
cd .. && source .venv/bin/activate
playwright install-deps
xvfb-python examples/run.py**Building Image Locally**
# For users who need to customize the Docker image or cannot access Docker Hub:
# 1. Open docker-compose.yml
# 2. Comment out the "image: mugglejinx/owl:latest" line
# 3. Uncomment the "build:" section and its nested properties
# 4. Then run:
docker compose up -d --build
# Run OWL inside the container
docker compose exec owl bash
cd .. && source .venv/bin/activate
playwright install-deps
xvfb-python examples/run.py**Using Convenience Scripts**
# Navigate to container directory
cd .container
# Make the script executable and build the Docker image
chmod +x build_docker.sh
./build_docker.sh
# Run OWL with your question
./run_in_docker.sh "your question"**Setup Environment Variables**
OWL requires various API keys to interact with different services.
Setting Environment Variables Directly
You can set environment variables directly in your terminal:
macOS/Linux (Bash/Zsh):
bashexport OPENAI_API_KEY="your-openai-api-key-here" # Add other required API keys as neededWindows (Command Prompt):
batchset OPENAI_API_KEY=your-openai-api-key-hereWindows (PowerShell):
powershell$env:OPENAI_API_KEY = "your-openai-api-key-here"
Note: Environment variables set directly in the terminal will only persist for the current session.
Alternative: Using a `.env` File
If you prefer using a .env file instead, you can:
Copy and Rename the Template:
bash# For macOS/Linux cd owl cp .env_template .env # For Windows cd owl copy .env_template .envAlternatively, you can manually create a new file named
.envin the owl directory and copy the contents from.env_template.Configure Your API Keys:
Open the.envfile in your preferred text editor and insert your API keys in the corresponding fields.
Note: For the minimal example (
examples/run_mini.py), you only need to configure the LLM API key (e.g.,OPENAI_API_KEY).
**MCP Desktop Commander Setup**
If using MCP Desktop Commander within Docker, run:
npx -y @wonderwhy-er/desktop-commander setup --force-file-protocolFor more detailed Docker usage instructions, including cross-platform support, optimized configurations, and troubleshooting, please refer to DOCKER_README.md.
๐ Quick Start
Basic Usage
After installation and setting up your environment variables, you can start using OWL right away:
python examples/run.pyRunning with Different Models
Model Requirements
Tool Calling: OWL requires models with robust tool calling capabilities to interact with various toolkits. Models must be able to understand tool descriptions, generate appropriate tool calls, and process tool outputs.
Multimodal Understanding: For tasks involving web interaction, image analysis, or video processing, models with multimodal capabilities are required to interpret visual content and context.
Supported Models
For information on configuring AI models, please refer to our CAMEL models documentation.
Note: For optimal performance, we strongly recommend using OpenAI models (GPT-4 or later versions). Our experiments show that other models may result in significantly lower performance on complex tasks and benchmarks, especially those requiring advanced multi-modal understanding and tool use.
OWL supports various LLM backends, though capabilities may vary depending on the model's tool calling and multimodal abilities. You can use the following scripts to run with different models:
# Run with Claude model
python examples/run_claude.py
# Run with Qwen model
python examples/run_qwen_zh.py
# Run with Deepseek model
python examples/run_deepseek_zh.py
# Run with other OpenAI-compatible models
python examples/run_openai_compatible_model.py
# Run with Gemini model
python examples/run_gemini.py
# Run with Azure OpenAI
python examples/run_azure_openai.py
# Run with Ollama
python examples/run_ollama.pyFor a simpler version that only requires an LLM API key, you can try our minimal example:
python examples/run_mini.pyYou can run OWL agent with your own task by modifying the examples/run.py script:
# Define your own task
task = "Task description here."
society = construct_society(question)
answer, chat_history, token_count = run_society(society)
print(f"\033[94mAnswer: {answer}\033[0m")For uploading files, simply provide the file path along with your question:
# Task with a local file (e.g., file path: `tmp/example.docx`)
task = "What is in the given DOCX file? Here is the file path: tmp/example.docx"
society = construct_society(question)
answer, chat_history, token_count = run_society(society)
print(f"\033[94mAnswer: {answer}\033[0m")OWL will then automatically invoke document-related tools to process the file and extract the answer.
Example Tasks
Here are some tasks you can try with OWL:
- "Find the latest stock price for Apple Inc."
- "Analyze the sentiment of recent tweets about climate change"
- "Help me debug this Python code: [your code here]"
- "Summarize the main points from this research paper: [paper URL]"
- "Create a data visualization for this dataset: [dataset path]"
๐งฐ Toolkits and Capabilities
Model Context Protocol (MCP)
OWL's MCP integration provides a standardized way for AI models to interact with various tools and data sources:
Before using MCP, you need to install Node.js first.
**Install Node.js**
Windows
Download the official installer: Node.js.
Check "Add to PATH" option during installation.
Linux
sudo apt update
sudo apt install nodejs npm -yMac
brew install node**Install Playwright MCP Service**
npm install @executeautomation/playwright-mcp-server
npx playwright install-depsTry our comprehensive MCP examples:
examples/run_mcp.py- Basic MCP functionality demonstration (local call, requires dependencies)examples/run_mcp_sse.py- Example using the SSE protocol (Use remote services, no dependencies)
Available Toolkits
Important: Effective use of toolkits requires models with strong tool calling capabilities. For multimodal toolkits (Web, Image, Video), models must also have multimodal understanding abilities.
OWL supports various toolkits that can be customized by modifying the tools list in your script:
# Configure toolkits
tools = [
*BrowserToolkit(headless=False).get_tools(), # Browser automation
*VideoAnalysisToolkit(model=models["video"]).get_tools(),
*AudioAnalysisToolkit().get_tools(), # Requires OpenAI Key
*CodeExecutionToolkit(sandbox="subprocess").get_tools(),
*ImageAnalysisToolkit(model=models["image"]).get_tools(),
SearchToolkit().search_duckduckgo,
SearchToolkit().search_google, # Comment out if unavailable
SearchToolkit().search_wiki,
SearchToolkit().search_bocha,
SearchToolkit().search_baidu,
*ExcelToolkit().get_tools(),
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
*FileWriteToolkit(output_dir="./").get_tools(),
]Available Toolkits
Key toolkits include:
Multimodal Toolkits (Require multimodal model capabilities)
- BrowserToolkit: Browser automation for web interaction and navigation
- VideoAnalysisToolkit: Video processing and content analysis
- ImageAnalysisToolkit: Image analysis and interpretation
Text-Based Toolkits
- AudioAnalysisToolkit: Audio processing (requires OpenAI API)
- CodeExecutionToolkit: Python code execution and evaluation
- SearchToolkit: Web searches (Google, DuckDuckGo, Wikipedia)
- DocumentProcessingToolkit: Document parsing (PDF, DOCX, etc.)
Additional specialized toolkits: ArxivToolkit, GitHubToolkit, GoogleMapsToolkit, MathToolkit, NetworkXToolkit, NotionToolkit, RedditToolkit, WeatherToolkit, and more. For a complete list, see the CAMEL toolkits documentation.
Customizing Your Configuration
To customize available tools:
# 1. Import toolkits
from camel.toolkits import BrowserToolkit, SearchToolkit, CodeExecutionToolkit
# 2. Configure tools list
tools = [
*BrowserToolkit(headless=True).get_tools(),
SearchToolkit().search_wiki,
*CodeExecutionToolkit(sandbox="subprocess").get_tools(),
]
# 3. Pass to assistant agent
assistant_agent_kwargs = {"model": models["assistant"], "tools": tools}Selecting only necessary toolkits optimizes performance and reduces resource usage.
๐ Web Interface
Starting the Web UI
# Start the Chinese version
python owl/webapp_zh.py
# Start the English version
python owl/webapp.py
# Start the Japanese version
python owl/webapp_jp.pyFeatures
- Easy Model Selection: Choose between different models (OpenAI, Qwen, DeepSeek, etc.)
- Environment Variable Management: Configure your API keys and other settings directly from the UI
- Interactive Chat Interface: Communicate with OWL agents through a user-friendly interface
- Task History: View the history and results of your interactions
The web interface is built using Gradio and runs locally on your machine. No data is sent to external servers beyond what's required for the model API calls you configure.
๐งช Experiments
To reproduce OWL's GAIA benchmark score:
We also provide an enhanced OWL in the main branch, so you can directly benefit from upgraded toolkits and increased stability even without switching branches.
For the original GAIA-specific performance, we recommend our gaia69 branch.
When running the benchmark evaluation:
Switch to the
gaia69branch:bashgit checkout gaia69Run the evaluation script:
bashpython run_gaia_workforce_claude.py
This will execute the same configuration that achieved our top-ranking performance on the GAIA benchmark.
๐ License
The source code is licensed under Apache 2.0.
๐ค Contributing
We welcome contributions from the community! Here's how you can help:
- Read our Contribution Guidelines
- Check open issues or create new ones
- Submit pull requests with your improvements
Current Issues Open for Contribution:
To take on an issue, simply leave a comment stating your interest.
๐ฅ Community
Join us (Discord or WeChat) in pushing the boundaries of finding the scaling laws of agents.
Join us for further discussions!
โ FAQ
General Questions
Q: Why don't I see Chrome running locally after starting the example script?
A: If OWL determines that a task can be completed using non-browser tools (such as search or code execution), the browser will not be launched. The browser window will only appear when OWL determines that browser-based interaction is necessary.
Q: Which Python version should I use?
A: OWL supports Python 3.10, 3.11, and 3.12.
Q: How can I contribute to the project?
A: See our Contributing section for details on how to get involved. We welcome contributions of all kinds, from code improvements to documentation updates.
Experiment Questions
Q: Which CAMEL version should I use for replicate the role playing result?
A: We provide a modified version of CAMEL (owl/camel) in the gaia58.18 branch. Please make sure you use this CAMEL version for your experiments.
Q: Why are my experiment results lower than the reported numbers?
A: Since the GAIA benchmark evaluates LLM agents in a realistic world, it introduces a significant amount of randomness. Based on user feedback, one of the most common issues for replication is, for example, agents being blocked on certain webpages due to network reasons.
We have uploaded a keywords matching script to help quickly filter out these errors here.
You can also check this technical report for more details when evaluating LLM agents in realistic open-world environments.
๐ Exploring CAMEL Dependency
OWL is built on top of the CAMEL Framework, here's how you can explore the CAMEL source code and understand how it works with OWL:
Accessing CAMEL Source Code
# Clone the CAMEL repository
git clone https://github.com/camel-ai/camel.git
cd camel๐๏ธ Cite
If you find this repo useful, please cite:
@misc{hu2025owl,
title={OWL: Optimized Workforce Learning for General Multi-Agent Assistance in Real-World Task Automation},
author={Mengkang Hu and Yuhang Zhou and Wendong Fan and Yuzhou Nie and Bowei Xia and Tao Sun and Ziyu Ye and Zhaoxuan Jin and Yingru Li and Qiguang Chen and Zeyu Zhang and Yifeng Wang and Qianshuo Ye and Bernard Ghanem and Ping Luo and Guohao Li},
year={2025},
eprint={2505.23885},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2505.23885},
}โญ Star History
File: community_usecase/Airbnb-MCP/README.md
๐ก CAMEL-AI + MCP: Airbnb Use Case
This example demonstrates how to use the CAMEL-AI OWL framework and MCP (Model Context Protocol) to search for Airbnb listings using a custom MCP server (@openbnb/mcp-server-airbnb). Agents in the OWL framework coordinate to perform tool-augmented travel research in a structured, automated way.
โจ Use Case
โFind me the best Airbnb in Gurugram with a check-in date of 2025-06-01 and a check-out date of 2025-06-07 for 2 adults. Return the top 5 listings with their names, prices, and locations.โ
Agents leverage an MCP server to execute real-time Airbnb queries and return formatted results.
๐ฆ Setup
1. Clone and install dependencies
git clone https://github.com/camel-ai/owl
cd owl
pip install -r requirements.txt2. Configure MCP Server
In your mcp_servers_config.json, add the following:
{
"mcpServers": {
"airbnb": {
"command": "npx",
"args": [
"-y",
"@openbnb/mcp-server-airbnb",
"--ignore-robots-txt"
]
}
}
}๐ ๏ธ You will need Node.js and NPM installed. Run
npxwill automatically fetch the Airbnb MCP server.
3. Run the Example Script
python community_usecase/Airbnb_MCPYou can also customize the prompt inside the script itself. Edit the default_task section of Airbnb_MCP.py like this:
# Replace this line:
default_task = (
"here you need to add the task"
)
# Example:
default_task = (
"Find me the best Airbnb in Gurugram with a check-in date of 2025-06-01 "
"and a check-out date of 2025-06-07 for 2 adults. Return the top 5 listings with their names, "
"prices, and locations."
)This allows agents to work from your hardcoded task without passing anything via command line.
๐ง How It Works
- MCPToolkit reads the config and connects to the
@openbnb/mcp-server-airbnb. - OWL RolePlaying Agents simulate a conversation between a
content_curatorand aresearch_assistant. - The assistant agent calls the MCP Airbnb server to fetch listings.
- The results are processed, formatted, and printed.
๐ง Notes
- This script uses GPT-4o via OpenAI for both user and assistant roles.
- Supports async execution and graceful cleanup of agents and MCP sessions.
- Add retries and fallback logic for production use.
๐ References
---
## File: community_usecase/a_share_investment_agent_camel/README.md
<h1 align="center">
๐ฆA่กๆ่ตไปฃ็็ณป็ป
</h1>
[English](README_EN.md) |
[ไธญๆ](README.md) |
[่ด่ฐข](#-่ด่ฐข) |
[็คบไพ่ฟ่ก็ปๆ](#-็คบไพ่ฟ่ก็ปๆ)
</h4>
## ๐ ้กน็ฎ็ฎไป
ๆฌ้กน็ฎๆฏไธไธชๅบไบOWLๆกๆถๅCamelๆกๆถ(v0.2.36)็ๅคไปฃ็A่กๆ่ตๅๆ็ณป็ป๏ผ้่ฟๅคไธชไธไธ่ง่ฒไปฃ็ๅไฝๅฎๆๆ่ตๅๆ๏ผไธบ็จๆทๆไพๆ่ตๅณ็ญๅปบ่ฎฎใ็ณป็ป้็จๅคๆจกๅๆฏๆ๏ผๅฏ็ตๆดปไฝฟ็จไธๅ็ๅคง่ฏญ่จๆจกๅ๏ผๅฆGeminiใOpenAIใQwen๏ผ่ฟ่กๅๆใ
ๆฌ้กน็ฎๅไธไบOWL็คพๅบ็จไพๆๆ่ต๏ผๆฏๅฏนๅผๆบ้กน็ฎ[A_Share_investment_Agent](https://github.com/24mlight/A_Share_investment_Agent)็ๆน่ฟ็ๆฌ๏ผไฝฟ็จOWLๅCamelๆกๆถ้ๆๅฎ็ฐใ
### ๐ ๆ ธๅฟ็น็น
- **ๅคไปฃ็ๅไฝไฝ็ณป**: ้่ฟ10ไธชไธไธ่ง่ฒไปฃ็ๅไฝ่ฟ่กๅๆ๏ผๅฎ็ฐๆดๅ
จ้ขใไธไธ็ๆ่ตๅณ็ญ
- **ๅคๆจกๅๆฏๆ**: ๆฏๆGeminiใOpenAIใQwen็ญๅค็งๅคง่ฏญ่จๆจกๅ๏ผ็ตๆดปๅๆข
- **A่กๅธๅบ็นๅ**: ไธไธบA่กๅธๅบ่ฎพ่ฎก๏ผๅ
ณๆณจไธญๅฝ่กๅธ็นๆงๅๆฐๆฎ
- **่พฉ่ฎบไธๅณ็ญๆบๅถ**: ๅๆฐ็ๅค็ฉบ่ง็น่พฉ่ฎบๆบๅถ๏ผๅนณ่กกๅๆ่ง็น
- **ๅฎๆด็ๆฐๆฎๅค็ๆตๆฐด็บฟ**: ไปๆฐๆฎๆถ้ๅฐๅๆๅๅฐๅณ็ญ็ๅ
จๆต็จๆฏๆ
## ๐๏ธ ็ณป็ปๆถๆ
็ณป็ปๆถๆๅ
ๅซไปฅไธๅ ไธชๆ ธๅฟไปฃ็๏ผ
### ๐ ๆฐๆฎไธๅๆๅฑ
1. **ๅธๅบๆฐๆฎไปฃ็** (Market Data Agent) - ่ด่ดฃๆถ้ๅ้ขๅค็ๅธๅบๆฐๆฎ
2. **ๆๆฏๅๆไปฃ็** (Technical Analyst) - ๅๆๆๆฏๆๆ ๅนถ็ๆไบคๆไฟกๅท
3. **ๅบๆฌ้ขๅๆไปฃ็** (Fundamentals Analyst) - ๅๆๅบๆฌ้ขๆฐๆฎๅนถ็ๆไบคๆไฟกๅท
4. **ๆ
็ปชๅๆไปฃ็** (Sentiment Analyst) - ๅๆๅธๅบๆ
็ปชๅนถ็ๆไบคๆไฟกๅท
5. **ไปทๅผ่ฏไผฐไปฃ็** (Valuation Analyst) - ่ฎก็ฎ่ก็ฅจๅ
ๅจไปทๅผๅนถ็ๆไบคๆไฟกๅท
### ๐ ็ ็ฉถไธ่พฉ่ฎบๅฑ
6. **ๅคๅคด็ ็ฉถๅ** (Researcher Bull) - ๆไพ็ๅค่งๅบฆๅๆ
7. **็ฉบๅคด็ ็ฉถๅ** (Researcher Bear) - ๆไพ็็ฉบ่งๅบฆๅๆ
8. **่พฉ่ฎบๅฎค** (Debate Room) - ๆดๅๅค็ฉบ่ง็นๅฝขๆๆ็ป่ง็น
### ๐งฎ ๅณ็ญๅฑ
9. **้ฃ้ฉ็ฎก็ไปฃ็** (Risk Manager) - ่ฎก็ฎ้ฃ้ฉๆๆ ๅนถ่ฎพ็ฝฎไปไฝ้ๅถ
10. **ๆ่ต็ปๅ็ฎก็ไปฃ็** (Portfolio Manager) - ๅถๅฎๆ็ปไบคๆๅณ็ญๅนถ็ๆ่ฎขๅ
## ๐ป ๅฎ่ฃ
ๆๅ
### ๅๆๆกไปถ
- Python 3.9+
- ็ธๅ
ณAPIๅฏ้ฅ๏ผGemini/OpenAI/Qwen๏ผ
### ๅฎ่ฃ
ๆญฅ้ชค
1. ๅ
้OWLไปๅบๅนถ่ฟๅ
ฅ้กน็ฎ็ฎๅฝ
```bash
git clone https://github.com/camel-ai/owl.git
cd owl/community_usecase/a_share_investment_agent_camel
```
2. ๅฎ่ฃ
ไพ่ต
```bash
pip install -r requirements.txt
```
3. ้
็ฝฎ็ฏๅขๅ้๏ผๅๅปบ.envๆไปถ๏ผ
```
# Gemini้
็ฝฎ
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=gemini-1.5-flash
# OpenAI้
็ฝฎ
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4o
# Qwen้
็ฝฎ
QWEN_API_KEY=your_qwen_api_key
QWEN_MODEL=qwen-max
QWEN_API_URL=https://your-qwen-api-endpoint
```
### Docker ไฝฟ็จๆนๆณ
ไธบไบ็ฎๅๅฎ่ฃ
ๆต็จ๏ผๆไปฌๆไพไบDockerๆฏๆใ
1. ๆๅปบDocker้ๅ
```bash
docker build -t a-share-investment-agent .
```
2. ๅๅปบๅ
ๅซAPIๅฏ้ฅ็.envๆไปถ
```bash
# ๅๅปบไธไธ่ฟฐ็ธๅๆ ผๅผ็.envๆไปถ
touch .env
# ็ผ่พ.envๆไปถๆทปๅ ๆจ็APIๅฏ้ฅ
```
## ๐ ไฝฟ็จๆนๆณ
### ๅบๆฌ็จๆณ
```bash
python src/main.py --ticker 000001 --model qwen
```
### ๆต่ฏๆจกๅผ
```bash
# ไฝฟ็จ้ป่ฎคๅๆฐ๏ผQwenๆจกๅๅ000001่ก็ฅจ๏ผ่ฟ่กๆต่ฏ
python src/main.py --test
# ๆๅฎ่ก็ฅจ่ฟ่กๆต่ฏ
python src/main.py --test --ticker 600036
```
### ๅๆฐ่ฏดๆ
- `--ticker`: ่ก็ฅจไปฃ็
- `--start-date`: ๅผๅงๆฅๆ (YYYY-MM-DD)
- `--end-date`: ็ปๆๆฅๆ (YYYY-MM-DD)
- `--show-reasoning`: ๆพ็คบๅๆๆจ็่ฟ็จ
- `--num-of-news`: ๆ
็ปชๅๆไฝฟ็จ็ๆฐ้ปๆฐ้
- `--initial-capital`: ๅๅง็ฐ้้้ข
- `--initial-position`: ๅๅง่ก็ฅจๆไป
- `--model`: ไฝฟ็จ็ๆจกๅ (gemini, openai, qwen)
- `--test`: ไฝฟ็จ้ข่ฎพๅๆฐ่ฟ่กๆต่ฏๅ่ฝ
### ็คบไพ่ฟ่ก็ปๆ
ไปฅไธๆฏ้ๅฏนๅฏๆญฆ็บช-U(688256)่ก็ฅจๅจ2025/01/04-2025/03/24ๆ้ด็ๅๆ็ปๆ็คบไพ๏ผ
```bash
python src/main.py --ticker 688256 --start-date 2025-01-04 --end-date 2025-03-24 --model qwen --show-reasoning
```
#### ๅไปฃ็ๅๆๆฅๅฟ
**ๅธๅบๆฐๆฎไปฃ็**:
```json
{
"trend": "็ญๆ่ถๅฟๅไธ๏ผไฝ้ฟๆ่ถๅฟไป้่งๅฏ",
"judgment": "ๅฝๅไปทๆ ผๅคไบๅธๆๅธฆไธญ่ฝจไธๆน๏ผRSIๆฅ่ฟไธญๆงๆฐดๅนณ๏ผMACD็บฟๅจไฟกๅท็บฟไธๆน๏ผ่กจๆ็ญๆๅฏ่ฝ็ปง็ปญ่ฐๆดใไฝ่่ๅฐไนๅ็ๅคงๅน
ไธๆถจ๏ผ้ฟๆ่ถๅฟไป้่ฟไธๆญฅ่งๅฏใๅปบ่ฎฎๅ
ณๆณจๆฏๆไฝ670.66ๅ้ปๅไฝ747.57ใ"
}
```
**ๆๆฏๅๆไปฃ็**:
```json
{
"signal": "bearish",
"confidence": 0.8,
"reasoning": "ไปๆๆฏๆๆ ๆฅ็๏ผ่ฏฅ่ก็ฅจ็ฎๅๅคไบไธไธช็ธๅฏนๅผฑๅฟ็็ถๆใ้ฆๅ
๏ผ5ๆฅๅ็บฟ๏ผ718.856๏ผๅทฒ็ปไธ็ฉฟ10ๆฅๅ็บฟ๏ผ743.927๏ผๅ20ๆฅๅ็บฟ๏ผ747.574๏ผ๏ผ่ฟ่กจๆ็ญๆ่ถๅฟๆญฃๅจ่ตฐๅผฑใMACDๆๆ ไนๆพ็คบไบ็ฑปไผผ็่ถๅฟ๏ผMACD็บฟ๏ผ8.994๏ผไฝไบไฟกๅท็บฟ๏ผ20.004๏ผ๏ผๅนถไธMACDๆฑ็ถๅพ๏ผ-11.009๏ผไธบ่ดๅผ๏ผ่กจๆๅธๅบๅจ่ฝๆญฃๅจๅๅผฑใRSIๆๆ ๏ผ48.676๏ผๅคไบไธญๆงๅบๅ๏ผไฝๆฅ่ฟ่ถ
ๅๅบๅ๏ผ่ฟๅฏ่ฝ้ข็คบ็็ญๆๅ
ๅฏ่ฝไผๆๅๅผน๏ผไฝๆดไฝ่ถๅฟไป็ถๅๅผฑใๅธๆๅธฆๆน้ข๏ผๅฝๅไปทๆ ผ๏ผ685.05๏ผๆฅ่ฟๅธๆๅธฆไธ่ฝจ๏ผ670.657๏ผ๏ผ่ฟๅฏ่ฝๆไพไธๅฎ็ๆฏๆ๏ผไฝ่่ๅฐๅ
ถไปๆๆ ็ๅผฑๅฟ่กจ็ฐ๏ผๆฏๆๅๅบฆๅฏ่ฝๆ้ใ็ปผๅๆฅ็๏ผๅฝๅ็ๅธๅบ็ฏๅขๅๆๆฏๆๆ ๅๆๅไธไธชๅ็ฉบ็่ถๅฟใ"
}
```
**ๅบๆฌ้ขๅๆไปฃ็**:
```json
{
"signal": "bearish",
"confidence": 0.8,
"reasoning": "ๅฏๆญฆ็บช-U็่ดขๅก็ถๅตๅไธๅก่กจ็ฐๆพ็คบๅบๆๆพ็่ด้ข่ถๅฟใ้ฆๅ
๏ผๅ
ฌๅธ็ๅๅฉๆถฆๆ็ปญไธบ่ด๏ผไธไบๆ้ขๅจๆ่ฟๅ ไธชๅญฃๅบฆๆๆๅขๅ ๏ผ่ฟ่กจๆๅ
ฌๅธๅจ็ๅฉ่ฝๅๆน้ขๅญๅจไธฅ้้ฎ้ขใๅ
ถๆฌก๏ผๅ
ฌๅธ็่ฅไธๆถๅ
ฅ่ฝ็ถๅจ2023ๅนด็ฌฌๅๅญฃๅบฆๆๆๅข้ฟ๏ผไฝ้ๅๅ ไธชๅญฃๅบฆๅบ็ฐไบๆพ่ไธ้๏ผ่ฟๅฏ่ฝๆๅณ็ๅธๅบ้ๆฑๆๅ
ฌๅธๅธๅบไปฝ้ข็ๅๅฐใๆญคๅค๏ผๅ
ฌๅธ็ๅธ็็ไธบ่ด๏ผๅธๅ็้ซ่พพ52.58๏ผ่กจๆๅธๅบๅฏนๅ
ถไผฐๅผ่ฟ้ซ๏ผๅญๅจ่พๅคง็ๆณกๆฒซ้ฃ้ฉใไป่ดขๅกๅฅๅบท็ถๅตๆฅ็๏ผๅฐฝ็ฎกๅ
ฌๅธ็่ตไบง่ดๅบ็่พไฝ๏ผไฝๅ
ถ็ป่ฅ็ฐ้ๆตๆ็ปญไธบ่ด๏ผ่กจๆๅ
ฌๅธๅจ่ฟ่ฅ่ฟ็จไธญ้ขไธด่พๅคง็่ต้ๅๅใ็ปผๅไปฅไธๅ ็ด ๏ผๆไปฌ่ฎคไธบๅฏๆญฆ็บช-U็่ก็ฅจ็ฎๅๅคไบ็่ท็ถๆใ"
}
```
**ๆ
็ปชๅๆไปฃ็**:
```json
{
"signal": "bullish",
"confidence": 0.8,
"reasoning": "ไปๆฐ้ปๆฐๆฎๆฅ็๏ผๆดไฝๅธๅบๆ
็ปชๅๅ็งฏๆ๏ผ็งฏๆๆฐ้ปๆฐ้่ฟๅคไบๆถๆๆฐ้ปใๅฐฝ็ฎกๆไธๆกๆฐ้ปๆๅฐ่ฏ็ETFๅๅฏๆญฆ็บช-U็ไธ่ท๏ผไฝๅคงๅคๆฐๆฐ้ป้ฝๅผบ่ฐไบๅฏๆญฆ็บช-Uๅๅ
ถๆๅจๆฟๅ็็งฏๆ่กจ็ฐ๏ผๅ
ๆฌ่กไปทไธๆถจๅๆๆฏ็ช็ ด็ญใๆญคๅค๏ผๅฏๆญฆ็บช-U่ขซ็บณๅ
ฅๅฏๆถไธญๅฝA50ๆๆฐ็ๆถๆฏไน่กจๆๅธๅบๅฏนๅ
ถ้ฟๆๅๆฏๆไน่งๆๅบฆใ็คพไบคๅชไฝ่ฎจ่ฎบไนไธป่ฆ้ไธญๅจๅ
ฌๅธ็็งฏๆๅๅฑไธ๏ผ่ฟไธๆญฅๆฏๆไบ็ๆถจ็่ง็นใ",
"key_events": [
"ๅฏๆญฆ็บช-U่ขซ็บณๅ
ฅๅฏๆถไธญๅฝA50ๆๆฐ",
"ๅฏๆญฆ็บช-U่กไปทๅคๆฌกไธๆถจ",
"ไบบๅทฅๆบ่ฝAIETFๆไป่กๅฏๆญฆ็บช-Uๅคงๆถจ",
"ๆบๅ
ๅฏๅ
ๅคงๆจกๅๅๅธ"
]
}
```
**ไผฐๅผๅๆไปฃ็**:
```json
{
"signal": "bearish",
"confidence": 0.85,
"reasoning": "ๅฏๆญฆ็บช-U็่ดขๅก็ถๅตๅไธๅก่กจ็ฐๆพ็คบๅบๆๆพ็่ด้ข่ถๅฟใ้ฆๅ
๏ผๅ
ฌๅธ็ๅๅฉๆถฆๆ็ปญไธบ่ด๏ผไธไบๆ้ขๅจๆ่ฟๅ ไธชๅญฃๅบฆๆๆๅขๅ ๏ผ่ฟ่กจๆๅ
ฌๅธๅจ็ๅฉ่ฝๅๆน้ขๅญๅจไธฅ้้ฎ้ขใๅ
ถๆฌก๏ผๅ
ฌๅธ็่ฅไธๆถๅ
ฅ่ฝ็ถๅจ2023ๅนด็ฌฌๅๅญฃๅบฆๆๆๅข้ฟ๏ผไฝ้ๅๅ ไธชๅญฃๅบฆๅบ็ฐไบๆพ่ไธ้๏ผ่ฟๅฏ่ฝๆๅณ็ๅธๅบ้ๆฑๆๅ
ฌๅธๅธๅบไปฝ้ข็ๅๅฐใๆญคๅค๏ผๅ
ฌๅธ็ๅธ็็ไธบ่ด๏ผๅธๅ็้ซ่พพ52.58๏ผ่กจๆๅธๅบๅฏนๅ
ถไผฐๅผ่ฟ้ซ๏ผๅญๅจ่พๅคง็ๆณกๆฒซ้ฃ้ฉใไป่ดขๅกๅฅๅบท็ถๅตๆฅ็๏ผๅฐฝ็ฎกๅ
ฌๅธ็่ตไบง่ดๅบ็่พไฝ๏ผไฝๅ
ถ็ป่ฅ็ฐ้ๆตๆ็ปญไธบ่ด๏ผ่กจๆๅ
ฌๅธๅจ่ฟ่ฅ่ฟ็จไธญ้ขไธด่พๅคง็่ต้ๅๅใ็ปผๅไปฅไธๅ ็ด ๏ผๆไปฌ่ฎคไธบๅฏๆญฆ็บช-U็่ก็ฅจ็ฎๅๅคไบ็่ท็ถๆใๆญคๅค๏ผ้่ฟDCFๆจกๅๅ็ธๅฏนไผฐๅผๆณ่ฎก็ฎ๏ผๅ
ฌๅธ็ๅ
ๅจไปทๅผๆพ่ไฝไบๅฝๅๅธๅบไปทๆ ผ๏ผ่ฟไธๆญฅๆฏๆไบ็่ท็่ง็นใ",
"fair_value": 200.0,
"key_metrics": [
"ๅธ็็",
"ๅธๅ็",
"่ฅไธๆถๅ
ฅ",
"ๅๅฉๆถฆ",
"็ป่ฅ็ฐ้ๆต"
]
}
```
**ๅคๅคด็ ็ฉถๅ**:
```json
{
"key_points": [
"ๅธๅบๆ
็ปช็งฏๆ๏ผๆฐ้ปๅ็คพไบคๅชไฝ่ฎจ่ฎบๅๅไน่ง",
"ๅฏๆญฆ็บช-U่ขซ็บณๅ
ฅๅฏๆถไธญๅฝA50ๆๆฐ๏ผ่กจๆๅธๅบๅฏนๅ
ถ้ฟๆๅๆฏๆไน่งๆๅบฆ",
"ๆๆฏ็ช็ ดๅ่กไปทไธๆถจ็็งฏๆๆฐ้ป",
"ๅฐฝ็ฎกๆๆฏ้ขๅๅบๆฌ้ขๆพ็คบๅผฑๅฟ๏ผไฝๅธๅบๆ
็ปชๅๆฝๅจๅฌๅๅๅฏ่ฝๆจๅจ่กไปทๅๅผน"
],
"confidence": 0.6,
"reasoning": "ๅฐฝ็ฎกๆๆฏ้ขๅๅบๆฌ้ขๅๆๆพ็คบๅฏๆญฆ็บช-U็ฎๅๅคไบๅผฑๅฟ็ถๆ๏ผไฝๅธๅบๆ
็ปชๅๆฝๅจๅฌๅๅๅฏ่ฝๆจๅจ่กไปทๅๅผนใๅฏๆญฆ็บช-U่ขซ็บณๅ
ฅๅฏๆถไธญๅฝA50ๆๆฐ๏ผ่กจๆๅธๅบๅฏนๅ
ถ้ฟๆๅๆฏๆไน่งๆๅบฆใๆญคๅค๏ผๅ
ฌๅธ่ฟๆ็ๆๆฏ็ช็ ดๅ่กไปทไธๆถจ็็งฏๆๆฐ้ปไนๆฏๆไบ็ๆถจ็่ง็นใ่ฝ็ถๅฝๅ็่ดขๅก็ถๅตๅไผฐๅผ่พ้ซ๏ผไฝๅธๅบๆ
็ปชๅๆฝๅจ็็งฏๆๅ ็ด ๅฏ่ฝไธบ่กไปทๆไพๆฏๆใๅ ๆญค๏ผๆไปฌๅปบ่ฎฎๅจ็ญๆๅ
ไฟๆ่ฐจๆ
๏ผไฝ้ฟๆๆฅ็๏ผๅฏๆญฆ็บช-Uไปๅ
ทๆๆ่ตๆฝๅใ"
}
```
**็ฉบๅคด็ ็ฉถๅ**:
```json
{
"key_points": [
"ๆๆฏๆๆ ๆพ็คบ็ญๆ่ถๅฟ่ตฐๅผฑ",
"ๅๅฉๆถฆๆ็ปญไธบ่ดไธไบๆๅขๅ ",
"่ฅไธๆถๅ
ฅไธ้่กจๆๅธๅบ้ๆฑๅๅฐ",
"ๅธๅ็้ซ่พพ52.58๏ผไผฐๅผ่ฟ้ซ",
"็ป่ฅ็ฐ้ๆตๆ็ปญไธบ่ด๏ผ่ต้ๅๅๅคง",
"DCFๆจกๅๅ็ธๅฏนไผฐๅผๆณๆพ็คบๅ
ๅจไปทๅผไฝไบๅธๅบไปทๆ ผ"
],
"confidence": 0.8,
"reasoning": "็ปผๅๆๆฏๅๆใๅบๆฌ้ขๅๆใๅธๅบๆ
็ปชๅๆๅไผฐๅผๅๆ๏ผๅฏๆญฆ็บช-U็่ก็ฅจ็ฎๅๅคไบ็่ท็ถๆใๆๆฏๆๆ ๆพ็คบ็ญๆ่ถๅฟ่ตฐๅผฑ๏ผๅบๆฌ้ขๅๆๆพ็คบๅ
ฌๅธ็ๅฉ่ฝๅๅทฎใๅธๅบ้ๆฑๅๅฐใไผฐๅผ่ฟ้ซไธ่ต้ๅๅๅคงใๅฐฝ็ฎกๅธๅบๆ
็ปชๅๅ็งฏๆ๏ผไฝ่ฟไบ็งฏๆๆ
็ปชไธป่ฆ้ไธญๅจ็ญๆไบไปถไธ๏ผๆ ๆณๆฉ็้ฟๆๅบๆฌ้ข้ฎ้ขใไผฐๅผๅๆ่ฟไธๆญฅๆฏๆไบ็่ท็่ง็น๏ผๅ
ๅจไปทๅผๆพ่ไฝไบๅฝๅๅธๅบไปทๆ ผใๅ ๆญค๏ผๅปบ่ฎฎๅๅบๅฏๆญฆ็บช-U็่ก็ฅจใ"
}
```
**่พฉ่ฎบๅฎค**:
```json
{
"signal": "neutral",
"confidence": 0.7,
"reasoning": "ๅคๅคดๅ็ฉบๅคด็ ็ฉถๅ็่ง็น้ฝๆๅ
ถๅ็ๆงๅไพๆฎใๅคๅคด็ ็ฉถๅๅผบ่ฐๅธๅบๆ
็ปช็งฏๆใๅฏๆญฆ็บช-U่ขซ็บณๅ
ฅๅฏๆถไธญๅฝA50ๆๆฐไปฅๅๆๆฏ็ช็ ดๅ่กไปทไธๆถจ็็งฏๆๆฐ้ป๏ผ่ฟไบๅ ็ด ๅฏ่ฝๅจ็ญๆๅ
ไธบ่กไปทๆไพๆฏๆใ็ถ่๏ผ็ฉบๅคด็ ็ฉถๅๆๅบๆๆฏๆๆ ๆพ็คบ็ญๆ่ถๅฟ่ตฐๅผฑ๏ผๅบๆฌ้ขๅๆๆพ็คบๅ
ฌๅธ็ๅฉ่ฝๅๅทฎใๅธๅบ้ๆฑๅๅฐใไผฐๅผ่ฟ้ซไธ่ต้ๅๅๅคงใๅฐฝ็ฎกๅธๅบๆ
็ปชๅๅ็งฏๆ๏ผไฝ่ฟไบ็งฏๆๆ
็ปชไธป่ฆ้ไธญๅจ็ญๆไบไปถไธ๏ผๆ ๆณๆฉ็้ฟๆๅบๆฌ้ข้ฎ้ขใ็ปผๅๆฅ็๏ผ็ญๆๅ
ๅธๅบๆ
็ปชๅๆๆฏ็ช็ ดๅฏ่ฝๆจๅจ่กไปทๅๅผน๏ผไฝ้ฟๆๅบๆฌ้ข้ฎ้ขไป็ถๅญๅจ๏ผๅ ๆญคๅปบ่ฎฎไฟๆไธญ็ซๆๅบฆ๏ผ็ญๅพ
ๆดๅคๆ็กฎไฟกๅทใ",
"final_verdict": "ๅปบ่ฎฎๆ่ต่
ๅจ็ญๆๅ
ไฟๆ่ฐจๆ
๏ผๅ
ณๆณจๅธๅบๆ
็ปชๅๆๆฏ็ช็ ด็ๆ็ปญๆงใ้ฟๆๆฅ็๏ผ้่ฆๅฏๅๅ
ณๆณจๅ
ฌๅธ็ๅบๆฌ้ขๆนๅๆ
ๅต๏ผ็นๅซๆฏ็ๅฉ่ฝๅใๅธๅบ้ๆฑๅ่ต้ๅๅ็ญๆน้ขใๅจๆฒกๆๆดๅคๆ็กฎไฟกๅทไนๅ๏ผๅปบ่ฎฎไฟๆไธญ็ซๆๅบฆ๏ผ้ฟๅ
่ฟๅบฆไน่งๆๆฒ่งใ"
}
```
**้ฃ้ฉ็ฎก็ไปฃ็**:
```json
{
"max_position_size": 0.2,
"volatility": 0.15,
"risk_score": 0.7,
"max_drawdown": 0.25,
"suggested_position_size": 0.15,
"reasoning": "้ดไบ่ก็ฅจ688256่พ้ซ็ๆณขๅจๆงๅๅบๆฌ้ข้ฃ้ฉ๏ผๅปบ่ฎฎ้ๅ่ฐจๆ
ๆๅบฆใ่ฝ็ถ็ญๆๅ
ๅญๅจๆๆฏ็ช็ ด็ๅฏ่ฝๆง๏ผไฝ้ฟๆๆฅ็ๅ
ฌๅธ้ขไธด็ๅฉ่ฝๅๅทฎ็ญ้ฎ้ขใๅ ๆญค๏ผๅปบ่ฎฎๆงๅถๆไปๆฏไพไธ่ถ
่ฟ20%๏ผๅนถ่ฎพ็ฝฎ้ๅฝ็ๆญขๆ็นไปฅไฟๆค่ตๆฌใๅๆถ๏ผ้่ฟๅคๆ ทๅๆ่ตๆฅๅๆฃ้ฃ้ฉใ"
}
```
**ๆ่ต็ปๅ็ฎก็ไปฃ็๏ผๆ็ปๅณ็ญ๏ผ**:
```json
{
"action": "hold",
"quantity": 0,
"confidence": 0.8,
"reasoning": "็ปผๅ่่ๅ็ฑปๅๆๅธ็ไบคๆไฟกๅทใ่พฉ่ฎบ็ปๆใ้ฃ้ฉๅๆใๅฝๅๆ่ต็ปๅ็ถๅตไปฅๅๆๆฐๅธๅบไปทๆ ผ๏ผๆไปฌๅณๅฎๅฏน่ก็ฅจ688256้ๅๆๆ็ญ็ฅใๆๆฏๅๆๅๅบๆฌ้ขๅๆๅๆพ็คบ่ฏฅ่ก็ฅจๅคไบๅผฑๅฟ็ถๆ๏ผๆๆฏๆๆ ๆพ็คบ็ญๆ่ถๅฟ่ตฐๅผฑ๏ผๅบๆฌ้ขๆพ็คบๅ
ฌๅธ็ๅฉ่ฝๅๅทฎใๅธๅบ้ๆฑๅๅฐใไผฐๅผ่ฟ้ซไธ่ต้ๅๅๅคงใๅฐฝ็ฎกๆ
็ปชๅๆๆพ็คบๅธๅบๆ
็ปชๅๅ็งฏๆ๏ผไฝ่ฟไบ็งฏๆๆ
็ปชไธป่ฆ้ไธญๅจ็ญๆไบไปถไธ๏ผๆ ๆณๆฉ็้ฟๆๅบๆฌ้ข้ฎ้ขใ่พฉ่ฎบ็ปๆไนๅปบ่ฎฎๅจ็ญๆๅ
ไฟๆ่ฐจๆ
๏ผๅ
ณๆณจๅธๅบๆ
็ปชๅๆๆฏ็ช็ ด็ๆ็ปญๆงใ้ฟๆๆฅ็๏ผ้่ฆๅฏๅๅ
ณๆณจๅ
ฌๅธ็ๅบๆฌ้ขๆนๅๆ
ๅตใ้ฃ้ฉๅๆๅปบ่ฎฎๆงๅถๆไปๆฏไพไธ่ถ
่ฟ20%๏ผๅนถ่ฎพ็ฝฎ้ๅฝ็ๆญขๆ็นไปฅไฟๆค่ตๆฌใๅ ๆญค๏ผๆไปฌๅณๅฎๆๆถๆๆ่ฏฅ่ก็ฅจ๏ผ็ญๅพ
ๆดๅคๆ็กฎไฟกๅทใ"
}
```
#### ็ปผๅ็ป่ฎบ
**ๆ็ปๆ่ตๅณ็ญ**: ๆๆ (็ฝฎไฟกๅบฆ: 0.8)
ๅคไธชไธไธไปฃ็็ๅๆ็ปๆ่กจๆ๏ผๅฏๆญฆ็บช-U(688256)่ก็ฅจ็ฎๅๅคไบๆๆฏๅๅบๆฌ้ข็ๅผฑๅฟ็ถๆ๏ผไฝๅธๅบๆ
็ปชๅ็ญๆไบไปถๅฏ่ฝไธบ่กไปทๆไพๆฏๆใ็ปผๅ่่ๅๆน้ขๅ ็ด ๏ผ็ณป็ปๅปบ่ฎฎๅฏน่ฏฅ่ก็ฅจ้ๅๆๆ็ญ็ฅ๏ผๅฏๅๅ
ณๆณจๅ็ปญๅบๆฌ้ขๅๅๅๅธๅบๆ
็ปชๅๅใๅๆถ๏ผ้ฃ้ฉ็ฎก็ๅปบ่ฎฎๅฐ่ฏฅ่ก็ฅจ็ๆๅคงๆไปๆฏไพๆงๅถๅจๆ่ต็ปๅ็20%ไปฅๅ
๏ผๅนถ่ฎพ็ฝฎ้ๅฝ็ๆญขๆ็นไปฅๆงๅถ้ฃ้ฉใ
## ๐ ๆฐๆฎๆต็จ่ฏดๆ
็ณป็ป็ๆฐๆฎๆต็จ้ตๅพชไปฅไธๆญฅ้ชค๏ผ
1. **ๆฐๆฎ้้**: ๅธๅบๆฐๆฎไปฃ็้่ฟakshare APIๆถ้A่กๅธๅบๆฐๆฎๅๆฐ้ป
2. **ๅค็ปดๅๆ**: ็ฑ4ไธชไธไธๅๆไปฃ็๏ผๆๆฏใๅบๆฌ้ขใๆ
็ปชใไผฐๅผ๏ผ็ฌ็ซ่ฟ่กๅๆ
3. **ๆญฃๅ็ ็ฉถ**: ๅคๅคดๅ็ฉบๅคด็ ็ฉถๅๅๅซไป็ๅคๅ็็ฉบ่งๅบฆๆไพๅๆๆฅๅ
4. **่พฉ่ฎบๆดๅ**: ่พฉ่ฎบๅฎคๆดๅๅค็ฉบ่ง็นๅฝขๆๆ็ปๅๆๆ่ง
5. **้ฃ้ฉ่ฏไผฐ**: ้ฃ้ฉ็ฎก็ไปฃ็่ฏไผฐๆ่ต้ฃ้ฉๅนถ่ฎพ็ฝฎไบคๆ้ๅถ
6. **ๆ็ปๅณ็ญ**: ๆ่ต็ปๅ็ฎก็ไปฃ็ๅถๅฎๆ็ปไบคๆๅณ็ญๅนถ็ๆ่ฎขๅ
## ๐ ้กน็ฎ็ปๆ
```
community_usecase/a_share_investment_agent_camel/
โโโ src/ # ๆบไปฃ็ ็ฎๅฝ
โ โโโ agents/ # ไปฃ็ๅฎ็ฐ
โ โ โโโ base_agent.py # ไปฃ็ๅบ็ฑป
โ โ โโโ market_data_agent.py # ๅธๅบๆฐๆฎไปฃ็
โ โ โโโ technical_analyst.py # ๆๆฏๅๆไปฃ็
โ โ โโโ ...
โ โโโ tools/ # ๅทฅๅ
ทๆจกๅ
โ โ โโโ data_helper.py # ๆฐๆฎ่พ
ๅฉๅทฅๅ
ท
โ โโโ utils/ # ๅฎ็จๅทฅๅ
ท
โ โ โโโ logging_utils.py # ๆฅๅฟๅทฅๅ
ท
โ โโโ models.py # ๆฐๆฎๆจกๅๅฎไน
โ โโโ roles.py # ่ง่ฒๅฎไน
โ โโโ main.py # ไธป็จๅบ
โโโ tests/ # ๆต่ฏ็ฎๅฝ
โโโ logs/ # ๆฅๅฟๆไปถ
โโโ .env # ็ฏๅขๅ้
โโโ pyproject.toml # Poetry้
็ฝฎ
โโโ requirements.txt # ไพ่ต้กน
โโโ README.md # ่ฏดๆๆๆกฃ
```
## ๐ ไปฃ็ ๅฎ็ฐไบฎ็น
### 1. ๅคไปฃ็ๅไฝๆถๆ
ๆฌ้กน็ฎๅฎ็ฐไบ10ไธชไธไธ่ง่ฒ็ไปฃ็๏ผๆฏไธชไปฃ็่ด่ดฃๆ่ตๅๆๆต็จไธญ็็นๅฎไปปๅกใไปฃ็ไน้ด้่ฟๆถๆฏไผ ้่ฟ่กๅไฝ๏ผๅฝขๆๅฎๆด็ๅๆๅณ็ญ้พๆกใ
```python
# ๅๅปบไปฃ็
market_data_agent = MarketDataAgent(show_reasoning=show_reasoning, model_name=model_name)
technical_analyst = TechnicalAnalystAgent(show_reasoning=show_reasoning, model_name=model_name)
fundamentals_analyst = FundamentalsAnalystAgent(show_reasoning=show_reasoning, model_name=model_name)
sentiment_analyst = SentimentAnalystAgent(show_reasoning=show_reasoning, model_name=model_name)
valuation_analyst = ValuationAnalystAgent(show_reasoning=show_reasoning, model_name=model_name)
researcher_bull = ResearcherBullAgent(show_reasoning=show_reasoning, model_name=model_name)
researcher_bear = ResearcherBearAgent(show_reasoning=show_reasoning, model_name=model_name)
debate_room = DebateRoomAgent(show_reasoning=show_reasoning, model_name=model_name)
risk_manager = RiskManagerAgent(show_reasoning=show_reasoning, model_name=model_name)
portfolio_manager = PortfolioManagerAgent(show_reasoning=show_reasoning, model_name=model_name)
```
### 2. ็ตๆดป็ๅคๆจกๅๆฏๆ
็ณป็ปๆฏๆๅ
ๆฌGeminiใOpenAIๅQwenๅจๅ
็ๅค็งๅคง่ฏญ่จๆจกๅ๏ผ้่ฟ็ปไธ็ๆฅๅฃๅฎ็ฐ็ตๆดปๅๆขใ
```python
def get_llm_client(model_name: str):
"""่ทๅๆๅฎ็LLMๅฎขๆท็ซฏ"""
if model_name.lower() == 'gemini':
return GeminiClient()
elif model_name.lower() == 'openai':
return OpenAIClient()
elif model_name.lower() == 'qwen':
return QwenClient()
else:
raise ValueError(f"ไธๆฏๆ็ๆจกๅ: {model_name}")
```
## ๐ ๆน่ฟไธๅๆฐ
็ธ่พไบๅๅง็ๆฌ๏ผๅบไบCamelๆกๆถ้ๆ็็ณป็ปๅ
ทๆไปฅไธๅๆฐๅๆน่ฟ๏ผ
1. **ๆจกๅๅ่ฎพ่ฎก**: ๆดๆธ
ๆฐ็ไปฃ็ๅฎไนๅ็ณป็ป็ปๆ๏ผไพฟไบๆฉๅฑๅ็ปดๆค
2. **ๅคๆจกๅๆฏๆ**: ็ตๆดปๆฏๆๅค็งLLMๆจกๅ๏ผๆ้ซ็ณป็ป้ๅบๆง
3. **ๅฎๅ็ๆฅๅฟ็ณป็ป**: ่ฏฆ็ป่ฎฐๅฝๅไปฃ็็ๅทฅไฝ่ฟ็จ๏ผไพฟไบ่ฐ่ฏๅๅๆ
## โ ๏ธ ๅ
่ดฃๅฃฐๆ
ๆฌ้กน็ฎไป
็จไบ**ๆ่ฒๅ็ ็ฉถ็ฎ็**ใ
- ไธ้็จไบๅฎ้
ไบคๆๆๆ่ต
- ไธๆไพไปปไฝไฟ่ฏ
- ่ฟๅพไธ็ปฉไธไปฃ่กจๆชๆฅ่กจ็ฐ
- ๅๅปบ่
ไธๆฟๆ
ไปปไฝ่ดขๅกๆๅคฑ่ดฃไปป
- ๆ่ตๅณ็ญ่ฏทๅจ่ฏขไธไธ็่ดข้กพ้ฎ
ไฝฟ็จๆฌ่ฝฏไปถๅณ่กจ็คบๆจๅๆไป
ๅฐๅ
ถ็จไบๅญฆไน ็ฎ็ใ
## ๐ ็ธๅ
ณ่ตๆบ
- [OWLๆกๆถๅฎๆนๆๆกฃ](https://github.com/camel-ai/owl)
- [Camelๆกๆถๅฎๆนๆๆกฃ](https://github.com/camel-ai/camel)
- [A_Share_investment_Agent](https://github.com/24mlight/A_Share_investment_Agent)
## ๐ ่ด่ฐข
ๆฌ้กน็ฎๅบไบไปฅไธๅผๆบ้กน็ฎ่ฟ่กๆน่ฟ๏ผ
1. [A_Share_investment_Agent](https://github.com/24mlight/A_Share_investment_Agent) - ๅๅงA่กๆ่ตไปฃ็้กน็ฎ๏ผไธบๆฌ้กน็ฎๆไพไบๅบ็กๆถๆๅๆ่ตๅๆๆ่ทฏ๏ผ็นๅซๆ่ฐขๅ
ถๅจA่กๆฐๆฎๅค็ๅๅๆ็ญ็ฅๆน้ข็ๅๆฐ่ฎพ่ฎกใ
2. [ai-hedge-fund](https://github.com/virattt/ai-hedge-fund.git) - ๅๅง็พ่กๆ่ตไปฃ็้กน็ฎ
3. [Camelๆกๆถ](https://github.com/camel-ai/camel) - ๅคไปฃ็ๅฏน่ฏๆกๆถ
4. [OWLๆกๆถ](https://github.com/camel-ai/owl) - ๅผๆบๅคๆบ่ฝไฝๅไฝๆกๆถ
ๆ่ฐขๆๆๅไฝ่
็่ดก็ฎๅๅฏๅ๏ผไธบๆฌ้กน็ฎๆไพไบๅๅฎ็ๅบ็กใ
---
## File: community_usecase/a_share_investment_agent_camel/README_EN.md
<h1 align="center">
๐ฆA-Share Investment Agent System
</h1>
[English](README_EN.md) |
[ไธญๆ](README.md) |
[Acknowledgements](#-acknowledgements) |
[Example Results](#-example-results)
</h4>
## ๐ Project Introduction
This project is a multi-agent A-share investment analysis system based on the OWL framework and Camel framework (v0.2.36), which completes investment analysis through multiple professional role agents working together to provide investment decision recommendations for users. The system adopts multi-model support and can flexibly use different large language models (such as Gemini, OpenAI, Qwen) for analysis.
This project participated in the OWL community use case challenge and is an improved version of the open-source project [A_Share_investment_Agent](https://github.com/24mlight/A_Share_investment_Agent), restructured using the OWL and Camel frameworks.
### ๐ Core Features
- **Multi-agent Collaboration System**: Analysis through 10 professional role agents working together to achieve more comprehensive and professional investment decisions
- **Multi-model Support**: Support for multiple large language models such as Gemini, OpenAI, Qwen, with flexible switching
- **A-share Market Specialization**: Designed specifically for the A-share market, focusing on Chinese stock market characteristics and data
- **Debate and Decision Mechanism**: Innovative bull and bear perspective debate mechanism to balance analytical viewpoints
- **Complete Data Processing Pipeline**: Full process support from data collection to analysis to decision-making
## ๐๏ธ System Architecture
The system architecture includes the following core agents:
### ๐ Data and Analysis Layer
1. **Market Data Agent** - Responsible for collecting and preprocessing market data
2. **Technical Analyst** - Analyzes technical indicators and generates trading signals
3. **Fundamentals Analyst** - Analyzes fundamental data and generates trading signals
4. **Sentiment Analyst** - Analyzes market sentiment and generates trading signals
5. **Valuation Analyst** - Calculates the intrinsic value of stocks and generates trading signals
### ๐ Research and Debate Layer
6. **Researcher Bull** - Provides bullish perspective analysis
7. **Researcher Bear** - Provides bearish perspective analysis
8. **Debate Room** - Integrates bull and bear perspectives to form a final viewpoint
### ๐งฎ Decision Layer
9. **Risk Manager** - Calculates risk indicators and sets position limits
10. **Portfolio Manager** - Formulates the final trading decision and generates orders
## ๐ป Installation Guide
### Prerequisites
- Python 3.9+
- Related API keys (Gemini/OpenAI/Qwen)
### Installation Steps
1. Clone the OWL repository and enter the project directory
```bash
git clone https://github.com/camel-ai/owl.git
cd owl/community_usecase/a_share_investment_agent_camel
```
2. Install dependencies
```bash
pip install -r requirements.txt
```
3. Configure environment variables (create .env file)
```
# Gemini Configuration
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=gemini-1.5-flash
# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4o
# Qwen Configuration
QWEN_API_KEY=your_qwen_api_key
QWEN_MODEL=qwen-max
QWEN_API_URL=https://your-qwen-api-endpoint
```
### Docker Usage Method
To simplify the installation process, we provide Docker support.
1. Build Docker image
```bash
docker build -t a-share-investment-agent .
```
2. Create a .env file containing API keys
```bash
# Create a .env file with the same format as above
touch .env
# Edit the .env file to add your API keys
```
## ๐ Usage
### Basic Usage
```bash
python src/main.py --ticker 000001 --model qwen
```
### Test Mode
```bash
# Use default parameters (Qwen model and 000001 stock) for testing
python src/main.py --test
# Specify stock for testing
python src/main.py --test --ticker 600036
```
### Parameter Description
- `--ticker`: Stock code
- `--start-date`: Start date (YYYY-MM-DD)
- `--end-date`: End date (YYYY-MM-DD)
- `--show-reasoning`: Display analysis reasoning process
- `--num-of-news`: Number of news used for sentiment analysis
- `--initial-capital`: Initial cash amount
- `--initial-position`: Initial stock position
- `--model`: Model to use (gemini, openai, qwen)
- `--test`: Run test function with preset parameters
## ๐ Example Results
### Analysis Results
Below is an example of the analysis results for Cambricon-U (688256) stock during the period 2025/01/04-2025/03/24:
```bash
python src/main.py --ticker 688256 --start-date 2025-01-04 --end-date 2025-03-24 --model qwen --show-reasoning
```
#### Agent Analysis Logs
**Market Data Agent**:
```json
{
"trend": "Short-term trend is downward, but long-term trend still needs observation",
"judgment": "Current price is below the middle Bollinger band, RSI is close to neutral level, MACD line is below the signal line, indicating short-term adjustment may continue. However, considering the previous significant rise, the long-term trend still needs further observation. Recommend paying attention to support level 670.66 and resistance level 747.57."
}
```
**Technical Analyst**:
```json
{
"signal": "bearish",
"confidence": 0.8,
"reasoning": "From technical indicators, the stock is currently in a relatively weak state. First, the 5-day moving average (718.856) has crossed below the 10-day (743.927) and 20-day (747.574) moving averages, indicating the short-term trend is weakening. The MACD indicator also shows a similar trend, with the MACD line (8.994) below the signal line (20.004), and the MACD histogram (-11.009) negative, indicating market momentum is weakening. The RSI indicator (48.676) is in neutral territory but approaching oversold territory, which may indicate a short-term rebound, but the overall trend remains weak. On the Bollinger Bands, the current price (685.05) is close to the lower band (670.657), which may provide some support, but considering the weakness shown by other indicators, the support may be limited. Overall, the current market environment and technical indicators point toward a bearish trend."
}
```
**Fundamentals Analyst**:
```json
{
"signal": "bearish",
"confidence": 0.8,
"reasoning": "Cambricon-U's financial condition and business performance show clear negative trends. First, the company's net profit continues to be negative, and the loss amount has increased in recent quarters, indicating serious problems with profitability. Second, although the company's operating revenue increased in the fourth quarter of 2023, it experienced a significant decline in subsequent quarters, which may indicate a decrease in market demand or company market share. Additionally, the company's P/E ratio is negative, and its P/B ratio is as high as 52.58, indicating overvaluation in the market with significant bubble risk. From a financial health perspective, although the company has a low debt-to-asset ratio, its operating cash flow continues to be negative, indicating the company faces significant financial pressure in operations. Considering these factors, we believe Cambricon-U's stock is currently bearish."
}
```
**Sentiment Analyst**:
```json
{
"signal": "bullish",
"confidence": 0.8,
"reasoning": "From the news data, the overall market sentiment is positive, with positive news far outnumbering negative news. Although one news item mentions the decline of chip ETFs and Cambricon-U, most news emphasizes the positive performance of Cambricon-U and its sector, including stock price increases and technological breakthroughs. Additionally, the news of Cambricon-U being included in the FTSE China A50 Index indicates the market's optimistic outlook for its long-term prospects. Social media discussions also mainly focus on the company's positive developments, further supporting the bullish view.",
"key_events": [
"Cambricon-U included in FTSE China A50 Index",
"Cambricon-U stock price rises multiple times",
"AI AIETF holding stock Cambricon-U surges",
"ZhiYuan QiYuan large model released"
]
}
```
**Valuation Analyst**:
```json
{
"signal": "bearish",
"confidence": 0.85,
"reasoning": "Cambricon-U's financial condition and business performance show clear negative trends. First, the company's net profit continues to be negative, and the loss amount has increased in recent quarters, indicating serious problems with profitability. Second, although the company's operating revenue increased in the fourth quarter of 2023, it experienced a significant decline in subsequent quarters, which may indicate a decrease in market demand or company market share. Additionally, the company's P/E ratio is negative, and its P/B ratio is as high as 52.58, indicating overvaluation in the market with significant bubble risk. From a financial health perspective, although the company has a low debt-to-asset ratio, its operating cash flow continues to be negative, indicating the company faces significant financial pressure in operations. Considering these factors, we believe Cambricon-U's stock is currently bearish. Furthermore, calculated through DCF model and relative valuation methods, the company's intrinsic value is significantly lower than the current market price, further supporting the bearish view.",
"fair_value": 200.0,
"key_metrics": [
"P/E Ratio",
"P/B Ratio",
"Operating Revenue",
"Net Profit",
"Operating Cash Flow"
]
}
```
**Researcher Bull**:
```json
{
"key_points": [
"Market sentiment is positive, news and social media discussions lean optimistic",
"Cambricon-U included in FTSE China A50 Index, indicating market's optimistic outlook for its long-term prospects",
"Positive news of technological breakthroughs and stock price increases",
"Despite weakness in technical and fundamental aspects, market sentiment and potential catalysts may drive stock price rebound"
],
"confidence": 0.6,
"reasoning": "Despite technical and fundamental analysis showing Cambricon-U is currently in a weak state, market sentiment and potential catalysts may drive stock price rebound. Cambricon-U being included in the FTSE China A50 Index indicates the market's optimistic outlook for its long-term prospects. Additionally, recent positive news about technological breakthroughs and stock price increases also support the bullish view. Although current financial conditions and valuations are high, market sentiment and potential positive factors may provide support for the stock price. Therefore, we recommend maintaining caution in the short term, but in the long term, Cambricon-U still has investment potential."
}
```
**Researcher Bear**:
```json
{
"key_points": [
"Technical indicators show short-term trend weakening",
"Net profit continues to be negative and losses increase",
"Declining operating revenue indicates decreased market demand",
"P/B ratio as high as 52.58, overvalued",
"Operating cash flow continues to be negative, significant financial pressure",
"DCF model and relative valuation methods show intrinsic value lower than market price"
],
"confidence": 0.8,
"reasoning": "Combining technical analysis, fundamental analysis, market sentiment analysis, and valuation analysis, Cambricon-U's stock is currently bearish. Technical indicators show short-term trend weakening, fundamental analysis shows poor profitability, decreased market demand, overvaluation, and significant financial pressure. Although market sentiment leans positive, these positive sentiments mainly focus on short-term events and cannot mask long-term fundamental issues. Valuation analysis further supports the bearish view, with intrinsic value significantly lower than current market price. Therefore, selling Cambricon-U stock is recommended."
}
```
**Debate Room**:
```json
{
"signal": "neutral",
"confidence": 0.7,
"reasoning": "Both bull and bear researchers' views have rationality and basis. The bull researcher emphasizes positive market sentiment, Cambricon-U's inclusion in the FTSE China A50 Index, and positive news about technological breakthroughs and stock price increases, which may provide support for the stock price in the short term. However, the bear researcher points out technical indicators show short-term trend weakening, fundamental analysis shows poor profitability, decreased market demand, overvaluation, and significant financial pressure. Although market sentiment leans positive, these positive sentiments mainly focus on short-term events and cannot mask long-term fundamental issues. Overall, in the short term, market sentiment and technological breakthroughs may drive stock price rebound, but long-term fundamental issues still exist, so maintaining a neutral attitude and waiting for more clear signals is recommended.",
"final_verdict": "Investors are advised to remain cautious in the short term and pay attention to the continuity of market sentiment and technological breakthroughs. In the long term, close attention should be paid to the company's fundamental improvements, especially in areas such as profitability, market demand, and financial pressure. Before more clear signals emerge, maintaining a neutral attitude and avoiding excessive optimism or pessimism is recommended."
}
```
**Risk Manager**:
```json
{
"max_position_size": 0.2,
"volatility": 0.15,
"risk_score": 0.7,
"max_drawdown": 0.25,
"suggested_position_size": 0.15,
"reasoning": "Given stock 688256's high volatility and fundamental risks, a cautious approach is recommended. Although there is potential for technical breakthrough in the short term, the company faces issues such as poor profitability in the long term. Therefore, it is recommended to control position ratio not exceeding 20% and set appropriate stop-loss points to protect capital. At the same time, diversify investments to spread risk."
}
```
**Portfolio Manager (Final Decision)**:
```json
{
"action": "hold",
"quantity": 0,
"confidence": 0.8,
"reasoning": "Considering various analysts' trading signals, debate results, risk analysis, current portfolio status, and latest market price, we decide to adopt a holding strategy for stock 688256. Technical analysis and fundamental analysis both show the stock is in a weak state, with technical indicators showing short-term trend weakening, and fundamentals showing poor profitability, decreased market demand, overvaluation, and significant financial pressure. Although sentiment analysis shows positive market sentiment, these positive sentiments mainly focus on short-term events and cannot mask long-term fundamental issues. The debate result also recommends caution in the short term, paying attention to the continuity of market sentiment and technological breakthroughs. In the long term, close attention should be paid to the company's fundamental improvements. Risk analysis recommends controlling position ratio not exceeding 20% and setting appropriate stop-loss points to protect capital. Therefore, we decide to temporarily hold the stock and wait for more clear signals."
}
```
#### Comprehensive Conclusion
**Final Investment Decision**: Hold (Confidence: 0.8)
The analysis results from multiple professional agents indicate that Cambricon-U (688256) stock is currently in a weak state in terms of technicals and fundamentals, but market sentiment and short-term events may provide support for the stock price. Considering all factors, the system recommends adopting a holding strategy for this stock and closely monitoring subsequent changes in fundamentals and market sentiment. At the same time, risk management recommends controlling the maximum position ratio of this stock to within 20% of the portfolio and setting appropriate stop-loss points to control risk.
## ๐ Data Process Description
The system's data process follows these steps:
1. **Data Collection**: Market data agent collects A-share market data and news through akshare API
2. **Multi-dimensional Analysis**: Four professional analysis agents (technical, fundamental, sentiment, valuation) conduct analysis independently
3. **Bull/Bear Research**: Bull and bear researchers provide analysis reports from bullish and bearish perspectives respectively
4. **Debate Integration**: Debate room integrates bull and bear perspectives to form a final analytical opinion
5. **Risk Assessment**: Risk manager assesses investment risk and sets trading restrictions
6. **Final Decision**: Portfolio manager formulates the final trading decision and generates orders
## ๐ Project Structure
```
community_usecase/a_share_investment_agent_camel/
โโโ src/ # Source code directory
โ โโโ agents/ # Agent implementations
โ โ โโโ base_agent.py # Base agent class
โ โ โโโ market_data_agent.py # Market data agent
โ โ โโโ technical_analyst.py # Technical analyst agent
โ โ โโโ ...
โ โโโ tools/ # Tool modules
โ โ โโโ data_helper.py # Data helper tools
โ โโโ utils/ # Utility tools
โ โ โโโ logging_utils.py # Logging tools
โ โโโ models.py # Data model definitions
โ โโโ roles.py # Role definitions
โ โโโ main.py # Main program
โโโ tests/ # Test directory
โโโ logs/ # Log files
โโโ .env # Environment variables
โโโ pyproject.toml # Poetry configuration
โโโ requirements.txt # Dependencies
โโโ README.md # Documentation
```
## ๐ Code Implementation Highlights
### 1. Multi-agent Collaboration Architecture
This project implements 10 professional role agents, with each agent responsible for specific tasks in the investment analysis process. Agents collaborate through message passing, forming a complete analysis decision chain.
```python
# Create agents
market_data_agent = MarketDataAgent(show_reasoning=show_reasoning, model_name=model_name)
technical_analyst = TechnicalAnalystAgent(show_reasoning=show_reasoning, model_name=model_name)
fundamentals_analyst = FundamentalsAnalystAgent(show_reasoning=show_reasoning, model_name=model_name)
sentiment_analyst = SentimentAnalystAgent(show_reasoning=show_reasoning, model_name=model_name)
valuation_analyst = ValuationAnalystAgent(show_reasoning=show_reasoning, model_name=model_name)
researcher_bull = ResearcherBullAgent(show_reasoning=show_reasoning, model_name=model_name)
researcher_bear = ResearcherBearAgent(show_reasoning=show_reasoning, model_name=model_name)
debate_room = DebateRoomAgent(show_reasoning=show_reasoning, model_name=model_name)
risk_manager = RiskManagerAgent(show_reasoning=show_reasoning, model_name=model_name)
portfolio_manager = PortfolioManagerAgent(show_reasoning=show_reasoning, model_name=model_name)
```
### 2. Flexible Multi-model Support
The system supports multiple large language models including Gemini, OpenAI, and Qwen, implementing flexible switching through a unified interface.
```python
def get_llm_client(model_name: str):
"""Get the specified LLM client"""
if model_name.lower() == 'gemini':
return GeminiClient()
elif model_name.lower() == 'openai':
return OpenAIClient()
elif model_name.lower() == 'qwen':
return QwenClient()
else:
raise ValueError(f"Unsupported model: {model_name}")
```
## ๐ Improvements and Innovations
Compared to the original version, the system restructured based on the Camel framework has the following innovations and improvements:
1. **Modular Design**: Clearer agent definitions and system structure, facilitating extension and maintenance
2. **Multi-model Support**: Flexible support for multiple LLM models, improving system adaptability
3. **Comprehensive Logging System**: Detailed recording of each agent's work process, facilitating debugging and analysis
## โ ๏ธ Disclaimer
This project is for **educational and research purposes only**.
- Not suitable for actual trading or investment
- No guarantees provided
- Past performance does not represent future performance
- Creators bear no responsibility for any financial losses
- Consult professional financial advisors for investment decisions
By using this software, you agree to use it for learning purposes only.
## ๐ Related Resources
- [OWL Framework Official Documentation](https://github.com/camel-ai/owl)
- [Camel Framework Official Documentation](https://github.com/camel-ai/camel)
- [A_Share_investment_Agent](https://github.com/24mlight/A_Share_investment_Agent)
## ๐ Acknowledgements
This project is improved based on the following open-source projects:
1. [A_Share_investment_Agent](https://github.com/24mlight/A_Share_investment_Agent) - Original A-share investment agent project, providing the foundation architecture and investment analysis ideas for this project. Special thanks for its innovative design in A-share data processing and analysis strategies.
2. [ai-hedge-fund](https://github.com/virattt/ai-hedge-fund.git) - Original US stock investment agent project
3. [Camel Framework](https://github.com/camel-ai/camel) - Multi-agent dialogue framework
4. [OWL Framework](https://github.com/camel-ai/owl) - Open-source multi-agent collaboration framework
Thanks to all the original authors for their contributions and inspiration, providing a solid foundation for this project.
---
## File: community_usecase/cooking-assistant/README.md
# Personal Dietician
This code example searches for recipes on the internet based on the ingredients you have, refines the content based on a dieterary restriction and generates shopping lists.
## How to use
1. Set up the OPENAI api key in the .env file
```bash
OPENAI_API_KEY = 'xxx'
```
2. Copy the python script to the owl/examples folder.
3. Run the script
```bash
python run_gpt4o.py
```
4. You can find the entire thought process of the agent within the log file.
5. Demo Link - https://drive.google.com/drive/folders/10LnMEMf_xQGojHyTAS57vI7oOmjvuKPE?usp=sharing
---
## File: community_usecase/excel_analyzer/README.md
# Excel Analyzer
[ไธญๆ](README_zh.md)
This project uses **Owl** for data analysis and visualization.
## Features
- Provides both English and Chinese versions of the raw data and prompts
- Utilizes **CodeExecutionToolkit**, **ExcelToolkit**, and **FileWriteToolkit** to complete related tasks
- Implements **ExcelRolePlaying** based on **OwlRolePlaying**, which overrides the `system_prompt` with a cleaner, more focused version tailored for data analysis scenarios
- tested using `gpt-4o` and `deepseek-v3`
- The analysis and visualization of this Excel file involve:
- Complex headers (merged rows)
- Nan value handling
- Complex group calculations
- Visualization
## How to Use
1. Set up the environment according to Owl's official instructions
2. Run the following commands:
```bash
cd community_usecase/excel_analyzer
# Chinese version, using deepseek-v3
python excel_analyzer_zh.py
# English version, using gpt-4o
python excel_analyzer_zh.py
```
3. The analysis results will be saved in the current directory
---
## File: community_usecase/excel_analyzer/README_zh.md
# Excel Analyzer
่ฟไธช้กน็ฎไฝฟ็จowlๆฅๅๆฐๆฎๅๆๅๅฏ่งๅ
## Features
- ๆไพไบ่ฑๆ๏ผไธญๆไธคไธช็ๆฌ็ๅๅงๆฐๆฎๅprompt๏ผๆนไพฟ็่งฃ
- ไฝฟ็จ**CodeExecutionToolkit**๏ผ**ExcelToolkit**๏ผ**FileWriteToolkit**ๆฅๅฎๆ็ธๅ
ณๅทฅไฝ
- ๅจ**OwlRolePlaying**ๅบ็กไนไธๅฎ็ฐไบ**ExcelRolePalying**๏ผๅฎ้ๅไบsystem_prompt๏ผๆด็ฎๆด๏ผ่็ฆๅจๆฐๆฎๅๆๅบๆฏ
- ็ป่ฟๆต่ฏ๏ผๅจ`gpt-4o`ๅ`deepseek-v3`ไธๅๅฏไปฅ่พพๅฐ้ขๆๆๆ
- ๅฏน่ฏฅexcel่ฟ่กๅๆๅๅฏ่งๅๆถๆถๅๅฐ็ๅ
ๅฎนๆ๏ผ
- ๅคๆ่กจๅคด๏ผๅๅนถ่ก๏ผ
- ็ผบๅคฑๅผๅค็
- ๅคๆ็ๅ็ป่ฎก็ฎ
- ๅฏ่งๅ
## How to use
1. ๆ็
งowl็ๅฎๆนๆต็จๆญๅปบๅฅฝ็ฏๅข
2. ่ฟ่ก
```
cd community_usecase/excel_analyzer
# Chinese version, using deepseek-v3
python excel_analyzer_zh.py
# English version, using gpt-4o
python excel_analyzer_zh.py
```
3. ๆฐๆฎ้ๅๆ็็ปๆๅฐไผๅจๅบๅญๅจๅฝๅ็ฎๅฝไธ
---
## File: community_usecase/learning-assistant/README.md
# Learning Assistant
This code example searches the internet for relevant learning materials depending on the user's knowledge level and devises a concrete learning roadmap all tailored to the user.
## How to use
1. Set up the OPENAI api key in the .env file
```bash
OPENAI_API_KEY = 'xxx'
```
2. Copy the python script to the owl/examples folder.
3. Run the script
```bash
python run_gpt4o.py
```
4. You can find the entire thought process of the agent within the log file.
5. Video demo - https://drive.google.com/drive/folders/1msrNNwjeZ0DKhSXCi2w1ljz_hULSusa_?usp=sharing
---
## File: community_usecase/Mcp_use_case/Readme.md
# Autonomous Website Scraping with OWL + FireCrawl MCP
This project leverages OWL (Optimized Workforce Learning) and FireCrawl MCP (Model Context Protocol) to automate content curation. The system scrapes top tech news websites, extracts relevant information, and compiles a summary report.
## Features
- Uses **FireCrawl MCP Server** for performing web scraping.
- Implements **OwlRolePlaying** for enhanced multi-agent task execution.
- Scrapes **TechCrunch, The Verge, and Wired** using **FireCrawl**.
- Extracts and summarizes **headlines, article summaries, and publication dates**.
- Generates a digest report **(Latest_tech_digest.md)** based on trends from these sources.
- Runs a default scraping task which can be updated before running the Script.
## Installation
1. Clone this repository:
```sh
git clone https://github.com/camel-ai/owl.git
cd owl
```
2. Install dependencies:
```sh
pip install -r requirements.txt
```
3. Set up environment variables:
- Create a `.env` file and add your API keys/configuration as needed.
## Usage
Navigate to the community use case directory before running the script:
```sh
cd community_usecase/Mcp_use_Case
```
Run the script using:
```sh
python Content_curator.py
```
The script automatically executes the default task without taking additional input from the terminal.
## Configuration
- The script reads from `mcp_servers_config.json`, which is located in the same folder as Mcp_use_case.
- Modify the `default_task` section in `Content_curator.py` to adjust scraping and summarization behavior.
## Improvements & Customization
- The current implementation runs a **default task** and does not take task input from the terminal.
- To modify the scraping target or change the extracted details, update the `default_task` in `Content_curator.py`.
- The project is stored in the `Mcp_use_Case` folder inside `community_usecase` in the OWL directory.
## Error Handling
- Ensures **graceful cleanup** in case of failures.
- Implements **try-except** blocks to handle tool execution errors.
- Cancels running async tasks to **prevent memory leaks**.
- Supports **KeyboardInterrupt** for a safe shutdown.
## Cleanup & Shutdown
- The script **automatically disconnects MCP** after execution.
- Cancels remaining async tasks to **prevent memory leaks**.
- Special handling for **Windows platforms** is included to ensure smooth termination.
## Repository
For more details, visit the OWL repository: [OWL GitHub Repo](https://github.com/camel-ai/owl)
---
## File: community_usecase/Notion-MCP/README.md
# Notion Integration with OWL
This project demonstrates the integration of Notion with OWL (Optimized Workforce Learning) using the official Notion MCP server. It provides automated interaction with Notion workspaces through AI agents.
## Prerequisites
- Python >=3.10,<3.13
- Node.js and npm
- CAMEL framework installed
- A Notion account and integration
## Installation
#### 1. Clone this repository:
```sh
git clone https://github.com/camel-ai/owl.git
cd owl
```
#### 2. Install dependencies:
```sh
pip install -r requirements.txt
```
#### 3. Set up environment variables:
- Create a `.env` file and add your API keys/configuration as needed.
## Setup
#### 1. Install the required Node.js package:
```bash
npm install @notionhq/notion-mcp-server@latest
```
#### 2. Set up your Notion integration:
- Go to https://www.notion.so/profile/integrations
- Create a new integration
- Copy the integration token
- Update `mcp_servers_config.json` with your token
#### 3. Connect your Notion pages:
- Open each Notion page you want to work with
- Click "..." (three dots) in the top right
- Select "Add connections"
- Choose your integration
#### 4. Visit official Notion MCP GitHub Repository
Visit the [Notion_MCP GitHub Repo](https://github.com/makenotion/notion-mcp-server) for detailed setup instructions.
## Usage
Navigate to the community use case directory before running the script:
```sh
cd community_usecase/Notion_MCP
```
#### Run the script using:
```bash
python notion_manager.py
```
This will run the default task which:
- Searches for a specific page
- Updates its properties
- Adds a comment
## Supported Operations
The integration supports these Notion API operations:
- Searching for pages
- Reading page content
- Updating page properties
- Adding comments
- Creating new pages
- Retrieving database content
## Troubleshooting
If you encounter errors:
1. Verify your Notion token is correct
2. Check that pages are connected to your integration
3. Ensure you have the required permissions
4. Check the Notion API version in config matches the current version
## Error Handling
The script includes:
- Graceful connection handling
- Task execution error catching
- Proper cleanup on exit
- Windows-specific asyncio handling
## Repository
For more details, visit the OWL repository: [OWL GitHub Repo](https://github.com/camel-ai/owl)