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:
- Aswath Damodaran Agent - The Dean of Valuation, focuses on story, numbers, and disciplined valuation
- Ben Graham Agent - The godfather of value investing, only buys hidden gems with a margin of safety
- Bill Ackman Agent - An activist investor, takes bold positions and pushes for change
- Cathie Wood Agent - The queen of growth investing, believes in the power of innovation and disruption
- Charlie Munger Agent - Warren Buffett's partner, only buys wonderful businesses at fair prices
- Michael Burry Agent - The Big Short contrarian who hunts for deep value
- Peter Lynch Agent - Practical investor who seeks "ten-baggers" in everyday businesses
- Phil Fisher Agent - Meticulous growth investor who uses deep "scuttlebutt" research
- Rakesh Jhunjhunwala Agent - The Big Bull of India
- Stanley Druckenmiller Agent - Macro legend who hunts for asymmetric opportunities with growth potential
- Warren Buffett Agent - The oracle of Omaha, seeks wonderful companies at a fair price
- Valuation Agent - Calculates the intrinsic value of a stock and generates trading signals
- Sentiment Agent - Analyzes market sentiment and generates trading signals
- Fundamentals Agent - Analyzes fundamental data and generates trading signals
- Technicals Agent - Analyzes technical indicators and generates trading signals
- Risk Manager - Calculates risk metrics and sets position limits
- Portfolio Manager - Makes final trading decisions and generates orders
Note: the system simulates trading decisions, it does not actually trade.
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.
- π New: Real-time Portfolio Monitoring
- Indian Stock Market Integration
- Setup
- Usage
- Contributing
- Feature Requests
- License
The AI Hedge Fund is a combination of multiple AI agents that analyze market data and collaborate to make investment decisions. Each AI agent is designed to mimic the trading style and strategies of a famous investor (like Warren Buffett, Michael Burry), or a specific trading approach (like technical analysis).
This project now includes a live portfolio monitoring system that tracks your actual Zerodha account in real-time! Monitor your cash, positions, P&L, and get AI-powered insights on your portfolio.
# 1. Set up Zerodha credentials
python generate_zerodha_token.py
# 2. Test the system
python test_portfolio_monitor.py
# 3. Start the web interface
./start_portfolio_monitor.shThen open http://localhost:5173 to see your live portfolio dashboard!
Features:
- π Real-time Portfolio Tracking: Live cash, positions, and P&L updates
- π Modern Web Interface: Beautiful dashboard with live data streaming
- π Portfolio Analytics: Risk metrics, concentration analysis, and performance tracking
- π Auto-refresh: Portfolio data updates every 30 seconds automatically
- π± Responsive Design: Works on desktop and mobile
For detailed setup instructions, see PORTFOLIO_MONITOR.md.
In addition to US stocks through financialdatasets.ai, this project now supports Indian stocks via Zerodha integration. The system can fetch data from NSE (National Stock Exchange) and process it in the same format used by the AI agents.
To use the Zerodha integration for Indian stocks:
- Ensure you have a Zerodha account and API credentials
- Set the following environment variables:
export ZERODHA_API_KEY="your_api_key" export ZERODHA_ACCESS_TOKEN="your_access_token" export AI_HEDGE_FUND_DATA_SOURCE="zerodha" - Run the hedge fund with Indian stock tickers:
./run_with_zerodha.sh --tickers RELIANCE,INFY,HDFCBANK
For a backtesting run:
./run_with_zerodha.sh --tickers RELIANCE,INFY --backtest
If you don't have LLM API keys, you can use Ollama for local inference:
./run_with_zerodha.sh --tickers RELIANCE,INFY --ollama
The Zerodha integration provides:
- Historical OHLCV data via Kite Connect API
- Basic fundamental metrics via web scraping (Screener.in)
Note that some metrics available for US stocks may not be available for Indian stocks.
If you're using the Zerodha integration for Indian stocks, you'll need to install additional dependencies:
pip install -r requirements-zerodha.txtOr with Poetry:
poetry add kiteconnect beautifulsoup4 python-dateutil pandas pyarrow fastparquetThe Zerodha API requires an access token that is valid for one day. To generate a token:
- Make sure you have your Zerodha API key and secret from the Kite Connect Developer Console
- Run the token generation script:
# Using Poetry (recommended)
poetry run python generate_zerodha_token.py
# Or with API credentials as arguments
poetry run python generate_zerodha_token.py --api-key YOUR_API_KEY --api-secret YOUR_API_SECRETThe script will:
- Open a browser window for you to log in to your Zerodha account
- Ask you to paste the request token from the redirect URL
- Generate and display your access token
- Show the export commands to set the required environment variables
Clone the repository:
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund- Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 -- Install dependencies:
poetry install- Set up your environment variables:
# Create .env file for your API keys
cp .env.example .env- 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-
Make sure you have Docker installed on your system. If not, you can download it from Docker's official website.
-
Clone the repository:
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund- Set up your environment variables:
# Create .env file for your API keys
cp .env.example .env-
Edit the .env file to add your API keys as described above.
-
Navigate to the docker directory:
cd docker- Build the Docker image:
# On Linux/Mac:
./run.sh build
# On Windows:
run.bat buildImportant: 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.
poetry run python src/main.py --ticker AAPL,MSFT,NVDANote: 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 main
# On Windows:
run.bat --ticker AAPL,MSFT,NVDA mainYou can also specify a --ollama flag to run the AI hedge fund using local LLMs.
# 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 mainYou can also specify a --show-reasoning flag to print the reasoning of each agent to the console.
# 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 mainYou can optionally specify the start and end dates to make decisions for a specific time period.
# 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 mainpoetry run python src/backtester.py --ticker AAPL,MSFT,NVDANote: 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 backtestYou 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 backtestYou can also specify a --ollama flag to run the backtester using local LLMs.
# 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- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Important: Please keep your pull requests small and focused. This will make it easier to review and merge.
If you have a feature request, please open an issue and make sure it is tagged with enhancement.
This project is licensed under the MIT License - see the LICENSE file for details.

