FinRL
FinRL copied to clipboard
StockTradingEnv.py
Why is the state space for the StockTradingEnv a 291 dimension space? how is the state_space derived? what is the rationale?
stock_dimension = len(train.tic.unique()) state_space = 1 + 2*stock_dimension + len(INDICATORS)*stock_dimension
Stock Dimension: 29, State Space: 291
The state space is derived as follows:
-
Account Balance (1): It represents the balance in the trading account.
-
Stock Dimension (2*stock_dimension): It includes the price and position for each stock. For each stock, two values are included: the stock price and the position (or holding) of the stock.
-
Indicators for each stock (len(INDICATORS)*stock_dimension): It represents the additional indicators calculated for each stock. The number of indicators multiplied by the stock dimension gives the total dimensions contributed by the indicators for all stocks. For example, if you have SMA and RSI (2 indicators in total) and you have 3 stocks, you have 2 * 3 = 6 values.
Adding these components together, the state space for the StockTradingEnv is a (1 + 2*stock_dimension + len(INDICATORS)*stock_dimension)-dimensional space, encompassing the account balance, stock prices, stock positions, and indicators for each stock.