Home

loadchange/ai-hedge-fund: A GitHub Repository Worth Watching

Al

Alex Chen

May 26, 202611 min read

# 🚀 AI Hedge Fund: A Multi‑Agent LLM Trading System Welcome to the future of **educational** quantitative finance! The [loadchange/ai-hedge-fund](https://github.com/loadchange/ai-hedge-fund) reposit...

🚀 AI Hedge Fund: A Multi‑Agent LLM Trading System

Welcome to the future of educational quantitative finance! The loadchange/ai-hedge-fund repository is a striking open‑source project that blends the wisdom of legendary investors with a modern quant stack—all powered by large language models. Whether you’re a curious developer, a finance enthusiast, or a researcher exploring LLM‑driven strategies, this repo offers a playground where thirteen AI “personas” (think Warren Buffett, Cathie Wood, Duan Yongping, and more) collaborate with rule‑based analysts to emit BUY / SELL / HOLD / SHORT signals for US, Hong Kong, and China A‑share markets.

💡 Key takeaway: The system is completely free to run—no paid data vendors required—thanks to integrations with yfinance, akshare, baostock, and Tencent APIs.


🏗️ Architecture Overview

At a high level, the project follows a clean, modular pipeline that you can visualize as a series of stages: data ingestion → LLM persona reasoning → quant signal generation → market‑review filter → risk & portfolio management → decision output → reporting & notifications.

   CLI · Issue bot · Daily Report (cron)
        │
   DataSourceManager  (US: yfinance→akshare · HK: tencent/yfinance/akshare
        │             · CN: baostock/akshare/tencent)
        ├──────────────────────────────┐
        ▼                              ▼
   LLM persona agents            Quant signals (BaseSignal)
   (LangGraph; Buffett /         trend · mean_reversion · momentum
   Munger / Wood / …)            volatility · stat_arb · value
        │                        quality · earnings_surprise
        │                        volume_price · pattern  ← new
        └────────────┬───────────┘
                     ▼
          Market Review (rule‑based)
          SPY · QQQ · 000300.SS · ^HSI
                     ▼
          Risk manager → Portfolio manager
          (vol / corr / drawdown caps; optional
          cvxpy MVO · risk parity · Black‑Litt.)
                     ▼
          BUY / SELL / HOLD / SHORT  (10 bps default cost)
                     ▼
          Dashboard Report → Notification (Lark/Telegram/Discord/Slack/…)
                     ▼
          Backtester · Validation (CPCV + PBO + Deflated Sharpe)

This diagram, taken straight from the README, showcases the separation of concerns: LLM agents provide narrative, qualitative insight; the quant module supplies hard, statistical edges; and the market review acts as a macro‑filter that keeps the system grounded.


🧩 Core Features

  • Thirteen LLM Personas – Each persona emulates the investment style of a famous investor (see the Agent Roster below).
  • Hybrid Decision Making – LLM reasoning + deterministic quant signals + rule‑based market review.
  • Multi‑Market Support – US equities, Hong Kong stocks, and China A‑shares (Shanghai & Shenzhen) with live‑free data feeds.
  • Bilingual Output – Reports and notifications can be generated in English or Simplified Chinese.
  • Plug‑and‑Play Notifications – Via Apprise, you can push results to Lark, Telegram, Discord, Slack, email, and more.
  • Automation‑Ready – GitHub Actions workflows for an Issue Bot and a Daily Market Report that run on schedule.
  • Full Backtest & Validation Suite – Walk‑forward backtesting, CPCV, PBO, and Deflated Sharpe ratio evaluation.
  • Zero‑Cost Data – No paid subscriptions; all data sources are open and free.

📌 Pro tip: Start with a single ticker and two analysts to keep LLM calls cheap while you explore the system’s behavior.


📊 Markets & Data Sources

The project abstracts data acquisition behind a DataSourceManager that automatically picks the best free provider for each market:

Market Primary Free Sources Fallbacks
United States yfinance akshare
Hong Kong tencent / yfinance akshare
China A‑share baostock / akshare tencent

All historical price, volume, and fundamental fields needed by the quant signals are pulled via these adapters. Because the adapters are thin wrappers, you can easily swap in a paid provider later if desired.


🤖 Agent Roster & Personas

The heart of the system is the LLM analyst crew. You can invoke any subset via the --analysts flag (or use all to run the full council).

Investor Personas (LLM‑driven)

  • warren_buffett – Value, moat‑focused
  • charlie_munger – Mental‑models, inversion
  • cathie_wood – Disruptive innovation, growth
  • duan_yongping – Pragmatic, cash‑flow oriented
  • stanley_druckenmiller – Macro‑tactical, momentum
  • aswath_damodaran – Valuation guru
  • ben_graham – Father of value investing
  • bill_ackman – Activist, concentrated bets
  • michael_burry – Contrarian, deep‑value
  • mohnish_pabrai – Dhandho investor, low‑risk high‑return
  • nassim_taleb – Antifragility, tail‑risk aware
  • peter_lynch – Growth at a reasonable price
  • phil_fisher – Scuttlebutt, qualitative growth
  • rakesh_jhunjhunwala – Indian market legend (included for breadth)

Generic Analysts (LLM‑free, signal‑based)

  • valuation_analyst – DCF, multiples
  • sentiment_analyst – News‑based sentiment
  • news_sentiment_analyst – Real‑time headline scoring
  • fundamentals_analyst – ROE, debt, margins
  • growth_analyst – Revenue/EPS trends
  • technical_analyst – Delegates to src/signals/ (pure quant)

Market Overview (Rule‑Based)

  • market_review – Evaluates SPY, QQQ, 000300.SS, ^HSI for regime filters.

Example usage:

uv run python src/main.py --tickers AAPL,MSFT \
  --model deepseek-v4-flash \
  --analysts warren_buffett,duan_yongping \
  --lang zhCN   # English: omit --lang or use enUS

The LLM extracts the analyst names from free‑text issue bodies when using the Issue Bot, making interaction natural.


⚙️ Quantitative Stack

While the LLMs provide the story, the quantitative layer supplies the numbers. All signals inherit from BaseSignal and are implemented in src/signals/.

Signal Category Examples
Trend trend, moving_average_crossover
Mean Reversion mean_reversion, bollinger_bands
Momentum momentum, rsi, macd
Volatility volatility, atr
Statistical Arbitrage stat_arb, pairs_trading
Value value, book_to_market, ev_ebitda
Quality quality, roe, debt_to_equity
Earnings Surprise earnings_surprise
Volume‑Price volume_price, vwap, obv
Pattern Recognition pattern, candlestick_patterns

These signals are combined via a simple weighted sum (configurable) before being passed to the portfolio manager. The portfolio manager can optionally run a mean‑variance optimization (cvxpy) or a risk‑parity allocation.

🔍 Insight: Because the quant signals are completely LLM‑free, you can run the backtester or validation suite without incurring any API costs—perfect for extensive research.


🚦 Quick Start Guide

Getting the AI Hedge Fund up and running takes just a few minutes. Below are the exact commands you’ll need (copied from the repository’s README).

1️⃣ Clone & Install

git clone https://github.com/loadchange/ai-hedge-fund.git
cd ai-hedge-fund
# Install uv if you don’t have it
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
# Copy the example env and fill in your LLM credentials
cp .env.example .env
# Edit .env to set at least ONE of: AI_BASE_URL, AI_API_KEY, AI_MODEL

Note: The repo uses uv for blazing‑fast Python package management, but you can also use pip or conda if you prefer.

2️⃣ Run a Single‑Day Decision

uv run python src/main.py --tickers AAPL,MSFT \
  --model deepseek-v4-flash \
  --analysts warren_buffett,duan_yongping \
  --lang zhCN   # Use English by dropping the flag or setting enUS

This will call the LLM once per analyst per ticker (plus one call for the portfolio manager) and print a concise BUY/SELL/HOLD/SHORT recommendation.

3️⃣ Backtest Over a Period

uv run python src/backtester.py --tickers AAPL \
  --model deepseek-v4-flash \
  --start-date 2025-01-01 \
  --end-date 2025-02-01 \
  --analysts warren_buffett,duan_yongping
# Optional: adjust cost model
# --cost-model {fixed,spread} --cost-bps N

⚠️ Warning: Backtester cost scales as analysts × tickers × days. For quick experiments, limit yourself to 1‑2 tickers and 2‑3 analysts over a week or two.

4️⃣ Pure‑Quant Validation (No LLM Calls)

uv run python -m src.validation.cli evaluate \
  --signal momentum,trend \
  --ticker AAPL,MSFT \
  --start 2023-01-01 \
  --end 2025-04-01 \
  --rolling-window 180

This runs CPCV (Combinatorial Purged Cross‑Validation), PBO (Probability of Backtest Overfitting), and Deflated Sharpe—all essential for robust strategy validation.


🤖 Issue Bot & Automation

One of the most delightful touches is the Issue Bot (.github/workflows/issue-bot.yml). By using a GitHub issue template, you can trigger automated analyses:

Mode Trigger Label LLM Usage Output
Ticker analysis bot-ticker Yes (per persona × ticker) Single‑day BUY/SELL/HOLD/SHORT
Backtester bot-backtester Yes (per business day) Equity curve, Sharpe, costs
Signal validation bot-validate No CPCV IS/OOS Sharpe + PBO + DSR
Event study bot-event-study No Market‑model α/β + AR/CAR + t‑stat

The bot posts a markdown comment with the results and then auto‑closes the issue. Only the repository owner can trigger LLM‑heavy modes; others receive a friendly reminder to fork and self‑deploy.

Required secrets (set in the repo’s Settings → Secrets):

  • AI_BASE_URL – Endpoint of your LLM provider (e.g., OpenAI, Azure, Ollama)
  • AI_API_KEY – Authentication token
  • AI_MODEL – Model name as listed in src/llm/api_models.json

📈 Daily Market Report

If you enjoy a morning brief, the Daily Market Report workflow is a treat. It runs on each trading day, creates a GitHub issue, runs the rule‑based market_review and technical_analyst (zero LLM cost), and pushes a notification via Apprise.

Market Trigger Time (Local) Indices Analyzed
China A‑share 15:45 Beijing 000300.SS, 000001.SS, ^HSI, SPY, QQQ
Hong Kong 16:47 Hong Kong ^HSI, 000300.SS, SPY, QQQ
US ~16:53 ET SPY, QQQ, DIA, IWM, 000300.SS, ^HSI

Required secret: NOTIFY_URLS – an Apprise URL string (e.g., lark://webhook_token or discord://<id>/<token>).

Because the report relies solely on rule‑based components, it’s free to run indefinitely—perfect for a personal dashboard or a team‑wide Slack digest.


🔬 Backtesting & Validation

The repo doesn’t stop at single‑day signals; it includes a full‑featured backtester and a validation CLI that emphasize statistical rigor.

Backtester Highlights

  • Walks through each business day in the requested range.
  • Re‑runs the entire pipeline (data → LLM agents → quant signals → market review → risk/portfolio).
  • Outputs equity curve, daily returns, Sharpe ratio, max drawdown, and transaction costs (default 10 bps).
  • Supports two cost models: fixed (constant bps) or spread (based on quoted spread).

Validation CLI Highlights

  • CPCV – Combinatorial Purged Cross‑Validation guards against look‑ahead bias.
  • PBO – Estimates the probability that a backtest’s Sharpe is due to chance.
  • Deflated Sharpe – Adjusts Sharpe for multiple testing and non‑normality.
  • All metrics are computed without invoking any LLM, making large‑scale parameter sweeps cheap.

Example output snippet:

Ticker: AAPL
Signal: momentum
CPCV IS Sharpe: 1.24
CPCV OOS Sharpe: 0.91
PBO: 0.12
Deflated Sharpe: 0.78

These numbers let you quickly assess whether a signal’s edge is robust or merely a product of overfitting.


🌐 Internationalisation & Notifications

The project embraces a global audience:

  • Language: Switch between English (enUS) and Simplified Chinese (zhCN) via the --lang flag. All LLM prompts, system messages, and report templates are localized.
  • Notification Channels: Through Apprise, you can route outputs to:
    • Lark / Feishu
    • Telegram
    • Discord
    • Slack
    • Email (SMTP)
    • Pushbullet, Gotify, Matrix, and many more.

This flexibility means you can run the AI Hedge Fund on a personal server and have it ping your phone whenever a compelling signal appears.


🏆 Verdict / Final Thoughts

The loadchange/ai-hedge-fund repository is a rare gem in the open‑source quant world. It successfully marries the narrative power of LLMs with the discipline of quantitative finance, all while remaining free to run and extremely approachable for newcomers.

What sets it apart:

  • Diverse Persona Panel – You get to “listen” to thirteen legendary investors debate each ticker.
  • Transparent, Modular Design – Swap data sources, tweak quant signals, or replace the LLM backend without touching the core logic.
  • Production‑Ready Automation – Issue Bot and Daily Report workflows turn GitHub into a live trading‑idea generator.
  • Rigorous Validation Tools – CPCV, PBO, and Deflated Sharpe ensure you’re not chasing mirages.
  • Zero‑Cost Data Pipeline – No expensive subscriptions; everything runs on public APIs.

Whether you’re looking to learn how LLMs can augment traditional analysis, prototype a new strategy, or simply enjoy watching AI personas argue about Apple’s valuation, this repo offers a polished, enjoyable, and deeply educational experience.

🚀 Ready to dive in? Clone the repo, set your LLM key, and run your first analysis today. The market never sleeps, and now neither does your AI‑powered hedge fund.

View on GitHub: loadchange/ai-hedge-fund


Disclaimer: This project is for educational and research purposes only. It does not constitute financial advice, and past performance is not indicative of future results.

Keywords

ai hedge fundmulti-agent tradingLLM agentsquantitative financeopen sourcebacktestingstock marketpython

Sources & References

  1. [1]loadchange/ai-hedge-fund

Keep reading

More related articles from DriftSeas.