AI Hedge Fund - An AI Hedge Fund Team

AI Hedge Fund

An AI Hedge Fund Team

This is a proof of concept for an AI-powered hedge fund. The goal of this project is to explore the use of AI to make trading decisions. This project is for educational purposes only and is not intended for real trading or investment.

This system employs several agents working together:

  1. Aswath Damodaran Agent - The Dean of Valuation, focuses on story, numbers, and disciplined valuation
  2. Ben Graham Agent - The godfather of value investing, only buys hidden gems with a margin of safety
  3. Bill Ackman Agent - An activist investor, takes bold positions and pushes for change
  4. Cathie Wood Agent - The queen of growth investing, believes in the power of innovation and disruption
  5. Charlie Munger Agent - Warren Buffett’s partner, only buys wonderful businesses at fair prices
  6. Michael Burry Agent - The Big Short contrarian who hunts for deep value
  7. Peter Lynch Agent - Practical investor who seeks “ten-baggers” in everyday businesses
  8. Phil Fisher Agent - Meticulous growth investor who uses deep “scuttlebutt” research
  9. Rakesh Jhunjhunwala Agent - The Big Bull of India
  10. Stanley Druckenmiller Agent - Macro legend who hunts for asymmetric opportunities with growth potential
  11. Warren Buffett Agent - The oracle of Omaha, seeks wonderful companies at a fair price
  12. Valuation Agent - Calculates the intrinsic value of a stock and generates trading signals
  13. Sentiment Agent - Analyzes market sentiment and generates trading signals
  14. Fundamentals Agent - Analyzes fundamental data and generates trading signals
  15. Technicals Agent - Analyzes technical indicators and generates trading signals
  16. Risk Manager - Calculates risk metrics and sets position limits
  17. Portfolio Manager - Makes final trading decisions and generates orders

Screenshot

Note: the system simulates trading decisions, it does not actually trade.

Disclaimer

This project is for educational and research purposes only.

  • Not intended for real trading or investment
  • No investment advice or guarantees provided
  • Creator assumes no liability for financial losses
  • Consult a financial advisor for investment decisions
  • Past performance does not indicate future results

By using this software, you agree to use it solely for learning purposes.

Setup

Using Poetry

Clone the repository:

Terminal window
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund
  1. Install Poetry (if not already installed):
Terminal window
curl -sSL https://install.python-poetry.org | python3 -
  1. Install dependencies:
Terminal window
poetry install
  1. Set up your environment variables:
Terminal window
# Create .env file for your API keys
cp .env.example .env
  1. Set your API keys:
Terminal window
# 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

Using Docker

  1. Make sure you have Docker installed on your system. If not, you can download it from Docker’s official website.
  2. Clone the repository:
Terminal window
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund
  1. Set up your environment variables:
Terminal window
# Create .env file for your API keys
cp .env.example .env
  1. Edit the .env file to add your API keys as described above.
  2. Navigate to the docker directory:
Terminal window
cd docker
  1. Build the Docker image:
Terminal window
# On Linux/Mac:
./run.sh build
# On Windows:
run.bat build

Important: You must set OPENAI_API_KEY, GROQ_API_KEY, ANTHROPIC_API_KEY, or DEEPSEEK_API_KEY for the hedge fund to work. If you want to use LLMs from all providers, you will need to set all API keys.

Financial data for AAPL, GOOGL, MSFT, NVDA, and TSLA is free and does not require an API key.

For any other ticker, you will need to set the FINANCIAL_DATASETS_API_KEY in the .env file.

Usage

Running the Hedge Fund

With Poetry

Terminal window
poetry run python src/main.py --ticker AAPL,MSFT,NVDA

With Docker

Note: All Docker commands must be run from the docker/ directory.

Terminal window
# Navigate to the docker directory first
cd docker
# On Linux/Mac:
./run.sh --ticker AAPL,MSFT,NVDA main
# On Windows:
run.bat --ticker AAPL,MSFT,NVDA main

Example Output:

Screenshot

You can also specify a --ollama flag to run the AI hedge fund using local LLMs.

Terminal window
# With Poetry:
poetry run python src/main.py --ticker AAPL,MSFT,NVDA --ollama
# With Docker (from docker/ directory):
# On Linux/Mac:
./run.sh --ticker AAPL,MSFT,NVDA --ollama main
# On Windows:
run.bat --ticker AAPL,MSFT,NVDA --ollama main

You can also specify a --show-reasoning flag to print the reasoning of each agent to the console.

Terminal window
# With Poetry:
poetry run python src/main.py --ticker AAPL,MSFT,NVDA --show-reasoning
# With Docker (from docker/ directory):
# On Linux/Mac:
./run.sh --ticker AAPL,MSFT,NVDA --show-reasoning main
# On Windows:
run.bat --ticker AAPL,MSFT,NVDA --show-reasoning main

You can optionally specify the start and end dates to make decisions for a specific time period.

Terminal window
# With Poetry:
poetry run python src/main.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01
# With Docker (from docker/ directory):
# On Linux/Mac:
./run.sh --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 main
# On Windows:
run.bat --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 main

Running the Backtester

With Poetry

Terminal window
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA

With Docker

Note: All Docker commands must be run from the docker/ directory.

# Navigate to the docker directory first
cd docker
# On Linux/Mac:
./run.sh --ticker AAPL,MSFT,NVDA backtest
# On Windows:
run.bat --ticker AAPL,MSFT,NVDA backtest

Example Output:

Screenshot

You can optionally 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 (from docker/ directory):
# On Linux/Mac:
./run.sh --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 backtest
# On Windows:
run.bat --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 backtest

You can also specify a --ollama flag to run the backtester using local LLMs.

Terminal window
# With Poetry:
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA --ollama
# With Docker (from docker/ directory):
# On Linux/Mac:
./run.sh --ticker AAPL,MSFT,NVDA --ollama backtest
# On Windows:
run.bat --ticker AAPL,MSFT,NVDA --ollama backtest

← Back to projects