# AI hedge fund

Deploy AI Hedge Fund on Render with one click. 19 AI agents modeled after famous investors analyze stocks and generate trading signals.

- Repository: https://github.com/render-examples/ai-hedge-fund-on-render/tree/main
- Stack: fastapi, python, postgresql, react
- Tags: full-stack, ai, ai-agent, database
- URL: https://render.com/templates/ai-hedge-fund

## Why deploy ai hedge fund on Render?

AI Hedge Fund is a simulation platform that uses multiple AI agents modeled after famous investors (Buffett, Munger, Burry, etc.) to analyze stocks and generate trading signals. It enables educational exploration of AI-driven investment strategies without placing real trades, combining a FastAPI backend, React UI, and PostgreSQL database deployable to Render with one click.

This template deploys a complete AI hedge fund stack—FastAPI backend, React frontend, and managed PostgreSQL—with all service URLs and database connections pre-wired through environment variables, so the 19 investor agents can start analyzing tickers immediately. Instead of manually provisioning three services, configuring CORS, and connecting a database, Render's Blueprint handles it in one click with `DATABASE_URL`, `VITE_API_URL`, and `FRONTEND_URL` automatically injected across services. You just supply your LLM and financial data API keys; Render handles the managed Postgres, CDN-hosted frontend, and keeps everything grouped in a single dashboard project.

## Architecture

```mermaid
flowchart LR
    classDef default fill:#1a1a2e,stroke:#a78bfa,color:#fff

    User([User])
    LLM([LLM Provider])
    FinData([Financial Data API])
    
    Frontend[ai-hedge-fund-web]
    Backend[ai-hedge-fund-api]
    DB[(ai-hedge-fund-db)]
    
    User -->|browses| Frontend
    Frontend -->|API calls| Backend
    Backend -->|queries| DB
    Backend -->|LLM requests| LLM
    Backend -->|market data| FinData
```

## What you can build

After deploying, you'll have a web app where you can input stock tickers and get AI-generated trading signals from 19 agents modeled after well-known investors like Buffett, Munger, and Burry. Each agent analyzes your chosen stocks and contributes to a final portfolio recommendation, with all runs persisted to a Postgres database. This is a simulation tool for exploring AI-driven investment analysis—it doesn't execute real trades.

## Key features

- *Multi-agent investor simulation*: Runs ~19 specialized AI agents modeled after famous investors (Buffett, Munger, Burry, etc.) that analyze tickers and produce trading signals with a final portfolio decision.
- *One-click Blueprint deployment*: A single render.yaml provisions FastAPI backend, React frontend, and managed PostgreSQL with all service URLs and DATABASE_URL auto-wired between components.
- *Multi-LLM provider support*: Supports OpenAI, Anthropic, Groq, Google Gemini, DeepSeek, OpenRouter, xAI, Kimi, and GigaChat with automatic model filtering based on configured API keys.
- *Auto-wired CORS configuration*: FRONTEND_URL is automatically injected from the static site's URL, locking down the backend to allow only that origin plus localhost for development.
- *Financial data integration*: Connects to Financial Datasets API for real market data (stock prices and fundamentals) to feed the AI agents' analysis.

## Use cases

- Finance student simulates multi-agent trading strategies for a class project
- Developer explores LLM orchestration by deploying famous-investor AI agents
- Hobbyist backtests portfolio ideas using AI-generated trading signals
- Startup founder demos AI investment analysis to potential investors

## What's included

| Service | Type | Purpose |
|---------|------|---------|
| ai-hedge-fund-api | Web Service | Handles API requests and business logic |
| ai-hedge-fund-web | Web Service | Application service |
| unnamed | rewrite | Application service |
| ai-hedge-fund-db | PostgreSQL | Primary database |

## Prerequisites

- *[LLM API Key](https://platform.openai.com/api-keys)*: Your API key for the AI language model provider (OpenAI, Anthropic, Groq, Google Gemini, or DeepSeek) that powers the hedge fund agents.
- *LLM Provider*: The name of your LLM provider (e.g., OpenAI, Anthropic, Groq, Google, DeepSeek); leave blank if using OpenAI.
- *[Financial Datasets API Key](https://financialdatasets.ai/)*: Your API key for Financial Datasets to fetch real market data including stock prices and fundamentals.

## Next steps

1. Open the ai-hedge-fund-web URL and run an analysis with 2-3 tickers (e.g., AAPL, MSFT) — You should see each investor agent (Buffett, Munger, etc.) return trading signals and a final portfolio recommendation within 30-60 seconds
2. Test the backtester by selecting a completed run and clicking backtest — You should see historical performance metrics and a chart showing how the AI signals would have performed
3. Configure a different LLM provider in the ai-hedge-fund-api Environment tab and re-run the same tickers — You should see the model picker reflect the new provider and results may vary based on the different AI model
