base_environment ================ .. py:module:: base_environment Classes ------- .. autoapisummary:: base_environment.BaseTradingEnv Module Contents --------------- .. py:class:: BaseTradingEnv(data, cfg, features, time_step = (TimeFrameUnit.Day, 1)) Bases: :py:obj:`gymnasium.Env`, :py:obj:`abc.ABC` Base trading environment for reinforcement learning agents. Contains common functionality shared between training and testing environments. .. py:attribute:: symbols .. py:attribute:: stock_dimension .. py:attribute:: features .. py:attribute:: feature_cols .. py:attribute:: cfg :type: trading.cli.alg.config.StockEnv .. py:attribute:: time_step .. py:attribute:: action_space .. py:attribute:: observation_space .. py:attribute:: observation_index .. py:attribute:: terminal :value: False .. py:attribute:: observation_timestamp :value: None .. py:method:: init_data(data) Set the data for the environment. :param data: DataFrame containing the trading data. .. py:method:: observation(df, portfolio_state, feature_cols, prices) :classmethod: Build observation from dataframe, portfolio state, and prices. .. py:method:: _get_observation_df(i = -1) Get the dataframe slice for observation at index i. .. py:method:: _get_prices(i = -1) Get prices at index i. .. py:method:: _get_observation(i = -1) :abstractmethod: Get the current observation from the environment. .. py:method:: reset(*, seed = None, options = None) Reset the environment to its initial state. Can be overridden by subclasses. .. py:method:: step(action) :abstractmethod: Execute one time step within the environment. .. py:method:: render() Render the environment state. .. py:method:: _reset_internal_states(timestamp = None) Reset internal state counters.