get some error in example/rl_order_execution
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 48.7k
- Forks
- 7.7k
- PR merge metrics
- No merged PRs in 30d
Description
❓ Questions and Help
We sincerely suggest you to carefully read the documentation of our library as well as the official paper. After that, if you still feel puzzled, please describe the question clearly under this issue.
in examples/rl_order_execution/scripts/gen_training_orders.py, I got two error:
df["date"] = df["datetime"].dt.date.astype("datetime64")
this will throw
TypeError: Casting to unit-less dtype 'datetime64' is not supported. Pass e.g. 'datetime64[ns]' instead.
and after I fix this problem, got another one
order_all = pd.DataFrame(df.groupby(level=(2, 0), group_keys=False).mean().dropna())
IndexError: Too many levels: Index has only 2 levels, not 3
and I change this code to
order_all = pd.DataFrame(df.groupby(level=(1, 0), group_keys=False).mean().dropna())
when traing model, get this error
Traceback (most recent call last):
File "/opt/anaconda3/envs/qlib38/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/anaconda3/envs/qlib38/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/opt/anaconda3/envs/qlib38/lib/python3.8/site-packages/qlib/rl/utils/data_queue.py", line 181, in _producer
for data in dataloader:
File "/opt/anaconda3/envs/qlib38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 521, in __next__
data = self._next_data()
File "/opt/anaconda3/envs/qlib38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 561, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/opt/anaconda3/envs/qlib38/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 46, in fetch
data = self.dataset[possibly_batched_index]
File "/opt/anaconda3/envs/qlib38/lib/python3.8/site-packages/qlib/rl/contrib/train_onpolicy.py", line 80, in __getitem__
stock_id=row["instrument"],
File "/opt/anaconda3/envs/qlib38/lib/python3.8/site-packages/pandas/core/series.py", line 1007, in __getitem__
return self._get_value(key)
File "/opt/anaconda3/envs/qlib38/lib/python3.8/site-packages/pandas/core/series.py", line 1116, in _get_value
loc = self.index.get_loc(label)
File "/opt/anaconda3/envs/qlib38/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3655, in get_loc
raise KeyError(key) from err
KeyError: 'instrument'
So how can we get this example run?
Env
- python 3.8
- qlib 0.9.7
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failures in examples/rl_order_execution/scripts/gen_training_orders.py with the reported Python and qlib versions. Inspect the dataframe index levels and columns around the date conversion, groupby, and train_onpolicy data loading. Done means the example completes training without the reported datetime, index-level, or missing-instrument errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100