mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-11 23:06:58 +08:00
Amend
This commit is contained in:
@@ -284,6 +284,32 @@ class NestedDataLoader(DataLoader):
|
|||||||
We have multiple DataLoader, we can use this class to combine them.
|
We have multiple DataLoader, we can use this class to combine them.
|
||||||
"""
|
"""
|
||||||
def __init__(self, dataloader_l: list[dict], join="left") -> None:
|
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__()
|
super().__init__()
|
||||||
self.data_loader_l = [(dl if isinstance(dl, DataLoader) else init_instance_by_config(dl)) for dl in dataloader_l]
|
self.data_loader_l = [(dl if isinstance(dl, DataLoader) else init_instance_by_config(dl)) for dl in dataloader_l]
|
||||||
self.join = join
|
self.join = join
|
||||||
|
|||||||
@@ -26,10 +26,13 @@ class TestDataLoader(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
# Of course you can use StaticDataLoader
|
||||||
|
|
||||||
nd.load
|
nd.load
|
||||||
...
|
...
|
||||||
|
|
||||||
|
# Then you can use it wth DataHandler;
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user