In this tutorial, we explain how to install and run locally the AI Hedge Fund model. This is an experimental model for making stock trading decisions. You can integrate various Large Language Models (LLMs) in this AI model, such as Llama 3.3, DeepSeek-R1, ChatGPT, etc. The YouTube tutorial explaining the installation instructions is given below.
Installation Instructions for AI Hedge Fund
If you are on a Windows computer, you need to install WSL. To do that, open a Windows PowerShell in the administrator mode, and type
wsl --install
This will install WSL and the default Linux Ubuntu distribution. Then, you will need to restart the computer. After you restart the computer, open a terminal, update, upgrade, and install Curl and Git:
sudo apt update && sudo apt upgrade
sudo apt install curl
sudo apt install git-all
Then, you need to install AI Hedge Fund. To do that, type
cd ~
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund
curl -sSL https://install.python-poetry.org | python3 -
export PATH="/home/ahaber/.local/bin:$PATH"
poetry install
After that you need to set the API keys in the .env file. First create .env file from the template
cp .env.example .env
Then, type
sudo nano .env
and edit the API keys
# 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 running LLMs hosted by anthropic (claude-3-5-sonnet, claude-3-opus, claude-3-5-haiku)
# Get your Anthropic API key from https://anthropic.com/
ANTHROPIC_API_KEY=your-anthropic-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
You can easily obtained them by registering and account at OpenAI, Groq, or Anthropic websites Finally, you need to have an account with Financial Datasets. You just need to set one API for an LLM provider, and one API at Financial Datasets. After you do that, you can run the test by typing:
poetry run python src/main.py --ticker AAPL,MSFT,NVDA

You need to select at least one agent with SPACE, and then you need to select an LLM


Some of the results are given below.


You can also back test this trading algorithms by running the following command:
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA
You can also specify the dates for back testing the AI Hedge Fund model:
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01