Back to Ai Hedge Fund

Web Application

app/README.md

latest5.9 KB
Original Source

Web Application

The AI Hedge Fund app is a complete system with both frontend and backend components that enables you to run an AI-powered hedge fund trading system through a web interface on your own computer.

Overview

The AI Hedge Fund consists of:

  • Backend: A FastAPI application that provides a REST API to run the hedge fund trading system and backtester
  • Frontend: A React/Vite application that offers a user-friendly interface to visualize and control the hedge fund operations

Table of Contents

🚀 Quick Start (For Non-Technical Users)

One-line setup and run command:

For Mac/Linux:

bash
./run.sh

If you get a "permission denied" error, run this first:

bash
chmod +x run.sh && ./run.sh

Or alternatively, you can run:

bash
bash run.sh

For Windows:

cmd
run.bat

Option 2: Using npm (Alternative)

bash
cd app && npm install && npm run setup

That's it! These scripts will:

  1. Check for required dependencies (Node.js, Python, Poetry)
  2. Install all dependencies automatically
  3. Start both frontend and backend services
  4. Automatically open your web browser to the application

Requirements:

After running, you can access:


🛠️ Manual Setup (For Developers)

If you prefer to set up each component manually or need more control:

Prerequisites

  • Node.js and npm for the frontend
  • Python 3.8+ and Poetry for the backend

Installation

  1. Clone the repository:
bash
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund
  1. Set up your environment variables:
bash
# Create .env file for your API keys (in the root directory)
cp .env.example .env
  1. Edit the .env file to add your API keys:
bash
# For running LLMs hosted by openai (gpt-4o, gpt-4o-mini, etc.)
OPENAI_API_KEY=your-openai-api-key

# For running LLMs hosted by groq (deepseek, llama3, etc.)
GROQ_API_KEY=your-groq-api-key

# For getting financial data to power the hedge fund
FINANCIAL_DATASETS_API_KEY=your-financial-datasets-api-key
  1. Install Poetry (if not already installed):
bash
curl -sSL https://install.python-poetry.org | python3 -
  1. Install root project dependencies:
bash
# From the root directory
poetry install
  1. Install backend app dependencies:
bash
# Navigate to the backend directory
cd app/backend
pip install -r requirements.txt  # If there's a requirements.txt file
# OR
poetry install  # If there's a pyproject.toml in the backend directory
  1. Install frontend app dependencies:
bash
cd app/frontend
npm install  # or pnpm install or yarn install

Running the Application

  1. Start the backend server:
bash
# In one terminal, from the backend directory
cd app/backend
poetry run uvicorn main:app --reload
  1. Start the frontend application:
bash
# In another terminal, from the frontend directory
cd app/frontend
npm run dev

You can now access:

Detailed Documentation

For more detailed information:

Disclaimer

This project is for educational and research purposes only.

  • Not intended for real trading or investment
  • No warranties or guarantees provided
  • 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.

Troubleshooting

Common Issues

"Command not found: uvicorn" Error

If you see this error when running the setup script:

bash
[ERROR] Backend failed to start. Check the logs:
Command not found: uvicorn

Solution:

  1. Clean Poetry environment:

    bash
    cd app/backend
    poetry env remove --all
    poetry install
    
  2. Or force reinstall:

    bash
    cd app/backend
    poetry install --sync
    
  3. Verify installation:

    bash
    cd app/backend
    poetry run python -c "import uvicorn; import fastapi"
    

Python Version Issues

  • Use Python 3.11: Python 3.13+ may have compatibility issues
  • Check your Python version: python --version
  • Switch Python versions if needed (using pyenv, conda, etc.)

Environment Variable Issues

  • Ensure .env file exists in the project root directory
  • Copy from template: cp .env.example .env
  • Add your API keys to the .env file

Permission Issues (Mac/Linux)

If you get "permission denied":

bash
chmod +x run.sh
./run.sh

Port Already in Use

If ports 8000 or 5173 are in use:

  • Kill existing processes: pkill -f "uvicorn\|vite"
  • Or use different ports by modifying the scripts

Getting Help