Closed ambresh1 closed 1 year ago
+1 for this. I just encountered the same issue running on python 3.8
I get a similar error in the notebook "FinRL_PortfolioAllocation_NeurIPS_2020"
@ambresh1 Sorry this is caused by change of dataframe index when splitting the notebook. It's now fixed. Please go to https://github.com/AI4Finance-Foundation/FinRL-Tutorials/tree/master/1-Introduction/Stock_NeurIPS2018 and run the corresponding notebook.
If anyone solve the problem in "FinRL_PortfolioAllocation_NeurIPS_2020.ipynb", you are welcome to reply to this issue or send a PR.
I'm trying to execute this notebook (of the latest master branch of FinRL) and got the same error.
buy_cost_list = sell_cost_list = [0.001] * stock_dimension
num_stock_shares = [0] * stock_dimension
env_kwargs = {
"hmax": 100,
"initial_amount": 1000000,
"num_stock_shares": num_stock_shares,
"buy_cost_pct": buy_cost_list,
"sell_cost_pct": sell_cost_list,
"state_space": state_space,
"stock_dim": stock_dimension,
"tech_indicator_list": INDICATORS,
"action_space": stock_dimension,
"reward_scaling": 1e-4
}
e_train_gym = StockTradingEnv(df = train, **env_kwargs)
File [~/Library/Caches/pypoetry/virtualenvs/playground-6H0uwau1-py3.10/lib/python3.10/site-packages/finrl/meta/env_stock_trading/env_stocktrading.py:404](https://file+.vscode-resource.vscode-cdn.net/~/Library/Caches/pypoetry/virtualenvs/playground-6H0uwau1-py3.10/lib/python3.10/site-packages/finrl/meta/env_stock_trading/env_stocktrading.py:404), in StockTradingEnv._initiate_state(self)
398 if self.initial:
399 # For Initial State
400 if len(self.df.tic.unique()) > 1:
401 # for multiple stock
402 state = (
403 [self.initial_amount]
--> 404 + self.data.close.values.tolist()
405 + self.num_stock_shares
406 + sum(
407 (
408 self.data[tech].values.tolist()
409 for tech in self.tech_indicator_list
410 ),
411 [],
412 )
413 ) # append initial stocks_share to initial state, instead of all zero
414 else:
415 # for single stock
416 state = (
417 [self.initial_amount]
418 + [self.data.close]
419 + [0] * self.stock_dim
420 + sum(([self.data[tech]] for tech in self.tech_indicator_list), [])
421 )
'numpy.float64' object has no attribute 'values'
Please Try to run this : https://github.com/AI4Finance-Foundation/FinRL-Tutorials/blob/master/1-Introduction/Stock_NeurIPS2018_Train.ipynb
Error : /usr/local/lib/python3.8/dist-packages/finrl/meta/env_stock_trading/env_stocktrading.py in _initiate_state(self) 402 # for multiple stock 403 state = ( --> 404 [self.initial_amount] 405 + self.data.close.values.tolist() 406 + self.num_stock_shares