Gym AnyTrading is an open-source collection of OpenAI Gym environments for training reinforcement learning agents on trading. It provides ready-made stock market and foreign exchange environments that work with practically any historical price dataset, so researchers can focus on agent design instead of building a simulator. The project has earned more than 2,300 stars on GitHub and was last actively updated in March 2024.
Applying reinforcement learning to trading requires an environment that steps through time-series data, tracks positions and profit, and renders results in a way humans can inspect. Gym AnyTrading supplies exactly that with two environment families โ one for stocks and one for forex โ built on the standard Gym API, so they plug directly into popular RL libraries and training loops. You bring your own OHLC price data as a pandas DataFrame, configure the window size and episode ranges, and the environment handles trading mechanics and reward accounting. Built-in rendering draws price charts with the agent’s buy and sell actions, which makes debugging strategies far easier than reading raw logs.
Gym AnyTrading is completely free and open source under the MIT license. Market data is not included, so any data costs depend on the source you choose to plug in.
Gym AnyTrading is for RL practitioners, students, and quantitative researchers who want a fast way to prototype and benchmark trading agents. It removes the simulator-building busywork so experiments can start from real data within minutes.