Repolode
whchien

whchien/ai-trader

Config-driven backtesting framework built on Backtrader for testing trading strategies across stocks, crypto, and forex, with an MCP server for AI assistants.

Open-source alternative to:TradingView

Stars
1,113
Forks
163
Open issues
7
Last commit
7 months ago

What is it?

AI-Trader is a Python backtesting framework for algorithmic trading, built on Backtrader. Backtests are defined in version-controllable YAML files, so runs can be reproduced, and the project ships with more than 20 built-in strategies ranging from classic indicator crossovers to adaptive models.

The framework covers US stocks, Taiwan stocks, cryptocurrencies, and forex. A CLI runs backtests from config files or quick runs on a data file, and fetches historical market data to CSV or a local SQLite cache. Custom strategies inherit from a base class and are picked up automatically by the CLI and the run_backtest function.

It also includes an MCP (Model Context Protocol) server, so AI assistants such as Claude Desktop can run backtests, fetch data, and list strategies through natural language.

Key features

  • 01Define backtests with reproducible YAML config files
  • 02Built-in MCP server for AI assistants like Claude
  • 03Supports US stocks, Taiwan stocks, crypto, and forex
  • 04Over 20 built-in strategies
  • 05CLI for running backtests and fetching market data
  • 06Optional SQLite caching for downloaded data

Use cases

  • Comparing classic moving-average or indicator strategies on historical stock data
  • Running repeatable backtests from versioned config files in a research workflow
  • Letting an AI assistant run backtests and fetch data through natural language
  • Prototyping custom trading strategies on a Backtrader-based base class

Quick start

  1. 1

    Install from PyPI

    pip install ai-trader
  2. 2

    Or clone the source repository

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

    Install dependencies from the source directory

    uv sync
  4. 4

    Run a quick backtest on your own data file

    ai-trader quick CrossSMAStrategy your_data.csv --cash 100000

Things to know

  • Licensed under GPL-3.0, so derivative distributions must also be open source under GPL-3.0.
  • Some features, such as the example configs and data, require a source installation rather than the PyPI package.

Topics

FAQ

What is ai-trader?
Config-driven backtesting framework built on Backtrader for testing trading strategies across stocks, crypto, and forex, with an MCP server for AI assistants. AI-Trader is a Python backtesting framework for algorithmic trading, built on Backtrader. Backtests are defined in version-controllable YAML files, so runs can be reproduced, and the project ships with more than 20 built-in strategies ranging from classic indicator crossovers to adaptive models.
Is ai-trader free to use? What license does it have?
ai-trader is open source under the GPL-3.0 license. Check the license terms before using it in commercial products.
Is ai-trader still maintained?
No commits for 6+ months. The last commit to ai-trader was on Mar 28, 2026.
What can I use ai-trader for?
Comparing classic moving-average or indicator strategies on historical stock data Running repeatable backtests from versioned config files in a research workflow Letting an AI assistant run backtests and fetch data through natural language Prototyping custom trading strategies on a Backtrader-based base class
How do I install ai-trader?
Install from PyPI: pip install ai-trader Or clone the source repository: git clone https://github.com/whchien/ai-trader.git Install dependencies from the source directory: uv sync Run a quick backtest on your own data file: ai-trader quick CrossSMAStrategy your_data.csv --cash 100000
Where can I get ai-trader?
The source code and installation instructions are on GitHub: https://github.com/whchien/ai-trader

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects