AI4Finance-Foundation/ElegantRL

已经下载好'./China_A_shares.pandas.dataframe',无法加载'./China_A_shares.pandas.dataframe',出现报错UnpicklingError

Closed this issue · 0 comments

执行 demo_FinRL_ElegantRL_China_A_shares.ipynb里面的代码

from demo_FinRL_ElegantRL_China_A_shares import StockTradingEnv
from demo_FinRL_ElegantRL_China_A_shares import check_env

check_env()
报错:


UnpicklingError Traceback (most recent call last)
Cell In[2], line 4
1 from demo_FinRL_ElegantRL_China_A_shares import StockTradingEnv
2 from demo_FinRL_ElegantRL_China_A_shares import check_env
----> 4 check_env()

File ~/autodl-tmp/finbigmodel/ElegantRL/examples/demo_FinRL_ElegantRL_China_A_shares.py:146, in check_env()
145 def check_env():
--> 146 env = StockTradingEnv(beg_idx=834, end_idx=1113)
147 env.if_random_reset = False
148 evaluate_time = 4

File ~/autodl-tmp/finbigmodel/ElegantRL/examples/demo_FinRL_ElegantRL_China_A_shares.py:24, in StockTradingEnv.init(self, initial_amount, max_stock, buy_cost_pct, sell_cost_pct, gamma, beg_idx, end_idx)
21 self.df_pwd = './China_A_shares.pandas.dataframe'
22 self.npz_pwd = './China_A_shares.numpy.npz'
---> 24 self.close_ary, self.tech_ary = self.load_data_from_disk()
25 self.close_ary = self.close_ary[beg_idx:end_idx]
26 self.tech_ary = self.tech_ary[beg_idx:end_idx]

File ~/autodl-tmp/finbigmodel/ElegantRL/examples/demo_FinRL_ElegantRL_China_A_shares.py:119, in StockTradingEnv.load_data_from_disk(self, tech_id_list)
117 tech_ary = ary_dict['tech_ary']
118 elif os.path.exists(self.df_pwd): # convert pandas.DataFrame to numpy.array
--> 119 df = pd.read_pickle(self.df_pwd) #, 'xz', 'gzip'
121 tech_ary = []
122 close_ary = []

File ~/miniconda3/lib/python3.8/site-packages/pandas/io/pickle.py:196, in read_pickle(filepath_or_buffer, compression, storage_options)
193 with warnings.catch_warnings(record=True):
194 # We want to silence any warnings about, e.g. moved modules.
195 warnings.simplefilter("ignore", Warning)
--> 196 return pickle.load(handles.handle)
197 except excs_to_catch:
198 # e.g.
199 # "No module named 'pandas.core.sparse.series'"
200 # "Can't get attribute '__nat_unpickle' on <module 'pandas._libs.tslib"
201 return pc.load(handles.handle, encoding=None)

UnpicklingError: invalid load key, '{'.