FinRL-Tutorials icon indicating copy to clipboard operation
FinRL-Tutorials copied to clipboard

FinRL_HyperparameterTuning_Optuna.ipynb has error

Open nexon33 opened this issue 2 years ago • 2 comments

the file FinRL_HyperparameterTuning_Optuna.ipynb gives me the following error

TypeError                                 Traceback (most recent call last)
Cell In[17], line 16
      3 env_kwargs = {
      4     "hmax": 100, 
      5     "initial_amount": 1000000, 
   (...)
     13     
     14 }
     15 #Instantiate the training gym compatible environment
---> 16 e_train_gym = StockTradingEnv(df = train, **env_kwargs)

TypeError: __init__() missing 1 required positional argument: 'num_stock_shares'

when defining env_kwargs, how can I fix this?

just adding some random number for num_stock_shares throws the error TypeError: can only concatenate list (not "int") to list

nexon33 avatar Dec 31 '22 21:12 nexon33

Same here, I've tried to feed a list of zero.

init_stocks_holding = [0] * stock_dimension

Stock Dimension: 29, State Space: 291 init_stocks_holding: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

then, it will pass, but I'm not sure is correct.

Steven-KamInNg avatar Apr 09 '23 10:04 Steven-KamInNg

I have a new error.

/usr/local/lib/python3.9/dist-packages/finrl/meta/env_stock_trading/env_stocktrading.py in _do_buy() 177 # Buy only if the price is > 0 (no missing data in this particular date) 178 available_amount = self.state[0] // ( --> 179 self.state[index + 1] * (1 + self.buy_cost_pct[index]) 180 ) # when buying stocks, we should consider the cost of trading when calculating available_amount, or we may be have cash<0 181 # print('available_amount:{}'.format(available_amount))

TypeError: 'float' object is not subscriptable

Steven-KamInNg avatar Apr 09 '23 10:04 Steven-KamInNg