AI-Trader MCP
MCP server for backtesting trading strategies: the agent fetches quotes, runs a test from YAML and reads the metrics on the Backtrader engine
- 1,122 ★ on the repository
- Last commit
- GPL-3.0
Extended access
Why this level
- Downloads quotes from external sources and writes CSV and SQLite files to the chosen folder
- Reads the YAML config and data files the user points to by path
Install
- Works in
Manual install
pip install ai-traderRequires Python 3.11 or newer. Package version 0.3.4. For the examples, config templates and data, clone the repository and install with `uv sync`.
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- Downloads quotes from external sources and writes CSV and SQLite files to the chosen folder
- Reads the YAML config and data files the user points to by path
This is third-party code. Review the repository files before installing.
What it does
AI-Trader is a framework for testing trading strategies against historical data. It is built on Backtrader and driven by a YAML file that sets starting cash, commission, the quotes file, the period, the strategy class with its parameters and the position size. The package ships more than twenty ready strategies: classic indicator ones (moving averages, RSI, MACD, Bollinger bands, Turtle, VCP) and portfolio ones with ROC and RSRS rotation. The MCP server starts with `python -m ai_trader.mcp` and gives the agent four tools. `list_strategies` shows what is available. `fetch_market_data` downloads quotes for US and Taiwan stocks, crypto and forex and saves them to CSV, optionally to a SQLite database. `quick_backtest` takes a strategy name, a data file and parameters and runs a test without a config, with a default position size of 95%. `run_backtest` reads a finished YAML file and returns detailed metrics. The `ai-trader` command line does the same (`run`, `fetch`, `quick`, `data`). For Claude Code the repository includes an `add-strategy` skill: it asks for the name, parameters, entry and exit conditions and creates a new strategy file registered in the package.
Who it is for. For traders and Python developers who test ideas on history and want to give the agent plain-language commands instead of running scripts by hand.
Good fit when
- You want to run a moving-average or RSI strategy on TSM or Apple stock and compare it with ready metrics
- The agent should download quotes for a period and save them to CSV or SQLite for repeat tests
- You want test parameters in YAML under version control so the same run can be repeated
- You need a new Backtrader strategy and would rather describe entry and exit rules to the `add-strategy` skill than write the class by hand
- You want to try the packaged strategies quickly on a single data file
Not a fit when
- You need to send real orders to an exchange: none of the server's four tools does that, it only replays history
- You need to test a portfolio through MCP: `quick_backtest` and `run_backtest` support single-stock strategies, while portfolio strategies run from the command line or Python
- You install on Python older than 3.11: the package requires 3.11 up to but excluding 4.0
- You need quotes from Russian exchanges: the project lists US, Taiwan, crypto and forex markets
- You need an MCP server with live quotes, screeners and indicators on request: tradingview-mcp covers that
Example request
Download TSM quotes from 2020 and run a 10 and 30 moving-average crossover strategy with a million in starting cashMCP
- Transport
- stdio
- Authentication
- not required
Limitations
- GPL-3.0 licence: derivative works must be distributed on the same terms.
- It needs Python 3.11 or newer; the dependencies include `TA-Lib`, `backtrader` 1.9.78.123 and `fastmcp`, so a separate environment is the safer place to install.
- Through MCP only single-instrument strategies run, and the Claude Desktop config must set the project folder in `cwd`.
- Backtest results describe the past: commission is set by hand in the config, and the sample config shows no slippage or liquidity model.
- Data comes through `yfinance` and `twstock`, so it depends on those sources being reachable; the market list has no ready loaders for Russian exchanges.
- The tool gives no investment advice; it checks ideas against history.
How to disable. Remove the `ai-trader` block from `mcpServers` in `claude_desktop_config.json` and restart Claude Desktop. The package is removed with `pip uninstall ai-trader`. Downloaded quotes sit in the folder you chose as `output_dir`; delete it by hand.
FAQ
How do I run a strategy backtest through MCP?
Add the server to the client config, restart it and ask the agent to run the strategy. For a single data file `quick_backtest` is enough: it needs a strategy name, a CSV path and parameters. To keep settings in the repository, describe them in YAML and call `run_backtest`.
Which markets and data sources are supported?
The README lists US stocks, Taiwan stocks, crypto and forex. `ai-trader fetch` pulls data through the `yfinance` and `twstock` dependencies; an example call is `ai-trader fetch BTC-USD --market crypto --start-date 2020-01-01`.
How many ready strategies does the package have?
More than twenty. The `classic` folder holds single-instrument ones, among them sma, rsi, macd, bbands, turtle, vcp, momentum, roc, rsrs and buyhold. The `portfolio` folder has four rotation ones: multi_bbands, roc_rotation, rsrs_rotation and triple_rsi.
Can quotes be stored in a database instead of CSV?
Yes. `ai-trader fetch` has a `--storage` option with csv, sqlite and both. After the first download, a repeat request for the same data is served from the SQLite cache without calling the source, and `ai-trader data list` and `ai-trader data info` show what is stored.
How do I add my own strategy?
Two ways. In Claude Code call the `add-strategy classic` skill: it asks for the name, description, parameters and entry and exit rules, then creates the file and registers the class. By hand, create a file in `ai_trader/backtesting/strategies/classic/` and inherit `BaseStrategy`; the class is immediately available to the CLI and `run_backtest`.
What is the agentic_ai_trader folder?
It holds two separate examples with their own description and `pyproject.toml`: `financial-advisor` with sub-agents for data analysis, trading, execution and loss assessment, and `trading-backtester` with NVDA and TSM data. They are not part of the MCP server.
Discussion
No questions or reviews yet.
Related
MCP serversAn MCP server for agentic trading: backtesting, 462 prebuilt alphas, trade journal analysis and multi-agent research teams
Skills and an MCP server for options traders: quotes, technical analysis, Greeks, spreads, scanners and Interactive Brokers portfolio
An MCP server for market data and technical analysis: quotes, indicators, screeners and backtesting for stocks, crypto, forex and futures
An MCP server for MetaTrader 5: the agent reads the account and quotes, opens, changes and closes trades; a skill, REST and quote stream included
Autonomous trading MCP for T-Bank Invest
Tinkoff Trader MCP
An MCP server for T-Bank Invest with market analysis, backtesting five strategies, risk management and order placement, with live trading off by default
An MCP server for personal stock analysis: market data, technical indicators, screening and portfolio tracking, no keys for the core
Comparison with similar tools
Entries that share the main search query, and how they differ.
| Entry | Official | Authentication | Repository stars | Main difference |
|---|---|---|---|---|
| AI-Trader (this entry) | no | not required | 1,122 | |
| Vibe-Trading | no | key is optional | 37,055 | a large toolset with ten backtest engines, trade-journal analysis and multi-agent teams |
| tradingview-mcp | no | not required | 5,163 | quotes, indicators and screeners on request, with backtesting as one of the features |
README in short
The repository holds the `ai_trader` package with backtesting, data loaders, a command line and an MCP server, YAML templates in `config/backtest`, example scripts and tests (unit and integration). The English and Chinese description walks through install from PyPI or source, running a test, fetching data, connecting to Claude Desktop and creating a strategy. Separate documents cover SQLite storage and migration from 0.1.x.