Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

tensortrade

> 编程语言
Open source

An open source reinforcement learning framework for training, evaluating, and deploying robust trading agents.

6.6K stars0 likes2 views
WebsiteGitHub

About

An open source reinforcement learning framework for training, evaluating, and deploying robust trading agents.

TensorTrade

Train RL agents to trade. Can they beat Buy-and-Hold? TensorTrade is an open-source Python framework for building, training, and evaluating reinforcement learning agents for algorithmic trading. The framework provides composable components for environments, action schemes, reward functions, and data feeds that can be combined to create custom trading systems.

Quick Start

bash
# Requires Python 3.12+
python3.12 -m venv tensortrade-env && source tensortrade-env/bin/activate
pip install -e .

# For training with Ray/RLlib (recommended)
pip install -r examples/requirements.txt

# Run training
python examples/training/train_simple.py

Documentation & Tutorials

Tutorial Index — Start here for the complete learning curriculum.

Foundations

  • The Three Pillars — RL + Trading + Data concepts
  • Architecture — How components work together
  • Your First Run — Run and understand output

Domain Knowledge

  • Trading for RL Practitioners
  • RL for Traders
  • Common Failures — Critical pitfalls to avoid
  • Full Introduction — New to both domains

Core Components

  • Action Schemes — BSH and order execution
  • Reward Schemes — Why PBR works
  • Observers & Feeds — Feature engineering

Training

  • First Training — Train with Ray RLlib
  • Ray RLlib Deep Dive — Configuration options
  • Optuna Optimization — Hyperparameter tuning

Advanced Topics

  • Overfitting — Detection and prevention
  • Commission Analysis — Key research findings
  • Walk-Forward Validation — Proper evaluation

Additional Resources

  • Experiments Log — Full research documentation
  • Environment Setup — Detailed installation guide
  • API Reference

Research Findings

We conducted extensive experiments training PPO agents on BTC/USD. Key results:

Configuration Test P&L vs Buy-and-Hold
Agent (0% commission) +$239 +$594
Agent (0.1% commission) -$650 -$295
Buy-and-Hold -$355 —

The agent demonstrates directional prediction capability at zero commission. The primary challenge is trading frequency—commission costs currently exceed prediction profits. See EXPERIMENTS.md for methodology and detailed analysis.


Architecture

…
Component Purpose Default
ActionScheme Converts agent output to orders BSH (Buy/Sell/Hold)
RewardScheme Computes learning signal PBR (Position-Based Returns)
Observer Generates observations Windowed features
Portfolio Manages wallets and positions USD + BTC
Exchange Simulates execution Configurable commission

Training Scripts

Script Description
examples/training/train_simple.py Basic demo with wallet tracking
examples/training/train_ray_long.py Distributed training with Ray RLlib
examples/training/train_optuna.py Hyperparameter optimization
examples/training/train_best.py Best configuration from experiments

Installation

Requirements: Python 3.11 or 3.12

bash
# Create environment
python3.12 -m venv tensortrade-env
source tensortrade-env/bin/activate  # Windows: tensortrade-env\Scripts\activate

# Install
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .

# Verify
pytest tests/tensortrade/unit -v

# Training dependencies (optional)
pip install -r examples/requirements.txt

See ENVIRONMENT_SETUP.md for platform-specific instructions and troubleshooting.

Docker

bash
make run-notebook  # Jupyter
make run-docs      # Documentation
make run-tests     # Test suite

Project Structure

tensortrade/
├── tensortrade/           # Core library
│   ├── env/              # Trading environments
│   ├── feed/             # Data pipeline
│   ├── oms/              # Order management
│   └── data/             # Data fetching
├── examples/
│   ├── training/         # Training scripts
│   └── notebooks/        # Jupyter tutorials
├── docs/
│   ├── tutorials/        # Learning curriculum
│   └── EXPERIMENTS.md    # Research log
└── tests/

Troubleshooting

Issue Solution
"No stream satisfies selector" Update to v1.0.4-dev1+
Ray installation fails Run pip install --upgrade pip first
NumPy version conflict pip install "numpy>=1.26.4,<2.0"
TensorFlow CUDA issues pip install tensorflow[and-cuda]>=2.15.1

Contributing

See CONTRIBUTING.md for guidelines.

Priority areas:

  1. Trading frequency reduction (position sizing, holding periods)
  2. Commission-aware reward schemes
  3. Alternative action spaces

Community

  • Discord
  • GitHub Issues
  • Documentation

License

Apache 2.0

Issues· 49 open

View all issuesOpen on GitHub
  • #501

    Observer converts NaN to 0.0 silently, so an unwarmed indicator reads as a real zero

    Updated Sep 8, 2026
  • #500

    Proposal: point-in-time macro features for TensorTrade DataFeeds

    Updated Jul 15, 2026
  • #482

    Help

    Updated Nov 4, 2025
  • #440

    treynor_ratio() missing 1 required positional argument: 'benchmark' in train_and_evaluate.ipynb Cell 10

    Updated May 16, 2023
  • #457

    How to install correctly on windows 11?

    Updated Jan 19, 2023
  • #455

    new complementary tool

    Updated Jan 10, 2023
  • #444

    Technical Analysis Library in Python (ta) required for tests but not described anywhere?

    Updated May 30, 2022
  • #443

    train_and_evaluate.ipynb getting AttributeError: 'AnalysisIndicators' object has no attribute 'study'

    Updated May 30, 2022
  • #442

    got a mistake when brew

    Updated May 17, 2022
  • #382

    Not possible to use GPU with Tensortrade environments

    help wantedUpdated May 7, 2022

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 24, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言