Noureddine RAMDI / ai-trader: AI-powered config-driven backtesting with natural language interaction

Created Mon, 04 May 2026 10:23:02 +0000 Modified Sat, 23 May 2026 20:41:27 +0000

whchien/ai-trader

Algorithmic trading frameworks are common, but few integrate natural language AI to interact with backtesting engines. ai-trader stands out by embedding an MCP server that lets AI assistants like Claude execute backtests, fetch market data, and analyze strategies through natural language commands. This hybrid approach bridges traditional quant workflows with emerging AI capabilities.

What ai-trader is and how it works

ai-trader is a Python backtesting framework built on top of Backtrader, designed for reproducible and configurable algorithmic trading strategy testing. The key architectural choice is a YAML-driven configuration system that defines backtest parameters, data sources, and strategy selection, making experiments repeatable and shareable.

It supports multiple markets including US stocks, Taiwan stocks, cryptocurrencies, and forex — all accessible through a unified CLI interface. Data fetching is integrated with caching backed by SQLite, which reduces repeated data retrieval times from ~2-3 seconds to ~50ms, improving iteration speed during development.

The standout feature is an embedded MCP (Multi-Channel Processing) server that exposes the backtesting engine’s capabilities to AI assistants like Claude. This means you can run backtests, query market data, or get strategy analyses simply by issuing natural language commands to the AI, which communicates with the MCP endpoint under the hood.

Underneath, ai-trader wraps Backtrader’s APIs but abstracts away much complexity via config files and CLI commands. It ships with 20+ built-in strategies ranging from classic technical indicator-based approaches (e.g., SMA crossover) to more adaptive models.

Strategy creation can be done manually by subclassing the BaseStrategy class or by leveraging Claude Code skills, enabling AI-assisted strategy generation and tuning.

Technical strengths and tradeoffs in ai-trader

The most technically interesting aspect is the MCP server integration. By exposing the backtesting framework as an AI-accessible service, ai-trader enables a novel interaction paradigm where an LLM can orchestrate trading experiments through natural language. This lowers the barrier for quant researchers who want to prototype strategies without deep coding.

The tradeoff is the added complexity and dependency on the MCP infrastructure and AI service availability. While the AI interaction is promising, it inherits the limitations of LLMs, including hallucinations and lack of domain-specific trading expertise.

The YAML config approach improves reproducibility and makes batch testing straightforward, but it requires learning the config schema and may not cover all use cases out of the box.

The SQLite caching layer is a practical addition that speeds up data fetches dramatically on repeated runs, improving DX in development and testing cycles. The 50ms cache hit time vs 2-3 seconds cold fetch is a solid improvement.

Code quality is generally good with a modular design. The CLI commands ai-trader run, ai-trader fetch, and ai-trader quick cover the main workflows, and the repo structure separates configs, data, and strategies cleanly.

A limitation is that this framework currently focuses on backtesting rather than live trading execution, so it’s mainly a research and prototyping tool rather than a full trading platform.

Quick start with ai-trader

The repo provides straightforward installation and usage instructions with two main options:

Option A: Install from PyPI for CLI usage

pip install ai-trader

This lets you run backtests, fetch data, and use the CLI commands directly.

Option B: Install from source for examples and customization

git clone https://github.com/whchien/ai-trader.git
cd ai-trader

# Install dependencies (choose one method)
uv sync        # Recommended (fastest, modern tool)

# poetry install   # Or use Poetry

# pip install -e .  # Or traditional pip with editable install

This mode is better if you want to run the config-based examples in config/backtest/, use example data files, or extend/customize strategies.

To run a backtest using a config file (source install required):

ai-trader run config/backtest/classic/sma_example.yaml

Or for a quick backtest on any data file (works with both pip and source install):

ai-trader quick --file path/to/data.csv --strategy SMA

Verdict

ai-trader offers a compelling blend of traditional backtesting with AI-powered natural language interaction via the MCP server. It’s a solid framework for quant researchers and hobbyists who want to experiment with algorithmic strategies across multiple markets using reproducible configs.

The AI integration is interesting but still experimental, so this is not a production-grade live trading system. It’s best suited for prototyping, learning, and research.

The caching and CLI design improve developer experience for iterative testing, and the modular strategy system is flexible. However, users must be comfortable with YAML configs and the limitations of LLM-based analysis.

In short, if you want to explore AI-assisted trading strategy design and backtesting with natural language control, ai-trader is worth a look. For traditional quantitative finance workflows without AI, more mature alternatives exist, but this project points toward a new interface paradigm worth understanding.


→ GitHub Repo: whchien/ai-trader ⭐ 636 · Python