Open-source framework for building, training, and deploying machine learning based trading agents. Multi-timeframe observations, 4 live brokers, spot & futures, 19 free datasets on HuggingFace. Same code for training/backtesting and live execution.
From multi-timeframe market data to production deployment on real exchanges.
Your agent sees 1-minute, 5-minute, 15-minute, and 1-hour data simultaneously. Rich market context at every decision point.
Deploy to Alpaca (US stocks & crypto), Binance Futures, Bitget Futures, or Bybit Futures. Paper trading included.
Long-only spot trading or leveraged long/short futures with configurable leverage up to 125x. Bracket orders with SL/TP.
Built on TensorDict and TorchRL. Composable transforms, standard loss modules, and seamless integration with PPO, DQN, SAC, and more.
1-minute OHLCV data for BTC, ETH, SOL, and more on HuggingFace. Spot, perpetual futures, and basis data. Validated and ready for training.
Behavioral fingerprinting, regime-conditional metrics, and buy-and-hold detection. Know what your agent actually learned.
Backtest strategies on historical data with offline environments. We provide free datasets to get started.
from torchtrade.envs.offline import SequentialTradingEnv
from torchtrade.envs.offline import SequentialTradingEnvConfig
config = SequentialTradingEnvConfig(
trading_mode="futures",
time_frames=["5min", "15min", "60min"],
leverage=5.0,
)
env = SequentialTradingEnv(df, config)
Train with PPO, DQN, GRPO, or any TorchRL algorithm out of the box. Or develop your own custom algorithm.
# Hydra config-driven training
# Multi-seed for statistical rigor
$ python train.py \
algo=ppo \
env=sequential_futures \
seed=1,2,3 \
optim.lr=3e-4 \
logger=wandb
Go live on any supported broker with the same environment API.
from torchtrade.envs.live.binance import (
BinanceFuturesTorchTradingEnv
)
env = BinanceFuturesTorchTradingEnv(config)
obs = env.reset()
while True:
action = policy(obs)
obs = env.step(action)
Specialized Claude Code agents that transform your AI assistant into a TorchTrade expert. Each agent is an optimized .md file packed with domain knowledge — drop it into your Claude Code setup and get instant expertise on any part of the TorchTrade pipeline.
These agents do not guarantee you will find a winning trading strategy. They accelerate and improve the development and discovery process, helping you iterate faster on research, environments, and deployments.
Deploy trained policies to any supported broker. Knows APIs, error recovery, logging, paper trading, and the full path from testnet to mainnet.
Run rigorous RL experiments. Designs sweeps, enforces multi-seed methodology, configures Hydra + WandB, and generates publication-ready result plots.
Build custom trading environments from scratch. Deep knowledge of TensorDicts, transforms, reward functions, action spaces, and position management.
Evaluate what your trained agent actually learned. Behavioral fingerprinting, buy-and-hold detection, regime analysis, and actionable improvement recommendations.
Build reliable data pipelines. Downloads OHLCV from exchanges, validates for gaps, creates HuggingFace datasets, and handles multi-timeframe alignment.
Craft informative features for your agent. Technical indicators, Chronos embeddings, normalization strategies, and multi-timeframe feature alignment.
Design neural architectures for trading. Actor-critic networks, dueling DQN, RNN policies, multi-input encoders, and TorchRL module composition.
The complete TorchTrade AI pipeline. Data, features, environments, networks, research, analysis, and live deployment — all in one package.
Articles and research reports with practical insights from experiments. Specific hyperparameters, training curves, failure modes, reward shaping decisions, and regime analysis from real runs. Each article includes the full experiment config and our interpretation of the results.
Architecture overview, universal account state, environment hierarchy, and the path from research to production.
Training DQN agents with stop-loss and take-profit bracket orders. Combinatorial action spaces and risk management.
Can a frontier LLM beat RL agents at live crypto trading? A week-long experiment with real money and real results.
Train on BTC, deploy on ETH. Contrastive representation learning for cross-asset transfer without retraining.
19 free 1-minute OHLCV datasets across major crypto pairs. Spot and perpetual futures, validated for gaps, ready for training.
Trade stocks, crypto spot, and crypto futures with paper trading support on every broker.
# Install TorchTrade
pip install torchtrade
# Create an environment and run your agent
from torchtrade.envs.offline import SequentialTradingEnv, SequentialTradingEnvConfig
import pandas as pd
df = pd.read_parquet("btcusdt_5m.parquet")
config = SequentialTradingEnvConfig(
trading_mode="futures",
time_frames=["5min", "15min", "60min"],
window_sizes=[12, 8, 24],
leverage=5.0,
)
env = SequentialTradingEnv(df, config)
td = env.reset()
while not td["done"]:
td["action"] = policy(td)
td = env.step(td)