Open bladering opened 1 year ago
File: Stock_NeurlPS2018_Train.ipynb
File ~/anaconda3/lib/python3.8/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 )
AttributeError: 'numpy.float64' object has no attribute 'values'
I think you have an issue with your dataframe index
try before passing to the enviroment df.index= df["date"].factorize()[0]
df.index= df["date"].factorize()[0]
it might solve your issue
It is useful,thank you so much.
File: Stock_NeurlPS2018_Train.ipynb
File ~/anaconda3/lib/python3.8/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 )
AttributeError: 'numpy.float64' object has no attribute 'values'