DEV Community

Cover image for Open Source Project of the Day (#123): Vibe-Trading — Quantitative Research in Natural Language, an AI-Powered Personal Trading Agent
WonderLab
WonderLab

Posted on

Open Source Project of the Day (#123): Vibe-Trading — Quantitative Research in Natural Language, an AI-Powered Personal Trading Agent

Introduction

"Turn natural language finance questions into runnable analysis, backtests, and trading workflows."

This is article #123 in the Open Source Project of the Day series. Today's project is Vibe-Trading — an AI-driven quantitative trading research framework from HKUDS (Hong Kong University Data Science Lab).

Quantitative research has a high traditional barrier: you need to know which data API to use, how to handle missing data, which backtesting framework to choose, how to write strategy code, how to do statistical validation. Any of these steps can block progress.

Vibe-Trading's starting premise: describe in natural language what you want to research, and let the AI agent handle the technical details underneath. "Backtest a BTC-USDT 20/50 MA strategy" — one sentence, and the agent automatically selects a data source, fetches data, writes the strategy, runs the backtest, and generates a report.

This isn't a promise to make you money. It's a research tool, and its own security design makes that clear: read-only defaults, no fund custody, all live trading relays through broker interfaces.

What You'll Learn

  • Natural language → executable strategy workflow: Plan/Ground/Execute/Validate/Deliver
  • 19 free data sources and intelligent fallback chain design
  • 461 pre-built alpha factors (Alpha Zoo)
  • Shadow account: analyzing your own trading behavior from historical trade records
  • Multi-agent investment committee mode
  • Security design: AST sandbox, no fund custody principle

Prerequisites

  • Basic understanding of quantitative trading concepts (strategy, backtest, alpha factor)
  • Python basics
  • Trading experience in A-shares, US stocks, or crypto helps contextualize use cases

Project Background

What Is Vibe-Trading?

Vibe-Trading is an open-source quantitative research workbench that uses AI agents to translate natural language research intent into executable analysis code and backtesting workflows.

Its positioning is not "AI that trades for you" but "lowering the technical barrier to quantitative research" — making professional quant tools accessible without requiring software engineering as a prerequisite.

Author / Team

  • Lab: HKUDS (Hong Kong University Data Science Lab)
  • License: MIT
  • Language: Python 3.11+

Project Stats

  • ⭐ GitHub Stars: 21,800+
  • 🍴 Forks: 3,800+
  • 🛠 Agent tools: 68
  • 📊 Alpha factors: 461
  • 📡 Data sources: 19 free + 63+ premium
  • 📄 License: MIT

Five-Stage Workflow

Plan

The agent parses the natural language query and decides:

  • Which skills to invoke
  • Which tools to call
  • Which data sources to connect
  • Whether to activate multi-agent collaboration

Ground

Market data fetched via fallback chains:

A-shares (ordered by ascending IP-ban risk):

tencent → mootdx → eastmoney → baostock → akshare → tushare
Enter fullscreen mode Exit fullscreen mode

US equities:

yahoo → stooq → sina → yfinance → finnhub → alphavantage
Enter fullscreen mode Exit fullscreen mode

Crypto:

okx → ccxt → yfinance
Enter fullscreen mode Exit fullscreen mode

One get_market_data call — upper-layer code doesn't need to know which source is used; the data layer handles fallbacks transparently.

Execute

The agent generates strategy code and runs backtest engines inside an AST sandbox. Supported engines:

Market Engine
A-shares China A-Share Engine
US equities US Equity Engine
HK equities HK Equity Engine
India India NSE/BSE Engine
Crypto Crypto Engine
China futures China Futures Engine
Global futures Global Futures Engine
Forex Forex Engine
Options Options Engine
Mixed portfolio CompositeEngine

Validate

Statistical validation methods:

  • Monte Carlo simulation
  • Bootstrap confidence intervals
  • Walk-Forward testing
  • Strategy run cards

Deliver

Output formats:

  • HTML / PDF reports
  • Pine Script (TradingView)
  • TDX (China-specific trading software)
  • MetaTrader 5 MQL5

Core Features

Self-Improving Agent

The agent's memory and skill system:

  • Cross-session persistent memory: Previously researched strategies, discovered patterns, and stated hypotheses are preserved
  • 87 skills across 9 categories: Quantitative research, factor analysis, risk management, portfolio optimization, and more
  • 5-layer context compression: Handles context expansion in long research sessions
  • Automatic skill evolution: Summarizes new skills during research, expanding the capability library

Alpha Zoo (Factor Library)

461 pre-built quantitative factors, benchmarkable in one command:

# Benchmark top 20 factors from GTJA191, CSI300 universe, 2018-2025
vibe-trading alpha bench \
  --zoo gtja191 \
  --universe csi300 \
  --period 2018-2025 \
  --top 20
Enter fullscreen mode Exit fullscreen mode

Output: IC mean, IC standard deviation, IR, and IC-positive ratio per factor.

Supported factor libraries:

  • Qlib158: Classic factor set from Microsoft's open-source quant library
  • Kakushadze101: The classic 101 alpha factors from academic literature
  • GTJA191: Guotai Junan's 191 quantitative factors
  • PIT-safe fundamental factors: Fundamental data factors designed to avoid Point-in-Time bias

Shadow Account

One of Vibe-Trading's most interesting features: upload your historical trade records and let AI analyze your behavioral patterns.

# Upload broker export
vibe-trading --upload trades_export.csv

# Analyze trading behavior
vibe-trading run -p "Analyze my trade history, identify behavioral biases, extract my actual trading strategy"
Enter fullscreen mode Exit fullscreen mode

Diagnosed bias types:

  • Disposition Effect: Selling winners too early, holding losers too long
  • Overtrading: High frequency with no corresponding alpha
  • Momentum Chasing: Buying after run-ups, selling after drawdowns
  • Anchoring Bias: Over-relying on specific price reference points

Output:

  • Quantified bias magnitude report
  • Extracted "shadow strategy" (your actual behavioral pattern)
  • Comparison against backtest baseline
  • HTML/PDF audit report

Multi-Agent Investment Committees

For complex research tasks, multiple agents can run in parallel:

Mode Composition
Investment committee Analyst, risk officer, portfolio manager in parallel
Quant desk Factor research, strategy development, backtest validation in division of labor
Crypto team On-chain analysis, DEX liquidity, macro hedging
Risk committee Multi-dimensional risk assessment and stress testing

Agents work in parallel with streamed progress output, results consolidated into a comprehensive final report.


Quick Start

Install:

pip install vibe-trading-ai

# All 16 IM channel adapters (Telegram, Slack, Discord, WeChat, Feishu, etc.)
pip install "vibe-trading-ai[channels]"

# Telegram only
pip install "vibe-trading-ai[telegram]"
Enter fullscreen mode Exit fullscreen mode

Basic usage:

# Strategy research and backtest
vibe-trading run -p "Backtest a BTC-USDT 20/50 MA crossover strategy for 2024"

# Macro analysis
vibe-trading run -p "Analyze current US tech stock valuations compared to 2000 dot-com levels"

# Factor research
vibe-trading run -p "Test momentum factor effectiveness in A-shares, 2015-2025"

# Shadow account analysis
vibe-trading --upload broker_export.csv
vibe-trading run -p "Identify my behavioral biases from the last 2 years of trading"
Enter fullscreen mode Exit fullscreen mode

Python API:

from vibe_trading import Agent

agent = Agent(provider="anthropic", model="claude-opus-4-6")

result = await agent.run(
    "Analyze CSI300 monthly momentum effect, backtest 2015-2025, "
    "output annualized return, Sharpe ratio, and maximum drawdown"
)
Enter fullscreen mode Exit fullscreen mode

Docker:

docker compose up -d
# WebUI: http://localhost:3000
Enter fullscreen mode Exit fullscreen mode

Broker Connections

Live and paper trading via 10 broker integrations:

Market Brokers
US equities Robinhood, Alpaca, Interactive Brokers
A-shares / HK Futu, Longbridge, Tiger Brokers
Crypto OKX, Binance
India Dhan, Shoonya

Critical safety design:

  • No fund custody — system only relays trade intent, brokers execute
  • Brokers without structural paper/live separation capped at read-only
  • Filesystem-level kill switch for emergency stop
  • Complete operation audit ledger

Security Design

Vibe-Trading has done substantial security work — necessary for any system that executes AI-generated code:

AST Sandbox: Backtest code runs inside a hardened AST sandbox:

Blocked at compile time:
  × network calls (no external network access)
  × subprocess (no spawning subprocesses)
  × eval/exec (no dynamic code execution)
  × os.environ (no environment variable access)
  × file writes outside designated directories
Enter fullscreen mode Exit fullscreen mode

AI-generated strategy code cannot perform any of these dangerous operations regardless of what the code contains.

Additional security measures:

  • CSRF protection + SSRF defenses
  • Rate limiting
  • Docker multi-stage builds with digest-pinned images
  • Short-lived single-use SSE authentication tickets

Links and Resources


Conclusion

Vibe-Trading represents a direction: lowering the technical barrier to quantitative research from "mastering multiple specialized tools" to "being able to describe what you want to research."

461 pre-built factors, 19 free data sources, backtest engines for 10 markets — this technical depth isn't a feature list. It's pre-solving the integration problems that anyone doing quantitative research has to work through, so users can focus on the research itself.

The shadow account feature is rare and genuinely useful. Most retail investors have accumulated trade records they've never systematically analyzed. This feature lets you compare "how I think I trade" with "how I actually trade."

The security design (AST sandbox, no fund custody, read-only defaults) shows the team understands where this class of system's risks lie and built defenses at the right places.

21.8k Stars from an academic background team at HKUDS signals both academic credibility and serious engineering.


Disclaimer: This article describes an open-source technical tool and does not constitute investment advice. Historical backtest performance does not guarantee future returns.


Explore PrimeSkills — A marketplace for handpicked AI Agents and skills. Each is validated in real enterprise workflows, stripping away hype and keeping only what truly works.

Welcome to my Homepage for more useful insights and interesting products.

Top comments (0)