ai-trader  by whchien

Algorithmic trading backtesting and LLM interaction

Created 1 year ago
409 stars

Top 71.3% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a comprehensive, Backtrader-powered backtesting framework for algorithmic trading strategies. It targets engineers, researchers, and professional traders seeking to efficiently test, optimize, and deploy strategies across diverse markets. The framework offers a reproducible, config-driven workflow, advanced strategy implementations, and novel integration capabilities with LLMs via an MCP server.

How It Works

Built upon the robust backtrader library, this framework introduces a modern architecture centered around a Command Line Interface (CLI) and YAML configuration files for reproducible, version-controlled backtests. It supports multi-market data sources (US stocks, TW stocks, crypto, forex) and features advanced, adaptive trading strategies like AlphaRSI variants. The design prioritizes ease of use for production workflows while offering deep customization.

Quick Start & Requirements

Installation involves cloning the repository, then using either Poetry (poetry install) or pip (pip install -r requirements.txt). For CLI access, install the package with pip install -e .. Running a backtest can be done via Python API (e.g., run_backtest(strategy=CrossSMAStrategy, data_source=None)) or the recommended CLI (ai-trader run config/backtest/classic/sma_example.yaml). Data fetching for various markets is integrated via CLI commands (e.g., ai-trader fetch AAPL --market us_stock). No specific hardware or OS prerequisites beyond a standard Python environment are detailed.

Highlighted Details

  • Features over 20 ready-to-use trading strategies, including advanced AlphaRSI variants with adaptive volatility and trend filtering.
  • Supports backtesting across multiple markets: US stocks, Taiwan stocks, cryptocurrencies, and forex.
  • Integrated MCP (Model Context Protocol) server enables LLMs (like Claude) to interact with the backtesting engine, offering tools for running backtests, fetching data, and listing strategies.
  • Config-driven workflows using YAML files promote reproducibility and version control for backtest setups.
  • Provides a CLI for streamlined execution of backtests, data fetching, and strategy management.

Maintenance & Community

The project is authored by Will Chien (@whchien). No specific details regarding active maintenance, community channels (like Discord/Slack), sponsorships, or partnerships are provided in the README.

Licensing & Compatibility

The project is licensed under the MIT License. This permissive license generally allows for commercial use and integration into closed-source projects.

Limitations & Caveats

Forex market data is noted to have zero volume due to its decentralized nature. The AITrader class has been deprecated since v0.2.0, requiring users to migrate their existing code.

Health Check
Last Commit

6 days ago

Responsiveness

Inactive

Pull Requests (30d)
4
Issues (30d)
0
Star History
141 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.