请问,计算指标通过expression filter筛选调出功能如何实现?(貌似现在只有raw data 通过D.instrument才可以调出,计算指标只有通过fetch筛选时间、股票名称),然后再用df的普通方法筛选,效率低。
from qlib.data.filter import ExpressionDFilter
filters = [
ExpressionDFilter("Mean(Ref($close, 1)/$close - 1, 30) > 0.01"),
]
inst = D.instruments("all", filter_pipe=filters)
df = D.features(inst, ["$close", "$volume"])
import qlib
from qlib.data import D
qlib.init(provider_uri ='C:/stockbase/Astocks')
instruments = ['sh600030', 'sh600000']
fields = ['$preclose']
features_df = D.features(instruments, fields, start_time='2016-12-08', end_time='2016-12-18', freq='day')
File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Users\kinger.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy__main.py", line 45, in <module>
cli.main()
File "c:\Users\kinger.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\kinger.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("main"))
File "C:\Python39\lib\runpy.py", line 268, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Python39\lib\site-packages\qlib\data\data.py", line 1036, in features
return DatasetD.dataset(instruments, fields, start_time, end_time, freq, inst_processors=inst_processors)
File "C:\Python39\lib\site-packages\qlib\data\data.py", line 771, in dataset
data = self.dataset_processor(
File "C:\Python39\lib\site-packages\qlib\data\data.py", line 554, in dataset_processor
ParallelExt(n_jobs=workers, backend=C.joblib_backend, maxtasksperchild=C.maxtasksperchild)(task_l),
File "C:\Python39\lib\site-packages\joblib\parallel.py", line 966, in call
n_jobs = self._initialize_backend()
File "C:\Python39\lib\site-packages\joblib\parallel.py", line 733, in _initialize_backend
n_jobs = self._backend.configure(n_jobs=self.n_jobs, parallel=self,
File "C:\Python39\lib\site-packages\joblib_parallel_backends.py", line 470, in configure
self._pool = MemmappingPool(n_jobs, **memmappingpool_args)
File "C:\Python39\lib\site-packages\joblib\pool.py", line 303, in init
manager = TemporaryResourcesManager(temp_folder)
File "C:\Python39\lib\site-packages\joblib_memmapping_reducer.py", line 531, in init
self.set_current_context(context_id)
File "C:\Python39\lib\site-packages\joblib_memmapping_reducer.py", line 535, in set_current_context
self.register_new_context(context_id)
File "C:\Python39\lib\site-packages\joblib_memmapping_reducer.py", line 560, in register_new_context
self.register_folder_finalizer(new_folder_path, context_id)
File "C:\Python39\lib\site-packages\joblib_memmapping_reducer.py", line 590, in register_folder_finalizer
resource_tracker.register(pool_subfolder, "folder")
File "C:\Python39\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 191, in register
self._send('REGISTER', name, rtype)
File "C:\Python39\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 204, in _send
msg = '{0}:{1}:{2}\n'.format(cmd, name, rtype).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-19: ordinal not in range(128)
Exception ignored in: <function Pool.del at 0x00000245E12561F0>
Traceback (most recent call last):
File "C:\Python39\lib\multiprocessing\pool.py", line 264, in del__
if self._state == RUN:
AttributeError: 'MemmappingPool' object has no attribute '_state'
qlib初始化是正常的,单个股票也是能读取数据的,但是当读取多个股票时就报错,问题可能处在哪里?
import qlib
from qlib.data import D
qlib.init_from_yaml_conf("qlib_clinet_config.yaml")
D.calendar(start_time='2010-01-01', end_time='2021-12-30', freq='day') # 报类型错误异常
Newbie here!
Dumb question ;-;
I’m running the google colab example using the LGBModel. And I’ve obtained as a result several charts as presented in the documentation, but I couldn’t fully understand the results collected. For this first chart, sent above, I’ve two doubts.
1) According to the documentation, "cum return wo cost” stands for "Cumulative returns series of portfolio without cost”, but what is this “cost”? The cost to purchase the stock?
2) The orange and green charts are the cumulative returns series created using the LGBModel? Therefore, the idea of this chart is to compare the portfolio created with LGBModel to the benchmark represented in blue?