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

An error when running examples /FinRL_Ensemble_StockTrading_ICAIF_2020.ipynb

Open wmmxk opened this issue 1 year ago • 5 comments

I was running the example in the title, and run into this error "If using all scalar values, you must pass an index". The error traces back to the code below and it is because trade_env.render() in finrl.agents.stablebaselines3.models.py returns None. It seems that the version of the stablebaselines3 I installed is not correct. Has anyone run into a similar issue?

        for i in range(len(trade_data.index.unique())):
            action, _states = model.predict(trade_obs)
            trade_obs, rewards, dones, info = trade_env.step(action)
            if i == (len(trade_data.index.unique()) - 2):
                # print(env_test.render())
                **last_state = trade_env.render()**

        **df_last_state = pd.DataFrame({"last_state": last_state})**

wmmxk avatar May 14 '23 16:05 wmmxk

I had the same error, followed https://stackoverflow.com/questions/17839973/constructing-pandas-dataframe-from-values-in-variables-gives-valueerror-if-usi

and changed df_last_state = pd.DataFrame({"last_state": last_state}) to df_last_state = pd.DataFrame({"last_state": [last_state]})

But now I am getting other errors.

ShuningZhao avatar May 15 '23 11:05 ShuningZhao

I had the same error, followed https://stackoverflow.com/questions/17839973/constructing-pandas-dataframe-from-values-in-variables-gives-valueerror-if-usi

and changed df_last_state = pd.DataFrame({"last_state": last_state}) to df_last_state = pd.DataFrame({"last_state": [last_state]})

But now I am getting other errors.

I also tried this way and failed with a new error "TypeError: 'NoneType' object is not subscriptable", which actually originated from a last_state with a None value. Apparently the last_state shouldn't be a None value before it is assigned to previous_state (That's where I got the NoneType error), and a trick of wrapping last_state in a list won't help.

gz-d avatar May 26 '23 07:05 gz-d

I was running the example in the title, and run into this error "If using all scalar values, you must pass an index". The error traces back to the code below and it is because trade_env.render() in finrl.agents.stablebaselines3.models.py returns None. It seems that the version of the stablebaselines3 I installed is not correct. Has anyone run into a similar issue?

        for i in range(len(trade_data.index.unique())):
            action, _states = model.predict(trade_obs)
            trade_obs, rewards, dones, info = trade_env.step(action)
            if i == (len(trade_data.index.unique()) - 2):
                # print(env_test.render())
                **last_state = trade_env.render()**

        **df_last_state = pd.DataFrame({"last_state": last_state})**

Did you figure this out? Why you are saying the version of your stablebaselines3 is not correct?

gz-d avatar May 26 '23 07:05 gz-d

I ran into lot of issues with pip install similar to #284 issue. Resolved the issue using local install from that post and updating the different compatible versions in requirements.txt file. Now, I am running into the issue "If using all scalar values, you must pass an index". stablebaselines3 version is 2.1.0. Did you find a resolution to this issue?

raj016 avatar Sep 21 '23 01:09 raj016

Has someone figured out which version of stablebaseline3 is correct for the trade_env.render() to work?

wmmxk avatar May 18 '24 17:05 wmmxk