AI4Finance-Foundation / AI4Finance-Foundation/FinRL

Ensemble StockTrading ICAIF 2020 notebook not working

未關閉
#1,000 4 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Jupyter Notebook
星號
16.3k
分支
3.5k
PR 合併指標
30 天內沒有已合併 PR

描述

**Describe the bug**
A clear and concise description of what the bug is.
When running the ensemble trading strategy, the code raises a ValueError: "If using all scalar values, you must pass an index". This error occurs during the DataFrame construction in the last part of the code.

`ValueError Traceback (most recent call last)

in ()
----> 1 df_summary = ensemble_agent.run_ensemble_strategy(A2C_model_kwargs,
2 PPO_model_kwargs,
3 DDPG_model_kwargs,
4 timesteps_dict)

5 frames

/usr/local/lib/python3.10/site-packages/finrl/agents/stablebaselines3/models.py in run_ensemble_strategy(self, A2C_model_kwargs, PPO_model_kwargs, DDPG_model_kwargs, timesteps_dict)
666 )
667 # print("Used Model: ", model_ensemble)
--> 668 last_state_ensemble = self.DRL_prediction(
669 model=model_ensemble,
670 name="ensemble",

/usr/local/lib/python3.10/site-packages/finrl/agents/stablebaselines3/models.py in DRL_prediction(self, model, name, last_state, iter_num, turbulence_threshold, initial)
319 last_state = trade_env.render()
320
--> 321 df_last_state = pd.DataFrame({"last_state": last_state})
322 df_last_state.to_csv(f"results/last_state_{name}_{i}.csv", index=False)
323 return last_state

/usr/local/lib/python3.10/site-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
707 elif isinstance(data, dict):
708 # GH#38939 de facto copy defaults to False only in non-dict cases
--> 709 mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
710 elif isinstance(data, ma.MaskedArray):
711 from numpy.ma import mrecords

/usr/local/lib/python3.10/site-packages/pandas/core/internals/construction.py in dict_to_mgr(data, index, columns, dtype, typ, copy)
479 arrays = [x.copy() if hasattr(x, "dtype") else x for x in arrays]
480
--> 481 return arrays_to_mgr(arrays, columns, index, dtype=dtype, typ=typ, consolidate=copy)
482
483

/usr/local/lib/python3.10/site-packages/pandas/core/internals/construction.py in arrays_to_mgr(arrays, columns, index, dtype, verify_integrity, typ, consolidate)
113 # figure out the index, if necessary
114 if index is None:
--> 115 index = _extract_index(arrays)
116 else:
117 index = ensure_index(index)

/usr/local/lib/python3.10/site-packages/pandas/core/internals/construction.py in _extract_index(data)
643
644 if not indexes and not raw_lengths:
--> 645 raise ValueError("If using all scalar values, you must pass an index")
646
647 if have_series:

ValueError: If using all scalar values, you must pass an index`

`df_summary = ensemble_agent.run_ensemble_strategy(A2C_model_kwargs,
PPO_model_kwargs,
DDPG_model_kwargs,
timesteps_dict)`

**To Reproduce**
Steps to reproduce the behavior:
1. Open the FinRL_Ensemble_StockTrading_ICAIF_2020.ipynb
2. Run in Colab
3. Proceed to Part 6: Implement DRL Algorithms
4. Observe the ValueError during the execution.

**Expected behavior**
A clear and concise description of what you expected to happen.
The expected behavior is for the code to run without raising a ValueError and return a summary DataFrame containing information about the ensemble strategy's performance.

**Screenshots**

**Additional context**

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。