Have you ever wondered how Wall Street’s elite use AI to rake in millions? With the AI Hedge Fund project, you can dive into the world of automated trading without risking a dime. This open-source gem from GitHub lets you simulate a hedge fund powered by AI agents inspired by legends like Warren Buffett and Cathie Wood. I got hooked exploring its trading strategies, and in this tutorial, I’ll show you how to set up your own AI Hedge Fund, run a trading simulation with stocks like Apple and Microsoft, and peek under the hood of its brainy agents. No finance PhD needed—just curiosity and a laptop! Ready to play hedge fund manager? Let’s roll!
What is the AI Hedge Fund? Your Virtual Trading Team
The AI Hedge Fund is an open-source project on GitHub that simulates a hedge fund using AI agents to make trading decisions. You can think of it as a digital dream team where each agent has a specialty, mimicking real-world investing gurus. Built for educational purposes, it uses large language models (LLMs) like GPT-4o or Llama 3 to analyze financial data and simulate trades—no real money involved. Key features include:
- Specialized Agents: Fundamentals, Technicals, Sentiment, Risk Manager, and Portfolio Manager analyze data and make decisions.
- Data Sources: Pulls free financial data for stocks like AAPL, MSFT, NVDA, GOOGL, and TSLA via the Financial Datasets API.
- Customizable: Run it with cloud-based LLMs (OpenAI, Groq) or local models via Ollama.
- Simulation: Backtests strategies to see how trades would’ve performed.
With 2K+ stars, it’s a hit for learning how AI is shaking up hedge funds. Let’s set it to trade smarter than a Wall Street bro!

Setting Up Your AI Hedge Fund Environment
Before we unleash your AI Hedge Fund, let’s prep your system. This is beginner-friendly, and I’ll guide you through each step.
1. Check System Requirements:
- OS: Windows (with WSL2), macOS, or Linux (Ubuntu 20.04+ recommended).
- Software:
- Python 3.10 (check with
python3 --version
). - Git (check with
git --version
). - Docker CLI or Docker Desktop for Ollama (optional, for local LLMs).
- If you’re on Windows, install WSL2 WSL2 by running
wsl --install
in PowerShell (Admin) and reboot. Missing anything? Install it now from python.org or git-scm.com.
2. Install Poetry: Poetry manages Python dependencies. Install it:
curl -sSL https://install.python-poetry.org | python3 -
Verify with poetry --version
(e.g., 1.8.0). Add Poetry to your PATH if needed: export PATH="$HOME/.local/bin:$PATH"
.
3. Get API Keys:
- OpenAI: Sign up at platform.openai.com for GPT-4o access. Copy your API key.
- Financial Datasets: Register at financialdatasets.ai for free stock data (AAPL, MSFT, etc.). Copy the key.
- Optional: Groq (groq.com) or Anthropic (anthropic) keys for other LLMs, or Ollama for local models.
4. Create a Project Folder: Stay organized:
mkdir ai-hedge-fund
cd ai-hedge-fund
Installing the AI Hedge Fund
Now, let’s clone and set up the AI Hedge Fund project. It’s quick and sets you up for trading simulations.
1. Clone the Repository: Grab the code from GitHub:
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund
This pulls the project (~50MB), including agent scripts and tools.
2. Install Dependencies: Use Poetry to install required libraries:
poetry install
This sets up Python packages like pandas
, requests
, and LLM SDKs. It takes a minute or two.
3. Configure API Keys: Create a .env
file to store your keys:
cp .env.example .env
Edit .env
with a text editor (e.g., nano .env
) and add:
# For running LLMs hosted by openai (gpt-4o, gpt-4o-mini, etc.)
# Get your OpenAI API key from https://platform.openai.com/
OPENAI_API_KEY=your-openai-api-key
# For running LLMs hosted by groq (deepseek, llama3, etc.)
# Get your Groq API key from https://groq.com/
GROQ_API_KEY=your-groq-api-key
# For getting financial data to power the hedge fund
# Get your Financial Datasets API key from https://financialdatasets.ai/
FINANCIAL_DATASETS_API_KEY=your-financial-datasets-api-key
Save and exit. For local LLMs, skip OpenAI and use Ollama (see below).
4. Optional: Set Up Ollama for Local LLMs: Want to run models like Llama 3 locally? Install Ollama:
curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3
Start Ollama: ollama serve
. This uses ~5GB for Llama 3. Ensure Docker is installed (docker.com) if running via Docker.

Running Your AI Hedge Fund: A Trading Simulation
Let’s fire up your AI Hedge Fund and simulate trades on stocks like Apple (AAPL) and Microsoft (MSFT). We’ll see how the AI agents work together.
1. Run the Simulation: In the ai-hedge-fund
folder, execute:
poetry run python src/main.py --ticker AAPL,MSFT
Or, for local LLMs:
poetry run python src/main.py --ticker AAPL,MSFT --ollama
This command:
- Targets AAPL and MSFT (free data from Financial Datasets).
- Uses AI agents to analyze fundamentals (e.g., P/E ratios), technicals (e.g., moving averages), sentiment (e.g., news), and risks.
- Simulates trades and outputs decisions.
2. What Happens?: The agents collaborate:
- Fundamentals Agent: Checks AAPL’s revenue growth and MSFT’s cash flow.
- Technicals Agent: Analyzes 50-day moving averages for buy/sell signals.
- Sentiment Agent: Scans news for positive/negative vibes (e.g., “Apple launches new iPhone”).
- Risk Manager: Sets position limits to avoid big losses.
- Portfolio Manager: Decides to buy 100 AAPL shares and hold MSFT based on signals.

View Results: Check the terminal for trade decisions, probabilities, and backtest results. Logs are saved in src/logs/
.
3. Running the Backtester: use the following command:
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA
Sample Output:

You also have the option to specify the start and end dates to backtest over a specific time period.
# With Poetry:
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01
# With Docker (on Linux/Mac):
./run.sh --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 backtest
# With Docker (on Windows):
run.bat --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 backtest

Exploring AI Hedge Fund Features
Your AI Hedge Fund is more than a script—it’s a learning playground. Here’s how to dig deeper:
- Agent Customization: Edit agent scripts in
src/agents/
(e.g.,bill_ackman.py
for activist investing). Tweak strategies like buying undervalued stocks. - Add Stocks: Try NVDA or TSLA in the
--ticker
flag (requires a Financial Datasets API key for non-free stocks). - Backtesting: The
backtester.py
tool simulates historical performance. Runpoetry run python src/backtester.py --ticker AAPL
to see past returns. - Sentiment Analysis: The Sentiment Agent uses NLP to parse news and social media, boosting decision accuracy. Test it with: “Analyze NVDA news sentiment.”
- Run Locally: Use Ollama with
llama3
for offline trading simulations, saving API costs.
I tweaked the Technicals Agent to focus on RSI (Relative Strength Index) and saw sharper buy signals—super fun to experiment!
Documenting Your APIs with APIdog
Building on your AI Hedge Fund and want to document its APIs for others? APIdog is a top-notch tool for creating interactive API docs. Its sleek design and self-hosting options make it perfect for sharing your trading system’s endpoints—give it a spin!

Troubleshooting and Tips
- API Key Errors: Ensure
.env
keys match your OpenAI/Financial Datasets accounts. Check withcat .env
. - Dependency Issues: If
poetry install
fails, update Poetry:poetry self update
. - Ollama Not Connecting: Verify
ollama serve
is running and port 11434 is open (netstat -tulpn | grep 11434
on Linux). - Performance: For faster runs, use a GPU with Ollama or stick to cloud LLMs like GPT-4o.
- Community: Join the project’s GitHub Discussions for help or to share your custom agents.
Why Use an AI Hedge Fund?
This AI Hedge Fund project is a goldmine for learning:
- Educational: Understand how AI drives trading at firms like Two Sigma.
- No Risk: Simulate trades without losing money.
- Customizable: Tweak agents to match your investing style.
- Cutting-Edge: Uses LLMs and NLP, mirroring real hedge fund tech.
It’s like a finance lab where you’re the mad scientist. I loved seeing the Sentiment Agent catch bullish news on MSFT and adjust trades!
Final Thoughts: Become an AI Trading Pro
Congrats—you’ve launched your own AI Hedge Fund and simulated trades like a Wall Street wizard! From setting up AI agents to running trades on AAPL and MSFT, you’re now part of the AI investing revolution. Experiment with new stocks, tweak agents, or document your APIs with APIdog. Share your AI Hedge Fund tweaks on X or GitHub—I’m pumped to see your trading empire grow! Happy simulating!