AI4Finance-Foundation / AI4Finance-Foundation/FinRL

Changes to StockTradingEnv Cause Hyperparameter Optimization Notebook to Fail

Aperta
#506 3 commenti 2 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Jupyter Notebook
Stelle
16.3k
Fork
3.5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

My notebook, _FinRL_HyperparameterTuning_Optuna.ipynb_, (in Tutorials/4-Optimization) is failing because of the changes recently made to the _StockTradingEnv_ class, specifically the introduction of "initial_list" to _env_stocktrading.py_. After an initial failure, I created an initial list based on reading the new code, but it failed as well. See below.

This new code was introduced through the standard installation command I have been using since I first began working on my notebook:

`!pip install git+https://github.com/AI4Finance-LLC/FinRL-Library.git`

In the near term, is there a previous release of the FinRL library available that does not include the initial_list concept? If not, I need further instructions on using the _initial_list_.

Thanks. Please let me know if you need more information.

```
[I 2022-03-08 20:33:10,205] A new study created in memory with name: ddpg_study
Callback threshold 1e-05, trial_number 5, patience 15
{'buffer_size': 10000, 'learning_rate': 0.15271325981748027, 'batch_size': 64}
Using cuda device
[W 2022-03-08 20:33:22,933] Trial 0 failed because of the following error: TypeError("'float' object is not subscriptable")
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/optuna/study/_optimize.py", line 213, in _run_trial
value_or_values = func(trial)
File "[](https://12lizvrkplh-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20220304-060046-RC00_432410246#)", line 26, in objective
total_timesteps=total_timesteps)
File "/usr/local/lib/python3.7/dist-packages/finrl/drl_agents/stablebaselines3/models.py", line 103, in train_model
callback=TensorboardCallback(),
File "/usr/local/lib/python3.7/dist-packages/stable_baselines3/ddpg/ddpg.py", line 139, in learn
reset_num_timesteps=reset_num_timesteps,
File "/usr/local/lib/python3.7/dist-packages/stable_baselines3/td3/td3.py", line 214, in learn
reset_num_timesteps=reset_num_timesteps,
File "/usr/local/lib/python3.7/dist-packages/stable_baselines3/common/off_policy_algorithm.py", line 361, in learn
log_interval=log_interval,
File "/usr/local/lib/python3.7/dist-packages/stable_baselines3/common/off_policy_algorithm.py", line 587, in collect_rollouts
new_obs, rewards, dones, infos = env.step(actions)
File "/usr/local/lib/python3.7/dist-packages/stable_baselines3/common/vec_env/base_vec_env.py", line 162, in step
return self.step_wait()
File "/usr/local/lib/python3.7/dist-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 44, in step_wait
self.actions[env_idx]
File "[/usr/local/lib/python3.7/dist-packages/finrl/finrl_meta/env_stock_trading/env_stocktrading.py](https://12lizvrkplh-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20220304-060046-RC00_432410246#)", line 298, in step
actions[index] = self._sell_stock(index, actions[index]) * (-1)
File "/usr/local/lib/python3.7/dist-packages/finrl/finrl_meta/env_stock_trading/env_stocktrading.py", line 149, in _sell_stock
sell_num_shares = _do_sell_normal()
File "/usr/local/lib/python3.7/dist-packages/finrl/finrl_meta/env_stock_trading/env_stocktrading.py", line 104, in _do_sell_normal
* (1 - self.sell_cost_pct[index])
TypeError: 'float' object is not subscriptable
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
51 trial_number=lc_trial_number)
52 #You can increase the n_trials for a better search space scanning
---> 53 study.optimize(objective, n_trials=n_trials,catch=(ValueError,),callbacks=[logging_callback])

15 frames
/usr/local/lib/python3.7/dist-packages/finrl/finrl_meta/env_stock_trading/env_stocktrading.py in _do_sell_normal()
102 self.state[index + 1]
103 * sell_num_shares
--> 104 * (1 - self.sell_cost_pct[index])
105 )
106 # update balance

TypeError: 'float' object is not subscriptable
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.