mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-06 04:20:57 +08:00
fix the type of filter_pipe
This commit is contained in:
@@ -211,13 +211,23 @@ class InstrumentProvider(abc.ABC, ProviderBackendMixin):
|
||||
'filter_start_time': None,
|
||||
'filter_end_time': None}]}
|
||||
"""
|
||||
from .filter import SeriesDFilter
|
||||
|
||||
if filter_pipe is None:
|
||||
filter_pipe = []
|
||||
config = {"market": market, "filter_pipe": []}
|
||||
# the order of the filters will affect the result, so we need to keep
|
||||
# the order
|
||||
for filter_t in filter_pipe:
|
||||
config["filter_pipe"].append(filter_t.to_config())
|
||||
if isinstance(filter_t, dict):
|
||||
_config = filter_t
|
||||
elif isinstance(filter_t, SeriesDFilter):
|
||||
_config = filter_t.to_config()
|
||||
else:
|
||||
raise TypeError(
|
||||
f"Unsupported filter types: {type(filter_t)}! Filter only supports dict or isinstance(filter, SeriesDFilter)"
|
||||
)
|
||||
config["filter_pipe"].append(_config)
|
||||
return config
|
||||
|
||||
@abc.abstractmethod
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
import os
|
||||
import abc
|
||||
import warnings
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from typing import Tuple, Union, List, Type
|
||||
from typing import Tuple, Union, List
|
||||
|
||||
from qlib.data import D
|
||||
from qlib.data import filter as filter_module
|
||||
from qlib.data.filter import BaseDFilter
|
||||
from qlib.utils import load_dataset, init_instance_by_config, time_to_slc_point, get_callable_kwargs
|
||||
from qlib.utils import load_dataset, init_instance_by_config, time_to_slc_point
|
||||
from qlib.log import get_module_logger
|
||||
|
||||
|
||||
@@ -173,13 +169,6 @@ class QlibDataLoader(DLWParser):
|
||||
inst_processor: dict
|
||||
If inst_processor is not None and type(config) == dict; load config[<group_name>] data using inst_processor[<group_name>]
|
||||
"""
|
||||
if filter_pipe is not None:
|
||||
assert isinstance(filter_pipe, list), "The type of `filter_pipe` must be list."
|
||||
filter_pipe = [
|
||||
init_instance_by_config(fp, None if "module_path" in fp else filter_module, accept_types=BaseDFilter)
|
||||
for fp in filter_pipe
|
||||
]
|
||||
|
||||
self.filter_pipe = filter_pipe
|
||||
self.swap_level = swap_level
|
||||
self.freq = freq
|
||||
|
||||
Reference in New Issue
Block a user