A sophisticated multi-agent system for intelligent cryptocurrency portfolio management using the Agent-to-Agent (A2A) communication protocol.
The Smart Crypto Portfolio Manager is a modular and extensible system that leverages multiple specialized AI agents to automate and optimize cryptocurrency trading. Each agent focuses on a specific aspect of trading, and they communicate with each other through a standardized A2A protocol, implementing Google's open Agent-to-Agent (A2A) protocol for seamless interoperability with other agent systems.
The system consists of five main agents:
- Market Analysis Agent: Monitors crypto markets, analyzes trends, and identifies trading opportunities.
- Trade Execution Agent: Executes buy/sell orders on various crypto exchanges.
- Risk Management Agent: Monitors portfolio risk exposure and suggests risk mitigation actions.
- Reporting and Analytics Agent: Generates reports on trading performance and portfolio valuation.
- Orchestration Agent: Manages the coordination of all agents, provides status monitoring, and accepts LLM function calls via the MCP protocol.
Agents communicate using two protocols:
- Implements the Google Agent-to-Agent (A2A) protocol for standardized agent communication
- Agent discovery through agent cards (JSON files describing capabilities)
- Task-based interaction model
- Structured JSON messages
- Secure and reliable communication
- The Orchestration Agent implements the MCP protocol for LLM function calls
- Allows external AI systems to interact with the platform
- Structured JSON schemas for function definitions
- Streamlined function calling interface
This project fully implements Google's Agent-to-Agent (A2A) protocol, allowing our agents to communicate not only with each other but also with any other A2A-compatible agents in the ecosystem. This integration provides several benefits:
- Agent Card: Our system exposes a standard Agent Card at
/.well-known/agent.json
describing all agent capabilities - Task-Based API: All agent interactions follow the A2A task lifecycle (submitted, working, input-required, completed, failed, canceled)
- Streaming Support: Real-time task updates via Server-Sent Events (SSE)
- Push Notifications: Proactive updates to client applications
- Skills Framework: Standardized skill definitions for all agent capabilities
- Connect with agents built on other frameworks (CrewAI, LangGraph, Semantic Kernel, etc.)
- Extend capabilities through third-party A2A agents
- Future-proof design aligned with emerging industry standards
- Simplified integration with LLM-based systems
Our implementation is compatible with the growing ecosystem of A2A-enabled agents and frameworks, including:
- Agent Development Kit (ADK)
- CrewAI
- LangGraph
- Genkit
- LlamaIndex
- Semantic Kernel
For more information on the A2A protocol, visit the official GitHub repository.
The Market Analysis Agent continuously monitors crypto markets and identifies trading opportunities based on technical analysis, trend detection, and pattern recognition. When it identifies a potential trade, it:
- Requests a risk assessment from the Risk Management Agent
- If the risk is acceptable, sends a trade execution request to the Trade Execution Agent
- Notifies the Reporting and Analytics Agent about the trade
- Monitors the trade and adjusts strategy as needed
The Risk Management Agent continuously evaluates the overall portfolio risk and can:
- Set stop-loss and take-profit levels for active positions
- Recommend portfolio rebalancing when asset allocations drift
- Trigger emergency protocols during market crashes
- Impose limits on trade sizes based on risk metrics
The Reporting and Analytics Agent automatically generates reports on:
- Daily, weekly, and monthly trading performance
- Portfolio valuation and asset allocation
- Risk metrics and exposure analysis
- Trade statistics and execution quality
The Orchestration Agent provides centralized control and monitoring:
- Executes predefined workflows across multiple agents
- Monitors the status of all agents in the system
- Provides a unified interface for LLM function calls via MCP
- Tracks workflow execution progress
External AI systems can interact with the platform through the MCP protocol:
- Query agent status and system health
- Execute market analysis and trades
- Assess portfolio risk
- Generate performance reports
- Execute multi-agent workflows
- Docker and Docker Compose
- Python 3.9+
- API keys for cryptocurrency exchanges (Binance, Coinbase, etc.)
-
Clone the repository:
git clone https://github.com/tonycai/smart_crypto_portfolio_manager.git cd smart_crypto_portfolio_manager
-
Configure the system:
- Edit the configuration files in the
config/
directory - Set your API keys in
config/trade_execution.json
- Adjust risk parameters in
config/risk_management.json
- Configure MCP functions in
config/orchestration.json
- Edit the configuration files in the
-
Build and start the containers:
docker-compose build docker-compose up -d
Each agent runs in its own Docker container, making deployment and scaling easy:
- Market Analysis Agent: Runs on port 8001
- Trade Execution Agent: Runs on port 8002
- Risk Management Agent: Runs on port 8003
- Reporting and Analytics Agent: Runs on port 8004
- Orchestration Agent: Runs on port 8005
You can scale individual agents to handle higher loads:
docker-compose up -d --scale market-analysis-agent=3
Monitor the system using standard Docker commands:
docker-compose ps
docker-compose logs -f
agents/
: Contains the implementation of each specialized agentmarket_analysis/
: Market Analysis Agent implementationtrade_execution/
: Trade Execution Agent implementationrisk_management/
: Risk Management Agent implementationreporting_analytics/
: Reporting and Analytics Agent implementationorchestration/
: Orchestration Agent implementation
a2a/
: Implementation of the Agent-to-Agent communication protocolconfig/
: Configuration files for each agentcommon/
: Shared utilities and code
- Create a new directory in
agents/
- Create an
agent.json
file defining the agent's capabilities - Implement the agent's functionality
- Add the agent to
docker-compose.yml
- Add new capability definitions to the agent's
agent.json
file - Implement the corresponding handler functions
- Register the handlers in the agent's initialization
Each agent exposes a RESTful API following the A2A protocol:
- Agent Discovery:
GET /api/v1/agent
- Task Management:
- Create Task:
POST /api/v1/tasks
- Get Task:
GET /api/v1/tasks/{task_id}
- Update Task:
PUT /api/v1/tasks/{task_id}
- Delete Task:
DELETE /api/v1/tasks/{task_id}
- Create Task:
- Messaging:
- Send Message:
POST /api/v1/tasks/{task_id}/messages
- Get Messages:
GET /api/v1/tasks/{task_id}/messages
- Send Message:
The Orchestration Agent also implements the MCP protocol:
- LLM Function Calls:
POST /api/v1/mcp/function
- API keys are stored in configuration files and never exposed in logs
- Communication between agents can be secured with TLS
- Authentication is required for task creation
- Risk limits prevent catastrophic trading errors
Contributions are welcome! Please feel free to submit a Pull Request.
Have suggestions or need help? Feel free to reach out:
- Telegram: @tonyironreal - Send your feature requests or report issues
- GitHub Issues: For bug reports and feature requests
If you find this project helpful and would like to support its development, you can donate cryptocurrency to the following addresses:
- Solana (SOL):
ESUpLq9tCo1bmauWoN1rgNiYwwr5K587h15SrJz9L7ct
(Phantom Wallet)
Your support is greatly appreciated and helps maintain and improve this project!
MIT License
Copyright (c) 2025 TonyCai
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This software is for educational and research purposes only. Cryptocurrency trading involves significant risk. Use at your own risk.