qlib icon indicating copy to clipboard operation
qlib copied to clipboard

使用features,报错ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-20: ordinal not in range(128)]

Open Liumh-01 opened this issue 1 year ago • 7 comments

❓ 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. ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-20: ordinal not in range(128)]

Liumh-01 avatar Dec 08 '24 18:12 Liumh-01

Hi, @Liumh-01 How can we reproduce your issue?

SunsetWolf avatar Dec 09 '24 05:12 SunsetWolf

@SunsetWolf Thanks for your reply import qlib from qlib.data import D qlib.init(provider_uri = "data/qlib_demo_data") all_code = D.list_instruments(D.instruments("all"),as_list=True) returns = D.features(instruments=all_code,fields=["$close/Ref($close,1)-1"],start_time='2023-02-01',end_time='2024-09-13',freq='day') print(returns) when instruments = one specific stock code,there is no problem,when i want to let instruments = more than one stock code,it will report errors:ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-20: ordinal not in range(128)]

Liumh-01 avatar Dec 09 '24 05:12 Liumh-01

Hi, @Liumh-01 We now understand your code, and it looks good. We would like to know what the data pointed to by the path data/qlib_demo_data in your code looks like.

SunsetWolf avatar Dec 09 '24 06:12 SunsetWolf

@SunsetWolf ,Hi, the path is created from following way: import qlib from qlib.tests.data import GetData data_uri = 'data/qlib_demo_data' qlib.init(provider_uri=data_uri, region="cn") GetData().qlib_data(target_dir=data_uri, region='cn') so,the data/qlib_demo_data is satisfied with the format that qlib required

Liumh-01 avatar Dec 09 '24 06:12 Liumh-01

Hi, @Liumh-01 , I didn't reproduce your problem, today I tried to run your code using a docker image and it is fine, you can try to pull and run the image and then run your code following the steps in the README.

SunsetWolf avatar Jan 02 '25 08:01 SunsetWolf

same problem, error occurred on win11

Guocode avatar Mar 30 '25 07:03 Guocode

same problem, error occurred on win11

@Liumh-01 I think it's because of joblib cannot parse chinese char of temp dir, you can manually change temp dir to normal path

Guocode avatar Apr 01 '25 15:04 Guocode