To train a trading agent, we need to create a market environment that provides price and other information, offers trading-related actions, and keeps track of the portfolio to reward the agent accordingly.
Reinforcement learning for trading
How to design an OpenAI trading environment
The OpenAI Gym allows for the design, registration, and utilization of environments that adhere to its architecture, as described in its documentation (https://github.com/openai/gym/tree/master/gym/envs#how-to-create-new-environments-for-gym). The trading_env.py file implements an example that illustrates how to create a class that implements the requisite step() and reset() methods.
The trading environment consists of three classes that interact...