{"repo":"51bitquant/ai-hedge-fund-crypto","free":true,"listed":false,"github":"https://github.com/51bitquant/ai-hedge-fund-crypto","clone":"git clone https://github.com/51bitquant/ai-hedge-fund-crypto.git","description":"AI-Hedge-Fund for Crypto 🚀  AI-powered hedge fund for cryptocurrency trading, leveraging LLM agents for intelligent decision-making.","language":"Python","stars":615,"topics":["ai-agent","ai-trading","ai-trading-agent","algorithmic-trading","backtesting","crypto-trading","hedge-fund","langchain","langchain-python","llm","llm-agent","multi-timeframe-analysis","openai","portfolio-management","quantitative-finance","strategy-ensembling","technical-analysis"],"license":"MIT","category":"algo_trading","readme_excerpt":"# AI Hedge Fund Crypto\n\n[![English](https://img.shields.io/badge/Language-English-blue)](README.md)\n[![中文](https://img.shields.io/badge/语言-中文-red)](README_CN.md)\n\nA next-generation algorithmic trading framework that leverages graph-based workflow architecture, \nensemble technical analysis, and AI language models to make data-driven cryptocurrency trading decisions. \nThis system employs a directed acyclic graph (DAG) of specialized nodes for multi-timeframe analysis, \nenabling sophisticated signal generation through weighted combinations of diverse trading strategies.\n\nAt its core, the system builds upon LangGraph's computational graph architecture to process market data through \na pipeline of technical analysis nodes. Each strategy implements a BaseNode interface that processes multi-interval data \nfor multiple assets simultaneously. The framework then aggregates these signals using adaptive weighting mechanisms, \nevaluates risk parameters, and formulates position management decisions through large language model (LLM) analysis.\n\nThe system stands out through its:\n- **AI-Enhanced Decision Making**: Integration of large language models (LLMs) for portfolio management decisions, combining technical signals with sophisticated reasoning\n- **Compositional Architecture**: Distinct nodes for data fetching, strategy execution, risk management, and portfolio management\n- **Signal Ensemble Approach**: Weighted aggregation of multiple technical strategies (trend following, mean reversion, momentum, volatility, and statistical arbitrage)\n- **Multi-Timeframe Analysis**: Simultaneous processing across various time intervals for more robust signal generation\n- **Dynamic Strategy Visualization**: Automatic generation of computational graph visualizations to better understand the decision flow\n- **Comprehensive Backtesting**: Robust historical performance evaluation with detailed metrics and visualizations\n\n## Backtest Results\n\nSample backtesting results showcasing how well-designed trading strategies can generate high-quality signals \nwhen implemented in this framework. The system's performance is driven by the quality of your strategies, \nwith the framework enabling efficient implementation, LLM-based decision refinement, and multi-timeframe analysis:\n\n![Backtest Results](imgs/backtest1.png)\n![Backtest Results](imgs/backtest2.png)\n![Portfolio Performance](imgs/backtest3.png)\n\nThese results demonstrate the system's ability to:\n- Generate profitable trading signals across different market conditions\n- Manage risk effectively with position sizing rules\n- Adapt to changing market dynamics with multi-timeframe analysis\n- Provide detailed performance metrics for strategy evaluation\n\n## Architecture\n\nThe system is built around a highly configurable directed acyclic graph (DAG) architecture, where data flows through various processing nodes. \nThis architecture provides exceptional flexibility, allowing users to customize both the available strategies and the timeframes for analysis without modifying the core code.\n\n### Node-Based Workflow System\n\nAt its heart, the system uses LangGraph to create a dynamic computational graph where:\n\n1. **Start Node**: Initializes the workflow and prepares the state for processing\n2. **Data Nodes**: Process market data for specific intervals (e.g., 30m, 1h, 4h) \n3. **Strategy Nodes**: Apply technical analysis algorithms to the processed data\n4. **Risk Management Node**: Evaluates position limits and exposure\n5. **Portfolio Management Node**: Makes final trading decisions using LLM reasoning\n\nThe key innovation is that both the data nodes and strategy nodes are fully configurable via the `config.yaml` file, \nallowing you to add, remove, or modify these nodes without changing the core architecture.\n\n![Graph Demo1](imgs/graph1.png)\n\n### Configurable Timeframes\n\nYou can specify multiple timeframes for analysis in your configuration:\n\n```yaml\nsignals:\n  intervals: [\"5m\", \"15m\", \"30m\", \"1h\", \"4h\", \"1d\"]\n```\n\nThe system will dynamically create separate data processing nodes for each timeframe, allowing strategies to analyze market behavior across multiple time horizons simultaneously. \nThis multi-timeframe approach provides more robust signals by capturing both short-term and long-term market trends.\n\n![Graph Demo2](imgs/graph2.png)\n\n### Configurable Strategies\n\nSimilarly, you can specify which trading strategies to include:\n\n```yaml\nsignals:\n  strategies: ['MacdStrategy', 'RSIStrategy', 'BollingerStrategy']\n```\n\nThe system will dynamically load and integrate only the specified strategies into the workflow graph. Each strategy is implemented as an independent node that:\n\n1. Receives the aggregated multi-timeframe data\n2. Applies its specific technical analysis algorithms\n3. Generates trading signals with confidence levels\n4. Passes these signals to the risk management node\n\nThis modular approach allows you to easily experiment with different combinations of strategies without rewriting any code. \nYou can also create your own custom strategy modules and add them to the configuration.\n\n![Graph Demo3](imgs/graph3.png)\n\n### Data Flow Architecture\n\nThe complete data flow works as follows:\n\n1. The start node initializes the workflow state\n2. Multiple timeframe nodes fetch and process data in parallel for different intervals\n3. The merge node combines the multi-timeframe data into a unified state\n4. Multiple strategy nodes analyze this unified data and generate signals\n5. The risk management node applies position sizing and exposure limits\n6. The portfolio management node makes final trading decisions using all available signals and LLM reasoning\n\nThis architecture provides several advantages:\n- **Flexibility**: Change strategies or timeframes without code modifications\n- **Parallelization**: Process multiple timeframes concurrently for improved performance\n- **Isolation**: Maintain separation of concerns between different components\n- **Extensibility**: Add new strategy nodes without affecting existing functionality\n- **Visualization**: Generate visual representations of the workflow for better understanding\n\n## Features\n\n- **Strategy-Based Architecture**: Implement and backtest multiple trading strategies\n- **Multi-Timeframe Analysis**: Analyze multiple intervals (1h, 4h, 1d, etc.) simultaneously\n- **Multiple Technical Indicators**: MACD, RSI, and custom indicator support\n- **Comprehensive Backtesting**: Test strategies against historical data\n- **Portfolio Management**: Manage positions with support for both long and short trades\n- **Performance Metrics**: Detailed performance statistics and visualization\n- **Strategy Visualization**: Automatically generate strategy workflow graphs\n\n## Table of Contents\n- [Setup](#setup)\n- [Configuration](#configuration)\n- [Usage](#usage)\n  - [Running Backtest Mode](#running-backtest-mode)\n  - [Running Live Mode](#running-live-mode)\n- [Creating Custom Strategies](#creating-custom-strategies)\n- [Project Structure](#project-structure)\n- [Contributing](#contributing)\n- [Star History](#star-history)\n- [License](#license)\n- [Disclaimer](#disclaimer)\n- [Referral Links](#referral-links)\n\n## Setup\n\n### Prerequisites\n- Python 3.9 or higher (Python 3.12 recommended — used during development)\n- Binance account (required for accessing market data)\n\n⚠️ While Python 3.9+ should work, we recommend using Python 3.12 for full compatibility with the development environment.\n\n### Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/51bitquant/ai-hedge-fund-crypto.git\ncd ai-hedge-fund-crypto\n```\n\n2. Set up using uv (recommended):\n```bash\n# Install uv if you don't have it\ncurl -fsSL https://install.lunarvim.org/uv.sh | sh\n\n# create an venv with python 3.12\nuv venv --python 3.12\n\n# Activate the virtual environment\n# For macOS/Linux:\nsource .venv/bin/activate\n# For Windows (PowerShell):\n.venv\\Scripts\\Activate.ps1\n\n# For Windows (CMD):\n.venv\\Scripts\\activate.bat\n# Install dependencies using pyproject.toml and lockfile\nuv pip sync\n```\nIf you have more questions, feel free to check out the [uv documentation](https://docs.astral.sh/uv/getting-started/installation/)\n\n3. Copy the example configuration:\n```bash\ncp config.example.yaml config.yaml\n```\n\n4. Set up environment variables:\n```bash\ncp .env.example .env\n```\n\n5. Add your API keys to the `.env` file:\n```\n# Binance API keys (required for data access)\nBINANCE_API_KEY=your-binance-api-key\nBINANCE_API_SECRET=your-binance-api-secret\n# For running LLMs hosted by openai (gpt-4o, gpt-4o-mini, etc.)\n# Get your OpenAI API key from https://platform.openai.com/\nOPENAI_API_KEY=your-open-ai-key\nGROQ_API_KEY=your-open-ai-key\nOPENROUTER_API_KEY=your-open-ai-key\nANTHROPIC_API_KEY=your-anthropic-api-key\nGOOGLE_API_KEY=your-google-api-key\n```\n\n## Configuration\n\nThe system is configured through the `config.yaml` file. Here's what each setting means:\n\n```yaml\nmode: backtest  # Options: backtest, live\nstart_date: 2025-04-20  # Start date for backtesting\nend_date: 2025-05-01  # End date for backtesting\nprimary_interval: 1h  # Main timeframe for analysis\ninitial_cash: 100000  # Starting capital\nmargin_requirement: 0.0  # Margin requirements for short positions\nshow_reasoning: false  # Whether to show strategy reasoning\nshow_agent_graph: true  # Whether to show the agent workflow graph\nsignals:\n  intervals: [\"30m\", \"1h\", \"4h\"]  # Timeframes to analyze\n  tickers: [\"BTCUSDT\", \"ETHUSDT\"]  # Trading pairs\n  strategies: ['MacdStrategy']  # Strategies to use\nmodel:\n  name: \"gpt-4o-mini\" # config your model\n  provider: \"openai\"  # config your llm provider, support openai， groq， openrouter，gemini，anthropic，ollama\n#  base_url: \"https://api.openai.com/v1\"  # not required, but if you want to set the base_url\n```\n**Supported providers include OpenAI, Groq, OpenRouter, Gemini, Anthropic, and Ollama.** Most LLMs are compatible with the OpenAI SDK,\nso you can often switch models by simply adjusting the model name and base_url to match the desired provider.\n\n## Usage\n","default_branch":"main","files":66,"tree":[".env.example",".github/ISSUE_TEMPLATE/bug_report.md",".github/ISSUE_TEMPLATE/feature_request.md",".gitignore",".python-version","LICENSE","MacdStrategy_graph.png","MacdStrategy_graph.pngRSIStrategy_graph.png","MyStrategy_graph.png","README.md","README_CN.md","backtest.py","config.example.yaml","config.yaml","imgs/backtest1.png","imgs/backtest2.png","imgs/backtest3.png","imgs/graph1.png","imgs/graph2.png","imgs/graph3.png","main.py","pyproject.toml","src/__init__.py","src/agent/__init__.py","src/agent/agent.py","src/agent/workflow.py","src/backtest/__init__.py","src/backtest/backtester.py","src/gateway/__init__.py","src/gateway/binance/__init__.py","src/gateway/binance/async_client.py","src/gateway/binance/base_client.py","src/gateway/binance/client.py","src/gateway/binance/enums.py","src/gateway/binance/exceptions.py","src/gateway/binance/helpers.py","src/gateway/binance/ws/__init__.py","src/gateway/binance/ws/constants.py","src/gateway/binance/ws/depthcache.py","src/gateway/binance/ws/keepalive_websocket.py","src/gateway/binance/ws/reconnecting_websocket.py","src/gateway/binance/ws/streams.py","src/gateway/binance/ws/threaded_stream.py","src/gateway/binance/ws/websocket_api.py","src/graph/__init__.py","src/graph/base_node.py","src/graph/data_node.py","src/graph/empty_ndoe.py","src/graph/portfolio_management_node.py","src/graph/risk_management_node.py","src/graph/start_node.py","src/graph/state.py","src/indicators/__init__.py","src/indicators/general_indicators.py","src/llm/__init__.py","src/strategies/__init__.py","src/strategies/macd_strategy.py","src/strategies/my_strategy.py","src/strategies/rsi_strategy.py","src/test/test_merged_dicts.py","src/utils/__init__.py","src/utils/binance_data_provider.py","src/utils/constants.py","src/utils/settings.py","src/utils/util_func.py","uv.lock"],"storefront":"/r/51bitquant","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/51bitquant/ai-hedge-fund-crypto/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}