Low activity

TensorTrade guide

TensorTrade’s modular environment design is useful for RL experiments even where its maintenance lags.

Last reviewed

Quick answer

TensorTrade is an open-source Python framework for building reinforcement-learning trading environments from interchangeable parts: data feeds, exchanges, action schemes, reward schemes and renderers, compatible with Gym-style agents. Development has slowed, so check compatibility with current libraries.

TensorTrade at a glance

Category
Machine learning & AI
Language
Python
License
Apache-2.0
Does
Machine learning, Backtesting
Markets
Crypto, Stocks
Best for
Custom RL environments with unusual action or reward designs.
In AlgoGP
Use the exported strategy object from your own code

Pick it if

Custom RL environments with unusual action or reward designs.

Watch out for

Low recent activity.

TensorTrade strengths and limitations

Strengths

  • Composable environment components.
  • Works with common RL libraries.

Limitations

  • Low recent activity.
  • Research tool, not production trading.

TensorTrade example

pip install tensortrade
Install
import tensortrade.env.default as default
env = default.create(portfolio=portfolio, action_scheme="managed-risk",
                     reward_scheme="risk-adjusted", feed=feed, window_size=20)
Environment construction (abridged).

Use TensorTrade with AlgoGP

AlgoGP does not add TensorTrade to projects automatically yet, but nothing stops you using them together. Every AlgoGP project exports plain Python with a framework-neutral strategy object, so you can call it from TensorTrade yourself.

  1. 1

    Design and backtest in AlgoGP

    Describe the idea to the copilot and backtest it on AlgoGP’s normalized history.

  2. 2

    Add any bridge to get the adapter core

    Adding a bridged framework (for example Backtrader) writes frameworks/algogp_bridge.py, whose StrategyBridge.on_bar() returns the orders the strategy wants.

  3. 3

    Call it from TensorTrade

    Feed TensorTrade’s bars to StrategyBridge, place the returned orders with TensorTrade, and report fills back with sync().

TensorTrade: frequently asked questions

TensorTrade or FinRL?

FinRL is more active and has more ready-made pipelines; TensorTrade is more modular.

TensorTrade alternatives

Independent guide. AlgoGP is not affiliated with TensorTrade. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.

Build a strategy