Vibe CodeAdvanced11 min read

Vibe-Trading: Backtest Strategies in Plain English with HKU's Open-Source AI Agent

Vibe-Trading is HKU's open-source AI agent that backtests trading strategies from plain English — and its best feature analyzes your own biases. An honest guide, plus the backtesting traps that make results lie. Educational, not financial advice.

Vibe-Trading: Backtest Strategies in Plain English with HKU's Open-Source AI Agent

Writing a backtest used to mean Python, historical data wrangling, and hours of debugging before you saw a single result. Vibe-Trading — an open-source AI agent from the University of Hong Kong's Data Intelligence Lab — collapses that into a sentence: describe a strategy in plain English and its agents write the code, fetch the data, and run the backtest for you. It's genuinely powerful. It's also finance, so this guide is as much about what a backtest can't tell you as what it can — because the fastest way to lose money is to trust a pretty equity curve.


Difficulty: Intermediate · Required tools: Python 3 and a terminal; the Vibe-Trading repo (free, open-source — HKUDS/Vibe-Trading); and an LLM API key. Optional: your broker's trade history for the bias analysis · Updated: July 2026

Overview

Vibe-Trading is an open-source multi-agent finance workspace (22,000+ GitHub stars) that turns natural-language requests into executable trading strategies, backtests, and analysis across stocks, crypto, and forex. Under the hood it's a team of AI agents plus a large alpha-factor library (460+ factors, built on Qlib); you type "backtest a moving-average crossover on BTC," and it generates the strategy code, pulls the data, runs it, and hands back charts and metrics. It can export strategies to platforms like TradingView (Pine Script) and MetaTrader 5, and — the most interesting part — analyze your own trade history to surface behavioral biases.

Here's the honest frame, because it decides whether this tool helps you or hurts you. A backtest is a hypothesis, not a prophecy. It tells you how a rule would have performed on data that already happened — which is useful for learning and dangerous for predicting. It's trivially easy to produce a gorgeous backtest that falls apart the moment real money and real markets are involved, because past data can be overfit, and live trading adds costs, slippage, and your own emotions that a clean backtest never modeled. Vibe-Trading removes the coding barrier brilliantly; it does not remove market risk, and no tool does.

So where does it genuinely shine? Two places. First, learning — you can test a hundred ideas in the time it used to take to code one, which makes it a fantastic way to understand how strategies behave. Second, and more valuably, self-analysis: its Shadow Account and Trade Journal Analyzer take your real trades and show you where fear and greed cost you — a mirror, not a money printer. Treat it as a research and learning tool and it's excellent; treat it as a signal to bet your rent on, and the math of retail trading will find you.

The honest goal: by the end you'll be able to install Vibe-Trading, backtest a strategy from a plain-English prompt, read the results skeptically (spotting the traps that make a backtest lie), use its strongest feature to study your own biases, and know exactly what to validate before real money is ever at stake — with no illusion that any of this is a guarantee of profit.

Who This Is Useful For

  • Curious learners who want to understand how trading strategies work without writing quant code first.
  • Hobbyist and aspiring quants who want to prototype and study many ideas quickly — and learn why most don't survive contact with reality.
  • Traders who suspect their own psychology is the problem and want an honest, data-driven look at their behavioral biases.
  • What You Will Learn

  • What Vibe-Trading is (HKU's open-source multi-agent finance workspace) and how to install and run it.
  • How to backtest a strategy from a plain-English prompt — no manual coding.
  • How to read backtest metrics skeptically: Sharpe, drawdown, win rate — and the traps (overfitting, lookahead/survivorship bias, missing costs).
  • How to use the Shadow Account and Trade Journal Analyzer to find your own behavioral biases — the tool's best use.
  • What to validate before risking real money — and why a great backtest is still not a green light.
  • What You Need

  • Python 3 and a terminal, plus a little comfort with the command line for setup.
  • An LLM API key for the agents that generate and analyze strategies.
  • A skeptic's mindset. The right question is never "how good is this backtest?" but "how might it be fooling me?"
  • Optional: your broker's trade history (usually a CSV) if you want the bias analysis — the most valuable feature.
  • Money you can afford to lose, if you ever go live. Assume you might lose it; this tool doesn't change that.
  • The 7 Steps

    Step 1: Understand what Vibe-Trading is — and what a backtest actually proves

    Get the mental model right first. Vibe-Trading is a team of AI agents that turns your words into a runnable strategy and a backtest — it is not an oracle that knows what markets will do. A backtest replays a rule against historical data and reports what would have happened. That's genuinely useful for understanding and comparing ideas, and genuinely misleading if you read it as a forecast. Hold both truths at once: the coding is now free; the certainty is not.

    Pro tip: Before you run anything, write down what result would make you suspicious rather than excited — a 90% win rate, a suspiciously smooth curve, huge returns with tiny drawdown. Those are usually signs of a bug or overfitting, not a goldmine. Deciding your skepticism in advance keeps a pretty chart from switching off your judgment.

    Step 2: Install Vibe-Trading

    HKUDS/Vibe-Trading on GitHub — an MIT-licensed, multi-agent trading workspace (tags: ai-agent, backtesting, quantitative-finance).
    HKUDS/Vibe-Trading on GitHub — an MIT-licensed, multi-agent trading workspace (tags: ai-agent, backtesting, quantitative-finance).

    Clone the repo and install its dependencies from your terminal:

    
    git clone https://github.com/HKUDS/Vibe-Trading.git
    cd Vibe-Trading
    pip install -r requirements.txt
    

    Then follow the README to add your LLM API key (the agents need a model to reason with) and any market-data settings. A clean virtual environment avoids dependency clashes. It's an active open-source project, so the README is the source of truth for exact setup — check it rather than any single tutorial, this one included.

    Pro tip: Do the whole first run in a throwaway environment with a small data range. You want to confirm the agents, the model key, and the data source all connect before you care about any strategy — debugging setup and strategy at the same time is how people give up in Step 2.

    Step 3: Backtest a strategy from a plain-English prompt

    Describe a strategy in plain English and the agents write the code, fetch the data, and return a backtest.
    Describe a strategy in plain English and the agents write the code, fetch the data, and return a backtest.

    Now the payoff. Describe a strategy in natural language and let the agents build and run it — for example:

    
    Backtest a 50/200-day moving-average crossover on BTC/USD
    over the last 3 years. Report Sharpe, max drawdown, and win rate.
    

    The agents generate the code, fetch the historical data, run the backtest, and return charts plus metrics. Be specific — asset, timeframe, exact rules, the period — because a vague prompt ("test a strategy") produces a vague, hard-to-trust result. You can lean on its 460+ built-in alpha factors too ("add a momentum factor"), but more knobs also means more ways to accidentally overfit.

    Pro tip: Change one thing at a time between runs — the asset, the window, one rule — and keep the rest fixed. If you tweak ten parameters until the curve looks great, you haven't found a strategy; you've fit the noise in one slice of history, and it won't repeat.

    Step 4: Read the metrics skeptically — and know the traps

    The core trap: a curve that fits past data beautifully (left) can fall apart on data it wasn't tuned on (right). A backtest is a hypothesis, not a prediction.
    The core trap: a curve that fits past data beautifully (left) can fall apart on data it wasn't tuned on (right). A backtest is a hypothesis, not a prediction.

    A backtest hands you numbers — Sharpe ratio (risk-adjusted return), max drawdown (worst peak-to-trough loss), win rate — and they're only as honest as the test behind them. Four traps make a backtest lie: overfitting (tuning a rule until it fits past noise); lookahead bias (accidentally using information the strategy couldn't have had at the time); survivorship bias (testing only on assets that still exist, ignoring the ones that went to zero); and missing costs — most backtests exclude trading fees and slippage by default, which can turn a "winner" into a loser. Read every green result as "how might this be wrong?"

    Pro tip: Add realistic fees and slippage and re-run before you believe anything. A strategy that trades often can look brilliant with zero costs and bleed to death with real ones — costs are where a huge share of paper-profitable strategies quietly die.

    Step 5: Use the Shadow Account to study your own biases

    The Shadow Account compares your emotional real trades against a disciplined, rule-based version of you — a mirror for your biases.
    The Shadow Account compares your emotional real trades against a disciplined, rule-based version of you — a mirror for your biases.

    This is where Vibe-Trading is most useful, and least hyped. Feed it your real broker trade history and its Trade Journal Analyzer builds a profile of how you actually trade — holding periods, win rate, PnL ratio, drawdown — and diagnoses behavioral biases. Its Shadow Account extracts the rules implied by your trades and backtests a disciplined version of you, then shows the gap: where fear made you sell the dip, where greed made you overstay. That gap — your behavior versus the rules followed without emotion — is often the single most actionable thing in the whole tool.

    Pro tip: Use this feature even if you never build a strategy. Understanding that you consistently exit winners too early or average down into losers is worth more than any backtest — because your biases follow you into every trade, and they're the one variable you can actually control.

    Step 6: Validate hard before any real money

    Validate before real money: out-of-sample testing, realistic costs, paper trading, and starting small. A great backtest is never a green light.
    Validate before real money: out-of-sample testing, realistic costs, paper trading, and starting small. A great backtest is never a green light.

    A good backtest is a reason to investigate further, never a reason to deploy. Before real capital is involved: test the strategy on out-of-sample data it wasn't tuned on (walk it forward through periods you didn't optimize against); confirm it survives with realistic costs; then paper-trade it live for a meaningful stretch to see how it behaves in real time. If you export to TradingView (Pine Script) or MetaTrader 5, treat that as the start of validation, not the finish line. And if you ever go live, start with an amount whose loss wouldn't hurt.

    Pro tip: The single best defense against a lying backtest is out-of-sample testing. Optimize on one slice of history, then test — untouched — on a different slice. If it only works on the data you tuned it on, it doesn't work.

    Step 7: Know the limits — this is a learning tool, not a money machine

    Keep the honesty that got you here. Vibe-Trading removes the coding barrier to backtesting, which is a real and useful thing — but backtesting itself has hard limits, markets change, and most people who trade actively lose money to costs, taxes, and their own psychology. Use it to learn: to understand strategies, to test ideas cheaply, and above all to see your own biases clearly. What it can't do is tell you the future or make trading safe — no tool can, and any tool that claims to is the one to walk away from.

    Pro tip: Judge the tool by how much it improves your understanding and discipline, not by any single backtest's returns. The durable win here isn't a strategy — it's becoming a more skeptical, self-aware trader (or deciding, honestly, that active trading isn't for you).

    3 Common Mistakes to Avoid

  • Overfitting to a beautiful backtest. Tune enough parameters and any strategy looks great on past data — and then fails live. Change one variable at a time, and trust out-of-sample results far more than in-sample ones.
  • Ignoring costs, slippage, and bias. A backtest without fees, or with lookahead/survivorship bias, isn't optimistic — it's wrong. Add realistic costs and validate the data before you believe a single metric.
  • Treating a backtest as a signal to trade. A good historical result is a hypothesis, not a green light. Validate out-of-sample, paper-trade, start tiny — and remember this is education, not financial advice.
  • Going Further

  • Use it mainly as a mirror. The Shadow Account / bias analysis is the feature most likely to actually improve your outcomes — study your own behavior before you chase new strategies.
  • Learn the pitfalls formally. Overfitting, lookahead and survivorship bias, and transaction-cost modeling are the core skills of honest backtesting; the tool makes running tests easy, but interpreting them is on you.
  • Export and inspect the code. Vibe-Trading writes the strategy code — read it. Understanding what it generated is how you catch the subtle bugs that inflate a backtest.
  • Follow the project. It's an active open-source repo (Qlib-based, multi-market, MCP-friendly); the data sources, factors, and export targets keep expanding, so the README stays the reference.
  • Key Takeaways

  • Vibe-Trading is HKU's open-source, multi-agent finance workspace that backtests plain-English strategies across stocks, crypto, and forex — no manual coding.
  • A backtest is a hypothesis, not a prediction. Read every result skeptically and watch for overfitting, lookahead/survivorship bias, and missing costs.
  • Its best feature is self-analysis — the Shadow Account and Trade Journal Analyzer reveal your behavioral biases, which is often more valuable than any strategy.
  • Validate hard before real money: out-of-sample testing, realistic costs, paper trading, and starting small — a great backtest is never a green light.
  • This is educational, not financial advice. The tool removes the coding barrier, not the risk; most retail traders lose money, and no backtest changes that.
  • Sources: HKUDS/Vibe-Trading — GitHub · HKU Data Intelligence Lab · Vibe-Trading setup guide — knightli

    Learn AI, after work

    Track your progress, earn XP, and unlock more free tutorials in the AfterWork Bytes app.

    Open this tutorial in the app

    More AI tutorials