From 8d76a99ee07dc33a0729489cbab5141e70c39d1a Mon Sep 17 00:00:00 2001 From: zhupr Date: Mon, 28 Sep 2020 15:29:04 +0800 Subject: [PATCH] QLibDataHandlerClose is renamed to Alpha158 --- README.md | 2 +- docs/component/data.rst | 6 +++--- docs/component/estimator.rst | 4 ++-- docs/component/model.rst | 6 +++--- examples/estimator/estimator_config.yaml | 2 +- examples/estimator/estimator_config_dnn.yaml | 2 +- examples/train_and_backtest.py | 4 ++-- examples/train_backtest_analyze.ipynb | 4 ++-- qlib/contrib/estimator/handler.py | 4 ++-- tests/test_all_pipeline.py | 4 ++-- tests/test_dump_data.py | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 42038e4d0..6554cb254 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ Your PR of new Quant models is highly welcomed. # Quant Dataset Zoo Dataset plays a very important role in Quant. Here is a list of the datasets build on `Qlib`. - [Alpha360](./qlib/contrib/estimator/handler.py) -- [QLibDataHandlerClose](./qlib/contrib/estimator/handler.py) +- [Alpha158](./qlib/contrib/estimator/handler.py) Here is a tutorial to build dataset with `Qlib`. Your PR to build new Quant dataset is highly welcomed. diff --git a/docs/component/data.rst b/docs/component/data.rst index 507d32af6..ebc2ce8ad 100644 --- a/docs/component/data.rst +++ b/docs/component/data.rst @@ -207,14 +207,14 @@ Example Know more about how to run ``Data Handler`` with ``Estimator``, please refer to `Estimator: Workflow Management `_ -Qlib provides implemented data handler `QLibDataHandlerClose`. The following example shows how to run `QLibDataHandlerV1` as a single module. +Qlib provides implemented data handler `Alpha158`. The following example shows how to run `QLibDataHandlerV1` as a single module. .. note:: Users need to initialize ``Qlib`` with `qlib.init` first, please refer to `initialization <../start/initialization.html>`_. .. code-block:: Python - from qlib.contrib.estimator.handler import QLibDataHandlerClose + from qlib.contrib.estimator.handler import Alpha158 from qlib.contrib.model.gbdt import LGBModel DATA_HANDLER_CONFIG = { @@ -233,7 +233,7 @@ Qlib provides implemented data handler `QLibDataHandlerClose`. The following exa "test_end_date": "2020-08-01", } - exampleDataHandler = QLibDataHandlerClose(**DATA_HANDLER_CONFIG) + exampleDataHandler = Alpha158(**DATA_HANDLER_CONFIG) # example of 'get_split_data' x_train, y_train, x_validate, y_validate, x_test, y_test = exampleDataHandler.get_split_data(**TRAINER_CONFIG) diff --git a/docs/component/estimator.rst b/docs/component/estimator.rst index 51f4251b9..39284448c 100644 --- a/docs/component/estimator.rst +++ b/docs/component/estimator.rst @@ -50,7 +50,7 @@ Below is a typical config file of ``Estimator``. num_leaves: 210 num_threads: 20 data: - class: QLibDataHandlerClose + class: Alpha158 args: dropna_label: True filter: @@ -291,7 +291,7 @@ Users can use the specified data handler by config as follows. .. code-block:: YAML data: - class: QLibDataHandlerClose + class: Alpha158 args: start_date: 2005-01-01 end_date: 2018-04-30 diff --git a/docs/component/model.rst b/docs/component/model.rst index 36a77b1ca..0cd375a24 100644 --- a/docs/component/model.rst +++ b/docs/component/model.rst @@ -121,7 +121,7 @@ Example - Run the following code to get the `prediction score` `pred_score` .. code-block:: Python - from qlib.contrib.estimator.handler import QLibDataHandlerClose + from qlib.contrib.estimator.handler import Alpha158 from qlib.contrib.model.gbdt import LGBModel DATA_HANDLER_CONFIG = { @@ -140,7 +140,7 @@ Example "test_end_date": "2020-08-01", } - x_train, y_train, x_validate, y_validate, x_test, y_test = QLibDataHandlerClose( + x_train, y_train, x_validate, y_validate, x_test, y_test = Alpha158( **DATA_HANDLER_CONFIG ).get_split_data(**TRAINER_CONFIG) @@ -163,7 +163,7 @@ Example pred_score = pd.DataFrame(index=_pred.index) pred_score["score"] = _pred.iloc(axis=1)[0] - .. note:: `QLibDataHandlerClose` is the data handler provided by ``Qlib``, please refer to `Data Handler `_. + .. note:: `Alpha158` is the data handler provided by ``Qlib``, please refer to `Data Handler `_. Also, the above example has been given in ``examples/train_backtest_analyze.ipynb``. diff --git a/examples/estimator/estimator_config.yaml b/examples/estimator/estimator_config.yaml index b0c73af09..7b532ca40 100644 --- a/examples/estimator/estimator_config.yaml +++ b/examples/estimator/estimator_config.yaml @@ -17,7 +17,7 @@ model: num_leaves: 210 num_threads: 20 data: - class: QLibDataHandlerClose + class: Alpha158 args: dropna_label: True filter: diff --git a/examples/estimator/estimator_config_dnn.yaml b/examples/estimator/estimator_config_dnn.yaml index 72f14f71f..9c0e85943 100644 --- a/examples/estimator/estimator_config_dnn.yaml +++ b/examples/estimator/estimator_config_dnn.yaml @@ -18,7 +18,7 @@ model: batch_size: 4096 GPU: '0' data: - class: QLibDataHandlerClose + class: Alpha158 args: dropna_label: True dropna_feature: True diff --git a/examples/train_and_backtest.py b/examples/train_and_backtest.py index db3fc7984..216d37592 100644 --- a/examples/train_and_backtest.py +++ b/examples/train_and_backtest.py @@ -8,7 +8,7 @@ import qlib import pandas as pd from qlib.config import REG_CN from qlib.contrib.model.gbdt import LGBModel -from qlib.contrib.estimator.handler import QLibDataHandlerClose +from qlib.contrib.estimator.handler import Alpha158 from qlib.contrib.strategy.strategy import TopkDropoutStrategy from qlib.contrib.evaluate import ( backtest as normal_backtest, @@ -54,7 +54,7 @@ if __name__ == "__main__": # use default DataHandler # custom DataHandler, refer to: TODO: DataHandler API url - x_train, y_train, x_validate, y_validate, x_test, y_test = QLibDataHandlerClose( + x_train, y_train, x_validate, y_validate, x_test, y_test = Alpha158( **DATA_HANDLER_CONFIG ).get_split_data(**TRAINER_CONFIG) diff --git a/examples/train_backtest_analyze.ipynb b/examples/train_backtest_analyze.ipynb index 6944ca617..fed729114 100644 --- a/examples/train_backtest_analyze.ipynb +++ b/examples/train_backtest_analyze.ipynb @@ -13,7 +13,7 @@ "import pandas as pd\n", "from qlib.config import REG_CN\n", "from qlib.contrib.model.gbdt import LGBModel\n", - "from qlib.contrib.estimator.handler import QLibDataHandlerClose\n", + "from qlib.contrib.estimator.handler import Alpha158\n", "from qlib.contrib.strategy.strategy import TopkDropoutStrategy\n", "from qlib.contrib.evaluate import (\n", " backtest as normal_backtest,\n", @@ -87,7 +87,7 @@ "\n", "# use default DataHandler\n", "# custom DataHandler, refer to: TODO: DataHandler api url\n", - "x_train, y_train, x_validate, y_validate, x_test, y_test = QLibDataHandlerClose(**DATA_HANDLER_CONFIG).get_split_data(**TRAINER_CONFIG)\n", + "x_train, y_train, x_validate, y_validate, x_test, y_test = Alpha158(**DATA_HANDLER_CONFIG).get_split_data(**TRAINER_CONFIG)\n", "\n", "\n", "MODEL_CONFIG = {\n", diff --git a/qlib/contrib/estimator/handler.py b/qlib/contrib/estimator/handler.py index 37f5c4c3c..1aee58a56 100644 --- a/qlib/contrib/estimator/handler.py +++ b/qlib/contrib/estimator/handler.py @@ -556,7 +556,7 @@ class QLibDataHandlerV1(ConfigQLibDataHandler): return df_labels -class QLibDataHandlerClose(QLibDataHandlerV1): +class Alpha158(QLibDataHandlerV1): config_template = { 'kbar': {}, 'price': { @@ -568,7 +568,7 @@ class QLibDataHandlerClose(QLibDataHandlerV1): def _init_kwargs(self, **kwargs): kwargs['labels'] = ["Ref($close, -2)/Ref($close, -1) - 1"] - super(QLibDataHandlerClose, self)._init_kwargs(**kwargs) + super(Alpha158, self)._init_kwargs(**kwargs) # if __name__ == '__main__': diff --git a/tests/test_all_pipeline.py b/tests/test_all_pipeline.py index d7d497301..b2f95bc26 100644 --- a/tests/test_all_pipeline.py +++ b/tests/test_all_pipeline.py @@ -13,7 +13,7 @@ import qlib from qlib.config import REG_CN from qlib.utils import drop_nan_by_y_index from qlib.contrib.model.gbdt import LGBModel -from qlib.contrib.estimator.handler import QLibDataHandlerClose +from qlib.contrib.estimator.handler import Alpha158 from qlib.contrib.strategy.strategy import TopkDropoutStrategy from qlib.contrib.evaluate import ( backtest as normal_backtest, @@ -79,7 +79,7 @@ def train(): model performance """ # get data - x_train, y_train, x_validate, y_validate, x_test, y_test = QLibDataHandlerClose( + x_train, y_train, x_validate, y_validate, x_test, y_test = Alpha158( **DATA_HANDLER_CONFIG ).get_split_data(**TRAINER_CONFIG) diff --git a/tests/test_dump_data.py b/tests/test_dump_data.py index 46cfbaadc..b3508dd07 100644 --- a/tests/test_dump_data.py +++ b/tests/test_dump_data.py @@ -25,7 +25,7 @@ QLIB_DIR.mkdir(exist_ok=True, parents=True) class TestDumpData(unittest.TestCase): - FIELDS = "open,close,high,low,volume,factor,change".split(",") + FIELDS = "open,close,high,low,volume".split(",") QLIB_FIELDS = list(map(lambda x: f"${x}", FIELDS)) DUMP_DATA = None STOCK_NAMES = None