1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-03 11:00:57 +08:00

QLibDataHandlerClose is renamed to Alpha158

This commit is contained in:
zhupr
2020-09-28 15:29:04 +08:00
committed by you-n-g
parent 3c9f3acf79
commit 8d76a99ee0
11 changed files with 20 additions and 20 deletions

View File

@@ -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.

View File

@@ -207,14 +207,14 @@ Example
Know more about how to run ``Data Handler`` with ``Estimator``, please refer to `Estimator: Workflow Management <estimator.html>`_
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)

View File

@@ -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

View File

@@ -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 <data.html#data-handler>`_.
.. note:: `Alpha158` is the data handler provided by ``Qlib``, please refer to `Data Handler <data.html#data-handler>`_.
Also, the above example has been given in ``examples/train_backtest_analyze.ipynb``.

View File

@@ -17,7 +17,7 @@ model:
num_leaves: 210
num_threads: 20
data:
class: QLibDataHandlerClose
class: Alpha158
args:
dropna_label: True
filter:

View File

@@ -18,7 +18,7 @@ model:
batch_size: 4096
GPU: '0'
data:
class: QLibDataHandlerClose
class: Alpha158
args:
dropna_label: True
dropna_feature: True

View File

@@ -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)

View File

@@ -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",

View File

@@ -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__':

View File

@@ -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)

View File

@@ -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