Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error when running examples /FinRL_Ensemble_StockTrading_ICAIF_2020.ipynb #294

Open
wmmxk opened this issue May 14, 2023 · 5 comments
Open
Labels
bug Something isn't working

Comments

@wmmxk
Copy link

wmmxk commented May 14, 2023

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})**
@YangletLiu YangletLiu added the bug Something isn't working label May 14, 2023
@ShuningZhao
Copy link

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.

@gz-d
Copy link

gz-d commented May 26, 2023

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
Copy link

gz-d commented May 26, 2023

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?

@raj016
Copy link

raj016 commented Sep 21, 2023

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?

@wmmxk
Copy link
Author

wmmxk commented May 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants