Curious about how AI is transforming quantitative trading and hedge funds? The open-source AI Hedge Fund project lets you simulate an automated trading desk using AI agents—without risking real capital. In this hands-on guide, you’ll set up the project, run trading simulations on stocks like Apple and Microsoft, and see how advanced AI decision-making works under the hood. No financial background required—just Python skills and curiosity.
💡 Need to document APIs for your trading system? Try Apidog for intuitive, interactive API documentation—ideal for trading and fintech projects.
What Is the AI Hedge Fund Project?
The AI Hedge Fund is an open-source simulator that models a hedge fund using AI-powered agents. Each agent specializes in a unique investing style, inspired by real-world figures like Warren Buffett and Cathie Wood. The project leverages large language models (LLMs) such as GPT-4o or Llama 3 to analyze financial data, evaluate strategies, and execute simulated trades.
Key Features:
- Modular AI Agents: Includes fundamentals, technicals, sentiment, risk management, and portfolio management agents.
- Flexible Data Sources: Pulls free stock data (AAPL, MSFT, NVDA, GOOGL, TSLA) via the Financial Datasets API.
- Customizable LLMs: Supports cloud-based (OpenAI, Groq) and local (Ollama) language models.
- Comprehensive Simulations: Backtests strategies so you can measure performance and tweak approaches.
With over 2,000 stars on GitHub, this tool offers practical exposure to AI-driven trading workflows for developers.
Setting Up the AI Hedge Fund: Environment Preparation
Get your environment ready with these clear steps. No advanced finance or infrastructure skills are required.
1. System Requirements
- OS: Windows (via WSL2), macOS, or Linux (Ubuntu 20.04+ preferred)
- Software:
- Python 3.10 (
python3 --version) - Git (
git --version) - Docker CLI/Desktop (optional, for Ollama/local LLMs)
- Python 3.10 (
- For Windows: Install WSL2 using
wsl --installin PowerShell (Admin), then reboot.
Install any missing prerequisites from python.org or git-scm.com.
2. Install Poetry for Dependency Management
Poetry ensures Python dependencies are reproducible:
curl -sSL https://install.python-poetry.org | python3 -
Check with poetry --version. If needed, add to your PATH:
export PATH="$HOME/.local/bin:$PATH"
3. Obtain Required API Keys
- OpenAI: Register at platform.openai.com for GPT-4o access.
- Financial Datasets: Sign up at financialdatasets.ai for free stock data.
- Optional: Groq (groq.com) or Anthropic API keys for alternative LLMs; Ollama for local models.
4. Organize Your Project
mkdir ai-hedge-fund
cd ai-hedge-fund
Installing the AI Hedge Fund Project
Follow these steps to get the code and dependencies in place.
1. Clone the Repository
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund
This downloads the full project, including agent scripts and tools.
2. Install Python Dependencies
poetry install
Poetry handles packages like pandas, requests, and LLM SDKs.
3. Configure Environment Variables
Copy and edit the .env file:
cp .env.example .env
nano .env
Add your API keys:
OPENAI_API_KEY=your-openai-api-key
GROQ_API_KEY=your-groq-api-key
FINANCIAL_DATASETS_API_KEY=your-financial-datasets-api-key
For local LLMs, you can skip the OpenAI key and use Ollama (see below).
4. (Optional) Set Up Ollama for Local Language Models
Run Llama 3 or other models on your hardware:
curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3
ollama serve
Note: Llama 3 requires ~5GB disk space. Make sure Docker is installed if using it for Ollama.

Running AI Hedge Fund Trading Simulations
Now, let's see the AI agents in action with a real trading simulation.
1. Start a Trading Simulation
From your project directory, run:
poetry run python src/main.py --ticker AAPL,MSFT
Or, for local LLMs:
poetry run python src/main.py --ticker AAPL,MSFT --ollama
- What Happens:
- The system analyzes selected stocks using fundamentals, technical indicators, and sentiment.
- The agents collaborate to evaluate opportunities and risks.
- Trade decisions, signals, and backtest results are output to the terminal and saved in
src/logs/.
Example Agent Collaboration:
- Fundamentals Agent: Evaluates Apple’s revenue growth, Microsoft’s cash flow.
- Technicals Agent: Looks for buy or sell signals using moving averages.
- Sentiment Agent: Uses NLP to process news headlines for market mood.
- Risk Manager: Ensures position sizing is sensible.
- Portfolio Manager: Executes simulated trades based on aggregated signals.

2. Running Historical Backtests
Backtest across multiple stocks and timeframes:
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA
Specify date ranges for detailed analysis:
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01
Docker users:
- Linux/Mac:
./run.sh --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 backtest - Windows:
run.bat --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 backtest

Exploring Key Features and Customization
The AI Hedge Fund is highly extensible—perfect for developers wanting to experiment and learn.
- Agent Tweaks: Modify agent scripts in
src/agents/(e.g.,bill_ackman.pyfor activist strategies). Adjust logic or add your own agent for new investing signals. - Add More Stocks: Use the
--tickerflag to include NVDA, TSLA, and others (requires a Financial Datasets API key for non-free stocks). - Backtesting Tools:
backtester.pylets you replay historical performance and compare strategies. - Sentiment Analysis: The Sentiment Agent applies NLP to news and social media. Try: “Analyze NVDA news sentiment.”
- Run Offline: Integrate with Ollama and Llama 3 for local, cost-efficient simulations.
Example: Tweaking the Technicals Agent to focus on RSI (Relative Strength Index) can sharpen buy/sell signals for more responsive strategies.
Documenting Your Trading APIs Using Apidog
As your trading system grows, clear API documentation becomes essential—especially for collaboration or integration with other teams. Apidog offers an interactive, developer-friendly platform for documenting RESTful APIs. Its intuitive interface and self-hosting support make it ideal for fintech and AI trading projects.

Troubleshooting & Developer Tips
- API Key Issues: Double-check your
.envfile. Usecat .envto verify values. - Dependency Errors: If
poetry installfails, update Poetry withpoetry self update. - Ollama Connection: Ensure
ollama serveis running and port 11434 is accessible (netstat -tulpn | grep 11434on Linux). - Performance: For faster simulations, use locally hosted LLMs on a GPU, or stick with high-performance cloud LLMs like GPT-4o.
- Community Support: Join the GitHub Discussions for help and to share custom agents or results.
Why Developers Should Explore the AI Hedge Fund
This project is a practical sandbox for:
- Learning Quantitative Finance: Get hands-on with AI approaches used in major hedge funds.
- Risk-Free Experimentation: Simulate strategies without risking real money.
- Custom Research: Adapt agents to match your trading philosophy or research interests.
- API-Centric Workflows: Ideal for teams building or testing trading APIs—especially when paired with Apidog for documentation.
The Sentiment Agent’s ability to spot bullish news on MSFT and adjust trades is a highlight—showing how AI can enhance real-world decision making.
Conclusion: Level Up Your AI Trading Skills
You’ve now got the tools to launch your own AI-powered hedge fund simulation—an excellent way to blend Python, finance, and AI in one project. Experiment with new agents, backtest diverse strategies, and streamline your API documentation with Apidog. Share your results or customizations with the open-source community and drive your API-driven trading platform forward.



