AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
9.72k stars 2.36k forks source link

Stock_NeurIPS2018_SB3.ipynb-initiate StockTradingEnv failed when multiple tickers loaded #1003

Closed chenshenlv closed 1 year ago

chenshenlv commented 1 year ago

Describe the bug When running the Stock_NeurIPS2018_SB3.ipynb In[21] and In[22], the StockTradingEnv can not be created. It reported below error: "Traceback (most recent call last): File "d:/Trading/ppoALpaca/train.py", line 137, in e_train_gym = StockTradingEnv(df = processed_full, **env_kwargs) File "D:\Program\anaconda3\envs\trade\lib\site-packages\finrl\meta\env_stock_trading\env_stocktrading.py", line 76, in init self.state = self._initiate_state() File "D:\Program\anaconda3\envs\trade\lib\site-packages\finrl\meta\env_stock_trading\env_stocktrading.py", line 404, in _initiate_state

To Reproduce Nothing in the original notebook was modified. Just run it step by step.

Suspect reason Perhaps the below line in env_stocktrading.py causes the error: self.data = self.df.loc[self.day, :] In the case of multiple tickers, this line just extracts the first row of data to initiate the initial state, which causes the state space wrong.