1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-18 01:44:34 +08:00

add data loder test

This commit is contained in:
Linlang
2024-07-04 20:43:41 +08:00
parent ce596f9dfa
commit 3f86171051
4 changed files with 47 additions and 27 deletions

View File

@@ -90,7 +90,6 @@ class Alpha360(DataHandlerLP):
return ["Ref($close, -2)/Ref($close, -1) - 1"], ["LABEL0"]
class Alpha360vwap(Alpha360):
def get_label_config(self):
return ["Ref($vwap, -2)/Ref($vwap, -1) - 1"], ["LABEL0"]
@@ -154,7 +153,6 @@ class Alpha158(DataHandlerLP):
return ["Ref($close, -2)/Ref($close, -1) - 1"], ["LABEL0"]
class Alpha158vwap(Alpha158):
def get_label_config(self):
return ["Ref($vwap, -2)/Ref($vwap, -1) - 1"], ["LABEL0"]

View File

@@ -1,11 +1,12 @@
from qlib.data.dataset.loader import DataLoader, QlibDataLoader
class Alpha360DL(QlibDataLoader):
"""Dataloader to get Alpha360"""
def __init__(self, config=None, **kwargs):
_config = {
"feature":self.get_feature_config(),
"feature": self.get_feature_config(),
}
if config is not None:
_config.update(config)
@@ -59,23 +60,26 @@ class Alpha360DL(QlibDataLoader):
class Alpha158DL(QlibDataLoader):
"""Dataloader to get Alpha158"""
def __init__(self, config=None, **kwargs):
_config = {
"feature":self.get_feature_config(),
"feature": self.get_feature_config(),
}
if config is not None:
_config.update(config)
super().__init__(config=_config, **kwargs)
@staticmethod
def get_feature_config(config={
def get_feature_config(
config={
"kbar": {},
"price": {
"windows": [0],
"feature": ["OPEN", "HIGH", "LOW", "VWAP"],
},
"rolling": {},
}):
}
):
"""create factors from config
config = {
@@ -304,4 +308,3 @@ class Alpha158DL(QlibDataLoader):
names += ["VSUMD%d" % d for d in windows]
return fields, names