# AutoHedge 🚀
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)
[![PyPI version](https://badge.fury.io/py/autohedge.svg)](https://badge.fury.io/py/autohedge)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Documentation Status](https://readthedocs.org/projects/autohedge/badge/?version=latest)](https://autohedge.readthedocs.io)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
Build your autonomous hedge fund in minutes. AutoHedge harnesses the power of swarm intelligence and AI agents to automate market analysis, risk management, and trade execution.
## 🌟 Features
- **Multi-Agent Architecture**: Leverages specialized AI agents for different aspects of trading
- Director Agent for strategy and thesis generation
- Quant Agent for technical analysis
- Risk Management Agent for position sizing and risk assessment
- Execution Agent for trade implementation
- **Real-Time Market Analysis**: Integrates with market data providers for live analysis
- **Risk-First Approach**: Built-in risk management and position sizing
- **Structured Output**: JSON-formatted trade recommendations and analysis
- **Comprehensive Logging**: Detailed logging system for trade tracking and debugging
- **Extensible Framework**: Easy to customize and extend with new capabilities
## 📋 Requirements
- Python 3.8+
- `swarms` package
- `tickr-agent`
- Additional dependencies listed in `requirements.txt`
## 🚀 Quick Start
### Installation
```bash
pip install -U autohedge
```
### Environment Variables
```bash
OPENAI_API_KEY=""
WORKSPACE_DIR="agent_workspace"
```
### Basic Usage
```python
# Example usage
from autohedge import AutoFund
# Define the stocks to analyze
stocks = ["NVDA"]
# Initialize the trading system with the specified stocks
trading_system = AutoFund(stocks)
# Define the task for the trading cycle
task = "Let's analyze nvidia to see if we should buy it, we have 50k$ in allocation"
# Run the trading cycle and print the results
print(trading_system.run(task=task))
```
## 🏗️ Architecture
AutoHedge uses a multi-agent architecture where each agent specializes in a specific aspect of the trading process:
```mermaid
graph TD
A[Director Agent] --> B[Quant Agent]
B --> C[Risk Manager]
C --> D[Execution Agent]
D --> E[Trade Output]
```
### Agent Roles
1. **Director Agent**
- Generates trading theses
- Coordinates overall strategy
- Analyzes market conditions
2. **Quant Agent**
- Performs technical analysis
- Evaluates statistical patterns
- Calculates probability scores
3. **Risk Manager**
- Assesses trade risks
- Determines position sizing
- Sets risk parameters
4. **Execution Agent**
- Generates trade orders
- Sets entry/exit points
- Manages order execution
## 📊 Output Format
AutoHedge generates structured output using Pydantic models:
```python
class AutoHedgeOutput(BaseModel):
id: str # Unique identifier
name: Optional[str] # Strategy name
description: Optional[str] # Strategy description
stocks: Optional[List[str]] # List of stocks
task: Optional[str] # Analysis task
thesis: Optional[str] # Trading thesis
risk_assessment: Optional[str] # Risk analysis
order: Optional[Dict] # Trade order details
timestamp: str # Timestamp
current_stock: str # Current stock being analyzed
```
## 🔧 Configuration
AutoHedge can be configured through environment variables or initialization parameters:
```python
trading_system = AutoFund(
name="CustomStrategy",
description="My Trading Strategy",
stocks=["NVDA", "AAPL"],
output_dir="custom_outputs"
)
```
## 📝 Logging
AutoHedge uses the `loguru` library for comprehensive logging:
```python
logger.add(
"trading_system_{time}.log",
rotation="500 MB",
retention="10 days",
level="INFO",
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}"
)
```
## 🔍 Advanced Usage
### Custom Agent Configuration
```python
from autohedge import TradingDirector, QuantAnalyst, RiskManager
# Custom director configuration
director = TradingDirector(
stocks=["NVDA", "AAPL"],
output_dir="custom_outputs"
)
# Custom analysis
analysis = director.generate_thesis(
task="Generate comprehensive analysis",
stock="NVDA"
)
```
### Risk Management
```python
from autohedge import RiskManager
risk_manager = RiskManager()
assessment = risk_manager.assess_risk(
stock="NVDA",
thesis=thesis,
quant_analysis=analysis
)
```
# Diagrams
## 🏗️ System Architecture
### High-Level Component Overview
```mermaid
flowchart TB
subgraph Client
A[AutoHedge Client] --> B[Trading System]
end
subgraph Agents["Multi-Agent System"]
B --> C{Director Agent}
C --> D[Quant Agent]
C --> E[Risk Agent]
C --> F[Execution Agent]
D --> G[Technical Analysis]
D --> H[Statistical Analysis]
E --> I[Risk Assessment]
E --> J[Position Sizing]
F --> K[Order Generation]
F --> L[Trade Execution]
end
subgraph Output
K --> M[JSON Output]
L --> N[Trade Logs]
end
```
### Trading Cycle Sequence
```mermaid
sequenceDiagram
participant C as Client
participant D as Director
participant Q as Quant
participant R as Risk
participant E as Execution
C->>D: Initialize Trading Cycle
activate D
D->>D: Generate Thesis
D->>Q: Request Analysis
activate Q
Q-->>D: Return Analysis
deactivate Q
D->>R: Request Risk Assessment
activate R
R-->>D: Return Risk Profile
deactivate R
D->>E: Generate Order
activate E
E-->>D: Return Order Details
deactivate E
D-->>C: Return Complete Analysis
deactivate D
```
### Trade State Machine
```mermaid
stateDiagram-v2
[*] --> Initialization
Initialization --> ThesisGeneration
ThesisGeneration --> QuantAnalysis
QuantAnalysis --> RiskAssessment
RiskAssessment --> OrderGeneration: Risk Approved
RiskAssessment --> ThesisGeneration: Risk Rejected
OrderGeneration --> OrderExecution
OrderExecution --> Monitoring
Monitoring --> ThesisGeneration: New Cycle
Monitoring --> [*]: Complete
```
### Data Flow
```mermaid
flowchart LR
subgraph Input
A[Market Data] --> B[Technical Indicators]
A --> C[Fundamental Data]
end
subgraph Processing
B --> D[Quant Analysis]
C --> D
D --> E[Risk Analysis]
E --> F[Order Generation]
end
subgraph Output
F --> G[Trade Orders]
F --> H[Risk Reports]
F --> I[Performance Metrics]
end
```
### Class Structure
```mermaid
classDiagram
class AutoFund {
+String name
+String description
+List stocks
+Path output_dir
+run()
}
class TradingDirector {
+Agent director_agent
+TickrAgent tickr
+generate_thesis()
}
class QuantAnalyst {
+Agent quant_agent
+analyze()
}
class RiskManager {
+Agent risk_agent
+assess_risk()
}
class ExecutionAgent {
+Agent execution_agent
+generate_order()
}
AutoFund --> TradingDirector
AutoFund --> QuantAnalyst
AutoFund --> RiskManager
AutoFund --> ExecutionAgent
```
## 🤝 Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## 📜 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 🙏 Acknowledgments
- [Swarms](https://swarms.ai) for the AI agent framework
- [Tickr Agent](https://github.com/The-Swarm-Corporation/tickr-agent) for market data integration
## 📞 Support
<!-- - Documentation: [https://autohedge.readthedocs.io](https://autohedge.readthedocs.io) -->
- Issue Tracker: [GitHub Issues](https://github.com/The-Swarm-Corporation/AutoHedge/issues)
- Discord: [Join our community](https://swarms.ai)
---
Created with ❤️ by [The Swarm Corporation](https://github.com/The-Swarm-Corporation)
Raw data
{
"_id": null,
"home_page": "https://github.com/The-Swarm-Corporation/AutoHedge",
"name": "autohedge",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "artificial intelligence, deep learning, optimizers, Prompt Engineering",
"author": "Kye Gomez",
"author_email": "kye@apac.ai",
"download_url": "https://files.pythonhosted.org/packages/30/f1/d84bbe2c8357751280feb505329a32f152c25bcb83558eae84ad01e81279/autohedge-0.1.0.tar.gz",
"platform": null,
"description": "# AutoHedge \ud83d\ude80\n\n[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)\n\n\n[![PyPI version](https://badge.fury.io/py/autohedge.svg)](https://badge.fury.io/py/autohedge)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![Documentation Status](https://readthedocs.org/projects/autohedge/badge/?version=latest)](https://autohedge.readthedocs.io)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nBuild your autonomous hedge fund in minutes. AutoHedge harnesses the power of swarm intelligence and AI agents to automate market analysis, risk management, and trade execution.\n\n## \ud83c\udf1f Features\n\n- **Multi-Agent Architecture**: Leverages specialized AI agents for different aspects of trading\n - Director Agent for strategy and thesis generation\n - Quant Agent for technical analysis\n - Risk Management Agent for position sizing and risk assessment\n - Execution Agent for trade implementation\n\n- **Real-Time Market Analysis**: Integrates with market data providers for live analysis\n- **Risk-First Approach**: Built-in risk management and position sizing\n- **Structured Output**: JSON-formatted trade recommendations and analysis\n- **Comprehensive Logging**: Detailed logging system for trade tracking and debugging\n- **Extensible Framework**: Easy to customize and extend with new capabilities\n\n## \ud83d\udccb Requirements\n\n- Python 3.8+\n- `swarms` package\n- `tickr-agent`\n- Additional dependencies listed in `requirements.txt`\n\n## \ud83d\ude80 Quick Start\n\n### Installation\n\n```bash\npip install -U autohedge\n```\n\n### Environment Variables\n\n```bash\nOPENAI_API_KEY=\"\"\nWORKSPACE_DIR=\"agent_workspace\"\n```\n\n### Basic Usage\n\n```python\n# Example usage\nfrom autohedge import AutoFund\n\n# Define the stocks to analyze\nstocks = [\"NVDA\"]\n\n# Initialize the trading system with the specified stocks\ntrading_system = AutoFund(stocks)\n\n# Define the task for the trading cycle\ntask = \"Let's analyze nvidia to see if we should buy it, we have 50k$ in allocation\"\n\n# Run the trading cycle and print the results\nprint(trading_system.run(task=task))\n\n```\n\n## \ud83c\udfd7\ufe0f Architecture\n\nAutoHedge uses a multi-agent architecture where each agent specializes in a specific aspect of the trading process:\n\n```mermaid\ngraph TD\n A[Director Agent] --> B[Quant Agent]\n B --> C[Risk Manager]\n C --> D[Execution Agent]\n D --> E[Trade Output]\n```\n\n### Agent Roles\n\n1. **Director Agent**\n - Generates trading theses\n - Coordinates overall strategy\n - Analyzes market conditions\n\n2. **Quant Agent**\n - Performs technical analysis\n - Evaluates statistical patterns\n - Calculates probability scores\n\n3. **Risk Manager**\n - Assesses trade risks\n - Determines position sizing\n - Sets risk parameters\n\n4. **Execution Agent**\n - Generates trade orders\n - Sets entry/exit points\n - Manages order execution\n\n## \ud83d\udcca Output Format\n\nAutoHedge generates structured output using Pydantic models:\n\n```python\nclass AutoHedgeOutput(BaseModel):\n id: str # Unique identifier\n name: Optional[str] # Strategy name\n description: Optional[str] # Strategy description\n stocks: Optional[List[str]] # List of stocks\n task: Optional[str] # Analysis task\n thesis: Optional[str] # Trading thesis\n risk_assessment: Optional[str] # Risk analysis\n order: Optional[Dict] # Trade order details\n timestamp: str # Timestamp\n current_stock: str # Current stock being analyzed\n```\n\n## \ud83d\udd27 Configuration\n\nAutoHedge can be configured through environment variables or initialization parameters:\n\n```python\ntrading_system = AutoFund(\n name=\"CustomStrategy\",\n description=\"My Trading Strategy\",\n stocks=[\"NVDA\", \"AAPL\"],\n output_dir=\"custom_outputs\"\n)\n```\n\n\n## \ud83d\udcdd Logging\n\nAutoHedge uses the `loguru` library for comprehensive logging:\n\n```python\nlogger.add(\n \"trading_system_{time}.log\",\n rotation=\"500 MB\",\n retention=\"10 days\",\n level=\"INFO\",\n format=\"{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}\"\n)\n```\n\n## \ud83d\udd0d Advanced Usage\n\n### Custom Agent Configuration\n\n```python\nfrom autohedge import TradingDirector, QuantAnalyst, RiskManager\n\n# Custom director configuration\ndirector = TradingDirector(\n stocks=[\"NVDA\", \"AAPL\"],\n output_dir=\"custom_outputs\"\n)\n\n# Custom analysis\nanalysis = director.generate_thesis(\n task=\"Generate comprehensive analysis\",\n stock=\"NVDA\"\n)\n```\n\n### Risk Management\n\n```python\nfrom autohedge import RiskManager\n\nrisk_manager = RiskManager()\nassessment = risk_manager.assess_risk(\n stock=\"NVDA\",\n thesis=thesis,\n quant_analysis=analysis\n)\n```\n\n# Diagrams\n\n## \ud83c\udfd7\ufe0f System Architecture\n\n### High-Level Component Overview\n```mermaid\nflowchart TB\n subgraph Client\n A[AutoHedge Client] --> B[Trading System]\n end\n \n subgraph Agents[\"Multi-Agent System\"]\n B --> C{Director Agent}\n C --> D[Quant Agent]\n C --> E[Risk Agent]\n C --> F[Execution Agent]\n \n D --> G[Technical Analysis]\n D --> H[Statistical Analysis]\n \n E --> I[Risk Assessment]\n E --> J[Position Sizing]\n \n F --> K[Order Generation]\n F --> L[Trade Execution]\n end\n \n subgraph Output\n K --> M[JSON Output]\n L --> N[Trade Logs]\n end\n```\n\n### Trading Cycle Sequence\n```mermaid\nsequenceDiagram\n participant C as Client\n participant D as Director\n participant Q as Quant\n participant R as Risk\n participant E as Execution\n \n C->>D: Initialize Trading Cycle\n activate D\n D->>D: Generate Thesis\n D->>Q: Request Analysis\n activate Q\n Q-->>D: Return Analysis\n deactivate Q\n D->>R: Request Risk Assessment\n activate R\n R-->>D: Return Risk Profile\n deactivate R\n D->>E: Generate Order\n activate E\n E-->>D: Return Order Details\n deactivate E\n D-->>C: Return Complete Analysis\n deactivate D\n```\n\n### Trade State Machine\n```mermaid\nstateDiagram-v2\n [*] --> Initialization\n Initialization --> ThesisGeneration\n \n ThesisGeneration --> QuantAnalysis\n QuantAnalysis --> RiskAssessment\n \n RiskAssessment --> OrderGeneration: Risk Approved\n RiskAssessment --> ThesisGeneration: Risk Rejected\n \n OrderGeneration --> OrderExecution\n OrderExecution --> Monitoring\n \n Monitoring --> ThesisGeneration: New Cycle\n Monitoring --> [*]: Complete\n```\n\n### Data Flow\n```mermaid\nflowchart LR\n subgraph Input\n A[Market Data] --> B[Technical Indicators]\n A --> C[Fundamental Data]\n end\n \n subgraph Processing\n B --> D[Quant Analysis]\n C --> D\n D --> E[Risk Analysis]\n E --> F[Order Generation]\n end\n \n subgraph Output\n F --> G[Trade Orders]\n F --> H[Risk Reports]\n F --> I[Performance Metrics]\n end\n```\n\n### Class Structure\n```mermaid\nclassDiagram\n class AutoFund {\n +String name\n +String description\n +List stocks\n +Path output_dir\n +run()\n }\n \n class TradingDirector {\n +Agent director_agent\n +TickrAgent tickr\n +generate_thesis()\n }\n \n class QuantAnalyst {\n +Agent quant_agent\n +analyze()\n }\n \n class RiskManager {\n +Agent risk_agent\n +assess_risk()\n }\n \n class ExecutionAgent {\n +Agent execution_agent\n +generate_order()\n }\n \n AutoFund --> TradingDirector\n AutoFund --> QuantAnalyst\n AutoFund --> RiskManager\n AutoFund --> ExecutionAgent\n```\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## \ud83d\udcdc License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n- [Swarms](https://swarms.ai) for the AI agent framework\n- [Tickr Agent](https://github.com/The-Swarm-Corporation/tickr-agent) for market data integration\n\n## \ud83d\udcde Support\n\n<!-- - Documentation: [https://autohedge.readthedocs.io](https://autohedge.readthedocs.io) -->\n- Issue Tracker: [GitHub Issues](https://github.com/The-Swarm-Corporation/AutoHedge/issues)\n- Discord: [Join our community](https://swarms.ai)\n\n---\nCreated with \u2764\ufe0f by [The Swarm Corporation](https://github.com/The-Swarm-Corporation)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "autohedge - TGSC",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://github.com/The-Swarm-Corporation/AutoHedge",
"Homepage": "https://github.com/The-Swarm-Corporation/AutoHedge",
"Repository": "https://github.com/The-Swarm-Corporation/AutoHedge"
},
"split_keywords": [
"artificial intelligence",
" deep learning",
" optimizers",
" prompt engineering"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "272c0640197498266d2b1221aa438f4b31529004b6c1b7a22501b93e52ecf255",
"md5": "bb78d3bb0dbb3fc4d7b92916cda4128e",
"sha256": "33cfc16324aa1f725518a47a2fddb61ada2b94a69152692b7a732cd782fdd470"
},
"downloads": -1,
"filename": "autohedge-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bb78d3bb0dbb3fc4d7b92916cda4128e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 15661,
"upload_time": "2024-12-12T05:20:55",
"upload_time_iso_8601": "2024-12-12T05:20:55.644010Z",
"url": "https://files.pythonhosted.org/packages/27/2c/0640197498266d2b1221aa438f4b31529004b6c1b7a22501b93e52ecf255/autohedge-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "30f1d84bbe2c8357751280feb505329a32f152c25bcb83558eae84ad01e81279",
"md5": "bbe56c21529dcdbda17d305c3778fa0e",
"sha256": "891d32f3c833598ff242247b2b04b27c577ee463d7524229cf4a1455582a3418"
},
"downloads": -1,
"filename": "autohedge-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "bbe56c21529dcdbda17d305c3778fa0e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 16436,
"upload_time": "2024-12-12T05:20:58",
"upload_time_iso_8601": "2024-12-12T05:20:58.500929Z",
"url": "https://files.pythonhosted.org/packages/30/f1/d84bbe2c8357751280feb505329a32f152c25bcb83558eae84ad01e81279/autohedge-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-12 05:20:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "The-Swarm-Corporation",
"github_project": "AutoHedge",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "swarms",
"specs": []
},
{
"name": "tickr-agent",
"specs": []
},
{
"name": "pydantic",
"specs": []
},
{
"name": "loguru",
"specs": []
},
{
"name": "swarm-models",
"specs": []
}
],
"lcname": "autohedge"
}