1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-06-06 14:01:28 +08:00
This commit is contained in:
Young
2024-07-04 10:17:52 +00:00
parent 13768d1dac
commit ce596f9dfa
2 changed files with 29 additions and 0 deletions

View File

@@ -284,6 +284,32 @@ class NestedDataLoader(DataLoader):
We have multiple DataLoader, we can use this class to combine them.
"""
def __init__(self, dataloader_l: list[dict], join="left") -> None:
"""
Parameters
----------
dataloader_l : list[dict]
A list of dataloader, for exmaple
.. code-block:: python
nd = NestedDataLoader(
dataloader_l=[
{
"class": "qlib.contrib.data.loader.Alpha158DL",
}, {
"class": "qlib.contrib.data.loader.Alpha360DL",
"kwargs": {
"config": {
"label": ( ["Ref($close, -2)/Ref($close, -1) - 1"], ["LABEL0"])
}
}
}
]
)
join :
it will pass to pd.concat when merging it.
"""
super().__init__()
self.data_loader_l = [(dl if isinstance(dl, DataLoader) else init_instance_by_config(dl)) for dl in dataloader_l]
self.join = join

View File

@@ -26,10 +26,13 @@ class TestDataLoader(unittest.TestCase):
}
]
)
# Of course you can use StaticDataLoader
nd.load
...
# Then you can use it wth DataHandler;
if __name__ == "__main__":
unittest.main()