AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
10.09k stars 2.43k forks source link

Error in FinRL for Quantitative Finance for multiple stocks, Missing parameters in DRLAgent.DRL_prediction, which are test_data and test_obs #112

Closed Mostafasaeed29 closed 2 years ago

Mostafasaeed29 commented 3 years ago

trade = data_split(processed_full, '2019-01-01','2021-01-01') e_trade_gym = StockTradingEnv(df = trade, turbulence_threshold = 380, **env_kwargs)

df_account_value, df_actions = DRLAgent.DRL_prediction( model=model_sac, environment = e_trade_gym)

xjdbie96 commented 3 years ago

in env_stocktrading.py in line 354 def save_action_memory(self): if len(self.df.tic.unique())>1:

date and close price length must match actions length

        date_list = self.date_memory[:-1]
        df_date = pd.DataFrame(date_list)
        df_date.columns = ['date']

        action_list = self.actions_memory
        df_actions = pd.DataFrame(action_list)
        df_actions.columns = self.data.tic.values
        df_actions.index = df_date.date
        #df_actions = pd.DataFrame({'date':date_list,'actions':action_list})
    else:
        date_list = self.date_memory[:-1]
        action_list = self.actions_memory
        df_actions = pd.DataFrame({'date':date_list,'actions':action_list})
    return df_actions

date_list in fact is a empty list so here df_date.columns = ['date'] will cause error I have not solve this error, I think this error is cause by the pandas version. @louisowen6 can I see your pip list?

louisowen6 commented 3 years ago

Hi @xjdbie96, I'm using the requirements.txt from the docker folder

xjdbie96 commented 3 years ago

ok,pandas version is the same.I have used earlier version for FinRL .the earlier version can work.but after update,the trade code appear error for below: trade = data_split(processed_full, '2019-01-01','2021-01-01') e_trade_gym = StockTradingEnv(df = trade, turbulence_threshold = 380, **env_kwargs)

df_account_value, df_actions = DRLAgent.DRL_prediction( model=model_sac, environment = e_trade_gym)

I try to understand the code and I still work on it to fix the problem . @louisowen6