mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-07 04:50:56 +08:00
fix bug
This commit is contained in:
@@ -123,7 +123,7 @@ class CalendarProvider(abc.ABC):
|
||||
H["c"][flag] = _calendar, _calendar_index
|
||||
return _calendar, _calendar_index
|
||||
|
||||
def get_calender_day(self, freq="day", future=False):
|
||||
def get_calendar_day(self, freq="day", future=False):
|
||||
flag = f"{freq}_future_{future}_day"
|
||||
if flag in H["c"]:
|
||||
_calendar, _calendar_index = H["c"][flag]
|
||||
|
||||
@@ -87,34 +87,16 @@ class DatasetH(Dataset):
|
||||
"""
|
||||
super().__init__(handler, segments)
|
||||
|
||||
def init(self, init_type: str = DataHandlerLP.IT_FIT_SEQ, enable_cache: bool = False):
|
||||
"""
|
||||
Initialize the data of Qlib
|
||||
def init(self, **kwargs):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
init_type : str
|
||||
- if `init_type` == DataHandlerLP.IT_FIT_SEQ:
|
||||
|
||||
the input of `DataHandlerLP.fit` will be the output of the previous processor
|
||||
|
||||
- if `init_type` == DataHandlerLP.IT_FIT_IND:
|
||||
|
||||
the input of `DataHandlerLP.fit` will be the original df
|
||||
|
||||
- if `init_type` == DataHandlerLP.IT_LS:
|
||||
|
||||
The state of the object has been load by pickle
|
||||
|
||||
enable_cache : bool
|
||||
default value is false:
|
||||
|
||||
- if `enable_cache` == True:
|
||||
|
||||
the processed data will be saved on disk, and handler will load the cached data from the disk directly
|
||||
when we call `init` next time
|
||||
"""
|
||||
self.handler.init(init_type=init_type, enable_cache=enable_cache)
|
||||
logger = get_module_logger("DatasetH")
|
||||
handler_init_kwargs = {}
|
||||
for arg_key, arg_value in kwargs.items():
|
||||
if arg_key in getfullargspec(self.handler.init).args:
|
||||
handler_init_kwargs[arg_key] = arg_value
|
||||
else:
|
||||
logger.info(f"init arguments[{arg_key}] is ignored.")
|
||||
self.handler.init(**handler_init_kwargs)
|
||||
|
||||
def setup_data(self, handler: Union[dict, DataHandler], segments: list):
|
||||
"""
|
||||
|
||||
@@ -433,6 +433,8 @@ class DataHandlerLP(DataHandler):
|
||||
except AttributeError:
|
||||
print("please set drop_raw = False if you want to use raw data")
|
||||
raise
|
||||
except:
|
||||
raise
|
||||
return df
|
||||
|
||||
def fetch(
|
||||
|
||||
@@ -147,7 +147,6 @@ class QlibDataLoader(DLWParser):
|
||||
"""
|
||||
self.filter_pipe = filter_pipe
|
||||
self.swap_level = swap_level
|
||||
print("swap level", swap_level)
|
||||
super().__init__(config)
|
||||
|
||||
def load_group_df(
|
||||
|
||||
@@ -17,11 +17,13 @@ from ..log import get_module_logger
|
||||
try:
|
||||
from ._libs.rolling import rolling_slope, rolling_rsquare, rolling_resi
|
||||
from ._libs.expanding import expanding_slope, expanding_rsquare, expanding_resi
|
||||
except ImportError as err:
|
||||
except ImportError:
|
||||
print(
|
||||
"#### Do not import qlib package in the repository directory in case of importing qlib from . without compiling #####"
|
||||
)
|
||||
raise
|
||||
except:
|
||||
raise
|
||||
|
||||
|
||||
np.seterr(invalid="ignore")
|
||||
@@ -1451,6 +1453,9 @@ class OpsWrapper(object):
|
||||
def __init__(self):
|
||||
self._ops = {}
|
||||
|
||||
def reset(self):
|
||||
self._ops = {}
|
||||
|
||||
def register(self, ops_list):
|
||||
for operator in ops_list:
|
||||
if not issubclass(operator, ExpressionOps):
|
||||
@@ -1469,12 +1474,15 @@ class OpsWrapper(object):
|
||||
|
||||
|
||||
Operators = OpsWrapper()
|
||||
Operators.register(OpsList)
|
||||
|
||||
|
||||
def register_custom_ops(C):
|
||||
"""register custom operator"""
|
||||
def register_all_ops(C):
|
||||
"""register all operator"""
|
||||
logger = get_module_logger("ops")
|
||||
|
||||
Operators.reset()
|
||||
Operators.register(OpsList)
|
||||
|
||||
if getattr(C, "custom_ops", None) is not None:
|
||||
Operators.register(C.custom_ops)
|
||||
logger.debug("register custom operator {}".format(C.custom_ops))
|
||||
|
||||
Reference in New Issue
Block a user