RL-friendly backtesting library for algorithmic trading research
Top 37.6% on sourcepulse
BTGym is a Python library designed for reinforcement learning (RL) research in algorithmic trading. It provides a scalable, event-driven backtesting framework that integrates with the OpenAI Gym API, enabling researchers and developers to build and test RL agents in simulated trading environments. The library aims to facilitate experimentation with complex, non-stationary stochastic environments common in financial markets.
How It Works
BTGym builds upon the backtrader
library, leveraging its event-driven architecture for backtesting. It wraps trading environments as OpenAI Gym-compatible environments, allowing seamless integration with standard RL algorithms and libraries. The framework supports both discrete and continuous action spaces, modeling trading scenarios with riskless and risky assets, transaction costs, and optional exogenous data feeds. Data sampling strategies include random, sequential, and sliding time-window approaches to manage non-stationarity and improve data efficiency.
Quick Start & Requirements
pip install -e .
after cloning the repository.Highlighted Details
Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
3 years ago
Inactive