← all repositories
whchien/ai-trader

Backtrader wrapped in YAML and handed to Claude

A config-driven Backtrader wrapper that exposes your backtesting engine to LLMs via an MCP server, complete with multi-market data fetching and a library of 20+ strategies.

ai-trader
Velocity · 7d
+1.1
★ / day
Trend
steady
star history

What it does

ai-trader layers a config-driven workflow and CLI on top of Backtrader, letting you backtest algorithmic strategies against US stocks, Taiwan stocks, crypto, and forex. You define a run in a single YAML file—broker, data source, strategy parameters, and all—or call run_backtest directly from Python. It ships with a library of over 20 built-in strategies, though the README only details classic indicator-based examples like moving-average crossovers.

The interesting bit

The project doubles as an MCP server, meaning you can point Claude (or another LLM client) at your backtesting engine and have it execute tests, fetch data, or list strategies via natural language. There is even a Claude Code /add-strategy skill that interactively generates new strategy files and wires them into the package automatically.

Key highlights

  • Version-controllable YAML configs define the full backtest stack from broker cash to position sizing
  • MCP server exposes the CLI and Python API to LLMs for agentic control
  • Fetches historical data for multiple markets and caches it in SQLite for repeated runs
  • 20+ built-in strategies included, spanning classic indicators to unspecified “adaptive models”
  • Rich CLI for one-off backtests, data management, and market data downloads

Caveats

  • MCP setup requires hand-editing a Claude Desktop JSON config file, so the LLM hookup is not quite plug-and-play
  • The strategy library is advertised as including “advanced adaptive models,” but the README only demonstrates classic technical-indicator examples, leaving the scope unclear
  • GPL-3.0 license may be a non-starter for proprietary trading firms

Verdict

Good fit for quant developers who want a structured, LLM-augmented sandbox without building a Backtrader harness from scratch. If you already have a heavily customized Backtrader setup, this is mostly polite wrapping paper.

Frequently asked

What is whchien/ai-trader?
A config-driven Backtrader wrapper that exposes your backtesting engine to LLMs via an MCP server, complete with multi-market data fetching and a library of 20+ strategies.
Is ai-trader open source?
Yes — whchien/ai-trader is open source, released under the GPL-3.0 license.
What language is ai-trader written in?
whchien/ai-trader is primarily written in Python.
How popular is ai-trader?
whchien/ai-trader has 891 stars on GitHub and is currently holding steady.
Where can I find ai-trader?
whchien/ai-trader is on GitHub at https://github.com/whchien/ai-trader.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.