Skip to content

WubzC/ai-value-fund

 
 

Repository files navigation

Great! I’ll update the README to refocus the project on identifying undervalued stocks using agents that analyze news, financial data, and expert-investor logic. I’ll preserve the structure and formatting, and suggest enhancements that align with the new investment strategy. I’ll share the revised README shortly.

AI Hedge Fund

This is a proof of concept for an AI-powered hedge fund platform focused on discovering undervalued stocks. The system uses autonomous AI agents to scan recent news articles, earnings reports, and financial data for companies that might be trading below their intrinsic value. Once a potential undervalued opportunity is identified, specialized investor logic agents—modeled after legendary investors like Warren Buffett, Ben Graham, and others—evaluate whether the opportunity meets strict value-investing criteria and is worth pursuing. This project is for educational and research purposes only and is not intended for real trading or investment.

This system employs several agents working together to identify and evaluate undervalued stock opportunities:

  1. Aswath Damodaran AgentThe Dean of Valuation. Focuses on a company's story and numbers to perform disciplined valuation, helping determine if the current market price is below the stock’s intrinsic value.
  2. Ben Graham AgentThe godfather of value investing. Scours the market for hidden gem stocks trading far below their intrinsic value, insisting on a significant margin of safety before considering any investment.
  3. Bill Ackman AgentAn activist investor. Looks for undervalued companies where strategic changes (or activist intervention) could unlock greater value. Willing to take bold positions if a company’s potential value substantially exceeds its current price.
  4. Cathie Wood AgentThe queen of growth investing. Identifies innovative or disruptive companies that may be undervalued by traditional metrics. Focuses on high-growth potential that is not yet fully reflected in the stock’s price.
  5. Charlie Munger AgentWarren Buffett’s partner. Prioritizes high-quality businesses and only invests when these companies are available at fair or undervalued prices relative to their true long-term worth.
  6. Michael Burry AgentThe contrarian ("Big Short") investor. Hunts for deeply undervalued or overlooked stocks that others are pessimistic about, capitalizing on significant mispricings or negative sentiment in the market.
  7. Peter Lynch AgentThe ten-bagger seeker. Searches for strong, everyday businesses that are currently underappreciated (or undervalued) by the market but have the potential to become "ten-baggers" (grow tenfold).
  8. Phil Fisher AgentThe meticulous growth researcher. Uses deep "scuttlebutt" research (extensive qualitative investigation) to find high-growth companies that may be undervalued due to lack of widespread awareness, ensuring thorough understanding before investing.
  9. Stanley Druckenmiller AgentThe macro growth legend. Hunts for asymmetric opportunities often driven by macroeconomic or industry trends, identifying cases where a company’s growth potential or macro tailwinds are undervalued by the market.
  10. Warren Buffett AgentThe Oracle of Omaha. Focuses on fundamentally strong "wonderful companies" and waits until they trade at prices below their intrinsic value (a fair or bargain price) before investing, exemplifying classic value investing principles.
  11. Valuation Agent – Calculates the intrinsic value of stocks using financial models. Flags potential undervalued opportunities by comparing intrinsic value estimates to current market prices, and generates trading signals when a stock appears underpriced.
  12. Sentiment Agent – Analyzes market sentiment by scanning news, social media, and other sentiment data. Identifies cases where sentiment-driven swings might have left a quality stock undervalued (or overhyped), and generates signals based on these insights.
  13. Fundamentals Agent – Examines companies’ fundamental data (financial statements, earnings, growth metrics, etc.). Highlights stocks with strong fundamentals that are not fully reflected in the share price, indicating possible undervaluation, and generates trading signals accordingly.
  14. Technicals Agent – Analyzes technical indicators and price patterns. While focused on market trends, this agent can spot oversold conditions or other technical signals that suggest a stock might be undervalued in the short term, generating signals for potential rebound opportunities.
  15. Risk Manager – Calculates risk metrics and ensures that any position (even in an undervalued stock) stays within acceptable risk limits. Sets position sizing and diversification rules to manage exposure and protect the portfolio.
  16. Portfolio Manager – Makes final portfolio decisions by synthesizing all agents’ inputs. Determines whether to invest in the identified undervalued opportunities and in what allocation, then generates the corresponding (simulated) trade orders.

Note: The system only simulates trading decisions; it does not execute actual trades or place real orders.

Disclaimer

  • 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.

Table of Contents

  • Setup

    • Using Poetry
    • Using Docker
  • Usage

    • Running the Hedge Fund
    • Running the Backtester
  • Project Structure

  • Contributing

  • Feature Requests

  • License

Setup

Using Poetry

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 -
    
  2. Install dependencies:

    poetry install
    
  3. Set up your environment variables:

    # Create .env file for your API keys  
    cp .env.example .env
    
  4. Set your API keys:

    # For running LLMs hosted by OpenAI (gpt-4, gpt-4-32k, 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, etc.)  
    # Get your Groq API key from https://groq.com/  
    GROQ_API_KEY=<your-groq-api-key>
    
    # For obtaining financial data for 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. Install Docker: Make sure you have Docker installed on your system. If not, you can download it from the Docker official website.

  2. Clone the repository:

    git clone https://github.com/virattt/ai-hedge-fund.git  
    cd ai-hedge-fund
    
  3. Set up environment variables:

    # Create .env file for your API keys  
    cp .env.example .env
    

    Edit the newly created .env file to add your API keys as described above.

  4. Build the Docker image:

    # On Linux/Mac:  
    ./run.sh build
    
    # On Windows:  
    run.bat build
    

Important: You must set at least one of OPENAI_API_KEY, GROQ_API_KEY, ANTHROPIC_API_KEY, or DEEPSEEK_API_KEY for the hedge fund agents to run. (If you want to use models from all supported providers, you will need to set all the relevant API keys.)

Financial data for AAPL, GOOGL, MSFT, NVDA, and TSLA is free to use and does not require an API key. For any other ticker symbols, you will need to set the FINANCIAL_DATASETS_API_KEY in the .env file to access those companies’ data.

Usage

Running the Hedge Fund

With Poetry

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

With Docker

# On Linux/Mac:  
./run.sh --ticker AAPL,MSFT,NVDA main

# On Windows:  
run.bat --ticker AAPL,MSFT,NVDA main

You can also specify an --ollama flag to run the AI hedge fund using local LLMs (via Ollama) instead of cloud APIs:

# With Poetry:  
poetry run python src/main.py --ticker AAPL,MSFT,NVDA --ollama

# With Docker (on Linux/Mac):  
./run.sh --ticker AAPL,MSFT,NVDA --ollama main

# With Docker (on Windows):  
run.bat --ticker AAPL,MSFT,NVDA --ollama main

You can also specify a --show-reasoning flag to print the reasoning and analysis from each agent to the console (useful for debugging or educational insight):

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

# With Docker (on Linux/Mac):  
./run.sh --ticker AAPL,MSFT,NVDA --show-reasoning main

# With Docker (on Windows):  
run.bat --ticker AAPL,MSFT,NVDA --show-reasoning main

By default, the system uses the most recent available data. You can optionally specify start and end dates to simulate decisions over a specific historical period:

# With Poetry (example: Jan 1, 2024 to Mar 1, 2024):  
poetry run python src/main.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 main

# With Docker (on Windows):  
run.bat --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 main

Running the Backtester

The backtester evaluates the performance of the hedge fund agents over past data.

With Poetry

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

With Docker

# On Linux/Mac:  
./run.sh --ticker AAPL,MSFT,NVDA backtest

# On Windows:  
run.bat --ticker AAPL,MSFT,NVDA backtest

Similar to the live run, you can specify a date range to backtest over a specific period:

# With Poetry (example: Jan 1, 2024 to Mar 1, 2024):  
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

Project Structure

ai-hedge-fund/  
├── src/  
│   ├── agents/                   # Agent definitions and workflows  
│   │   ├── bill_ackman.py        # Bill Ackman agent logic  
│   │   ├── fundamentals.py       # Fundamental analysis agent logic  
│   │   ├── portfolio_manager.py  # Portfolio management agent logic  
│   │   ├── risk_manager.py       # Risk management agent logic  
│   │   ├── sentiment.py          # Sentiment analysis agent logic  
│   │   ├── technicals.py         # Technical analysis agent logic  
│   │   ├── valuation.py          # Valuation analysis agent logic  
│   │   ├── ...                   # Other agents (investor logic agents)  
│   │   ├── warren_buffett.py     # Warren Buffett agent logic  
│   │   ├── aswath_damodaran.py   # Aswath Damodaran agent logic  
│   │   ├── ...                   # Other agents  
│   ├── tools/                    # Tools (e.g. data/API interfaces)  
│   │   ├── api.py                # Example tool for API access  
│   ├── backtester.py             # Backtesting module  
│   ├── main.py                   # Main entry point for running the hedge fund  
├── pyproject.toml  
├── ... (other project files)

Contributing

  1. Fork this repository (click the "Fork" button at the top right of the GitHub page).
  2. Create a feature branch for your changes (git checkout -b my-feature).
  3. Commit your changes with clear and descriptive messages.
  4. Push to your branch on your forked repository.
  5. Create a Pull Request on the main repository, describing your changes and why they should be merged.

Important: Please keep pull requests small and focused. This makes them easier to review and merge more quickly.

Feature Requests

If you have an idea for a new feature or enhancement, please open an issue and tag it with the enhancement label. We welcome contributions and feedback from the community.

For example, potential future enhancements could include:

  • News ingestion pipelines: Automatically gathering and processing relevant news articles (and possibly social media feeds) to feed the Sentiment Agent, enabling earlier detection of undervalued opportunities based on news flow.
  • Earnings transcript summarization: Using AI to summarize quarterly earnings calls and SEC filings for target companies, pulling out key insights that might indicate a company is undervalued or facing issues.
  • Real-time valuation alerts: Continuously monitoring market prices versus the agents’ calculated intrinsic values, and alerting when a stock’s market price drops significantly below its estimated fair value.
  • Anomalous insider activity detection: Monitoring insider trading reports for unusual patterns (e.g. significant insider buying) that could signal insiders believe the stock is undervalued (or significant insider selling that warrants caution).
  • Buffett-style scorecard system: Implementing a checklist or scoring system inspired by Warren Buffett’s investment criteria (quality of business, moat, management, financial health, etc.), to rate companies and highlight high-quality stocks that are trading at value prices.

License

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

About

An AI Value Investing Team

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 71.9%
  • TypeScript 23.3%
  • Batchfile 1.8%
  • Shell 1.7%
  • CSS 1.0%
  • JavaScript 0.1%
  • Other 0.2%