Skip to content

Fix find class bug #1601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions qlib/finco/tpl/sl/workflow_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data_handler_config: &data_handler_config
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
label: "Ref($close, -21) / Ref($close, -1) - 1"
infer_processors:
- class: RobustZScoreNorm
kwargs:
Expand Down
5 changes: 4 additions & 1 deletion qlib/utils/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ def find_all_classes(module_path: Union[str, ModuleType], cls: type) -> List[typ
>>> from qlib.data.dataset.handler import DataHandler
>>> find_all_classes("qlib.contrib.data.handler", DataHandler)
[<class 'qlib.contrib.data.handler.Alpha158'>, <class 'qlib.contrib.data.handler.Alpha158vwap'>, <class 'qlib.contrib.data.handler.Alpha360'>, <class 'qlib.contrib.data.handler.Alpha360vwap'>, <class 'qlib.data.dataset.handler.DataHandlerLP'>]
>>> from qlib.contrib.rolling.base import Rolling
>>> find_all_classes("qlib.contrib.rolling", Rolling)
[<class 'qlib.contrib.rolling.base.Rolling'>, <class 'qlib.contrib.rolling.ddgda.DDGDA'>]

TODO:
- skip import error
Expand All @@ -220,7 +223,7 @@ def find_all_classes(module_path: Union[str, ModuleType], cls: type) -> List[typ

def _append_cls(obj):
# Leverage the closure trick to reuse code
if isinstance(obj, type) and issubclass(obj, cls) and cls not in cls_list:
if isinstance(obj, type) and issubclass(obj, cls) and obj not in cls_list:
cls_list.append(obj)

for attr in dir(mod):
Expand Down