Skip to main content

An AI-powered hedge fund that uses multiple agents to make trading decisions

Project description

AI Hedge Fund

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. Ben Graham Agent - The godfather of value investing, only buys hidden gems with a margin of safety
  2. Bill Ackman Agent - An activist investors, takes bold positions and pushes for change
  3. Cathie Wood Agent - The queen of growth investing, believes in the power of innovation and disruption
  4. Warren Buffett Agent - The oracle of Omaha, seeks wonderful companies at a fair price
  5. Charlie Munger Agent - Warren Buffett's partner, only buys wonderful businesses at fair prices
  6. Valuation Agent - Calculates the intrinsic value of a stock and generates trading signals
  7. Sentiment Agent - Analyzes market sentiment and generates trading signals
  8. Fundamentals Agent - Analyzes fundamental data and generates trading signals
  9. Technicals Agent - Analyzes technical indicators and generates trading signals
  10. Risk Manager - Calculates risk metrics and sets position limits
  11. Portfolio Manager - Makes final trading decisions and generates orders
Screenshot 2025-02-09 at 11 26 14 AM

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

Twitter Follow

Disclaimer

This project is for educational and research purposes only.

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

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

Table of Contents

Setup

Clone the repository:

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

Important: You must set OPENAI_API_KEY, GROQ_API_KEY, or ANTHROPIC_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

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

Example Output: Screenshot 2025-01-06 at 5 50 17 PM

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

poetry run python src/main.py --ticker AAPL,MSFT,NVDA --show-reasoning

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

poetry run python src/main.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 

Running the Backtester

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

Example Output: Screenshot 2025-01-06 at 5 47 52 PM

You can optionally specify the start and end dates to backtest over a specific time period.

poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01

Project Structure

ai-hedge-fund/
├── src/
│   ├── agents/                   # Agent definitions and workflow
│   │   ├── bill_ackman.py        # Bill Ackman agent
│   │   ├── fundamentals.py       # Fundamental analysis agent
│   │   ├── portfolio_manager.py  # Portfolio management agent
│   │   ├── risk_manager.py       # Risk management agent
│   │   ├── sentiment.py          # Sentiment analysis agent
│   │   ├── technicals.py         # Technical analysis agent
│   │   ├── valuation.py          # Valuation analysis agent
│   │   ├── warren_buffett.py     # Warren Buffett agent
│   ├── tools/                    # Agent tools
│   │   ├── api.py                # API tools
│   ├── backtester.py             # Backtesting tools
│   ├── main.py # Main entry point
├── pyproject.toml
├── ...

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Important: Please keep your pull requests small and focused. This will make it easier to review and merge.

Feature Requests

If you have a feature request, please open an issue and make sure it is tagged with enhancement.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_rich-0.1.5.tar.gz (54.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_rich-0.1.5-py3-none-any.whl (67.1 kB view details)

Uploaded Python 3

File details

Details for the file ai_rich-0.1.5.tar.gz.

File metadata

  • Download URL: ai_rich-0.1.5.tar.gz
  • Upload date:
  • Size: 54.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.8.0-49-generic

File hashes

Hashes for ai_rich-0.1.5.tar.gz
Algorithm Hash digest
SHA256 4139da9ac3e072478b1cf86ad4af5a74a899623825b80cc9fc1d261102458f96
MD5 02eea7eab76ed54241a6220cdec9bf99
BLAKE2b-256 48902ab660468a7ae9f8ae5a2a61e2d4af1b017231369e3cae66b7d25ff229a4

See more details on using hashes here.

File details

Details for the file ai_rich-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: ai_rich-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 67.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.8.0-49-generic

File hashes

Hashes for ai_rich-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 53716ffad280cef8d87fa08242e79e0f3cd1127c30e0aabd2ec44b8e13407a04
MD5 2ca04f7e1ff7da1ee6feb9d476f81be2
BLAKE2b-256 6acfb15af66247c992ba21fd46dc1fe7b0e32030c54b67a7d19fc2e7f5ddc8f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page