mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-14 16:26:55 +08:00
QLibDataHandlerClose is renamed to Alpha158
This commit is contained in:
@@ -183,7 +183,7 @@ Your PR of new Quant models is highly welcomed.
|
|||||||
# Quant Dataset Zoo
|
# Quant Dataset Zoo
|
||||||
Dataset plays a very important role in Quant. Here is a list of the datasets build on `Qlib`.
|
Dataset plays a very important role in Quant. Here is a list of the datasets build on `Qlib`.
|
||||||
- [Alpha360](./qlib/contrib/estimator/handler.py)
|
- [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`.
|
Here is a tutorial to build dataset with `Qlib`.
|
||||||
Your PR to build new Quant dataset is highly welcomed.
|
Your PR to build new Quant dataset is highly welcomed.
|
||||||
|
|||||||
@@ -207,14 +207,14 @@ Example
|
|||||||
|
|
||||||
Know more about how to run ``Data Handler`` with ``Estimator``, please refer to `Estimator: Workflow Management <estimator.html>`_
|
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>`_.
|
.. note:: Users need to initialize ``Qlib`` with `qlib.init` first, please refer to `initialization <../start/initialization.html>`_.
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: Python
|
.. code-block:: Python
|
||||||
|
|
||||||
from qlib.contrib.estimator.handler import QLibDataHandlerClose
|
from qlib.contrib.estimator.handler import Alpha158
|
||||||
from qlib.contrib.model.gbdt import LGBModel
|
from qlib.contrib.model.gbdt import LGBModel
|
||||||
|
|
||||||
DATA_HANDLER_CONFIG = {
|
DATA_HANDLER_CONFIG = {
|
||||||
@@ -233,7 +233,7 @@ Qlib provides implemented data handler `QLibDataHandlerClose`. The following exa
|
|||||||
"test_end_date": "2020-08-01",
|
"test_end_date": "2020-08-01",
|
||||||
}
|
}
|
||||||
|
|
||||||
exampleDataHandler = QLibDataHandlerClose(**DATA_HANDLER_CONFIG)
|
exampleDataHandler = Alpha158(**DATA_HANDLER_CONFIG)
|
||||||
|
|
||||||
# example of 'get_split_data'
|
# example of 'get_split_data'
|
||||||
x_train, y_train, x_validate, y_validate, x_test, y_test = exampleDataHandler.get_split_data(**TRAINER_CONFIG)
|
x_train, y_train, x_validate, y_validate, x_test, y_test = exampleDataHandler.get_split_data(**TRAINER_CONFIG)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ Below is a typical config file of ``Estimator``.
|
|||||||
num_leaves: 210
|
num_leaves: 210
|
||||||
num_threads: 20
|
num_threads: 20
|
||||||
data:
|
data:
|
||||||
class: QLibDataHandlerClose
|
class: Alpha158
|
||||||
args:
|
args:
|
||||||
dropna_label: True
|
dropna_label: True
|
||||||
filter:
|
filter:
|
||||||
@@ -291,7 +291,7 @@ Users can use the specified data handler by config as follows.
|
|||||||
.. code-block:: YAML
|
.. code-block:: YAML
|
||||||
|
|
||||||
data:
|
data:
|
||||||
class: QLibDataHandlerClose
|
class: Alpha158
|
||||||
args:
|
args:
|
||||||
start_date: 2005-01-01
|
start_date: 2005-01-01
|
||||||
end_date: 2018-04-30
|
end_date: 2018-04-30
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ Example
|
|||||||
- Run the following code to get the `prediction score` `pred_score`
|
- Run the following code to get the `prediction score` `pred_score`
|
||||||
.. code-block:: Python
|
.. code-block:: Python
|
||||||
|
|
||||||
from qlib.contrib.estimator.handler import QLibDataHandlerClose
|
from qlib.contrib.estimator.handler import Alpha158
|
||||||
from qlib.contrib.model.gbdt import LGBModel
|
from qlib.contrib.model.gbdt import LGBModel
|
||||||
|
|
||||||
DATA_HANDLER_CONFIG = {
|
DATA_HANDLER_CONFIG = {
|
||||||
@@ -140,7 +140,7 @@ Example
|
|||||||
"test_end_date": "2020-08-01",
|
"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
|
**DATA_HANDLER_CONFIG
|
||||||
).get_split_data(**TRAINER_CONFIG)
|
).get_split_data(**TRAINER_CONFIG)
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ Example
|
|||||||
pred_score = pd.DataFrame(index=_pred.index)
|
pred_score = pd.DataFrame(index=_pred.index)
|
||||||
pred_score["score"] = _pred.iloc(axis=1)[0]
|
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``.
|
Also, the above example has been given in ``examples/train_backtest_analyze.ipynb``.
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ model:
|
|||||||
num_leaves: 210
|
num_leaves: 210
|
||||||
num_threads: 20
|
num_threads: 20
|
||||||
data:
|
data:
|
||||||
class: QLibDataHandlerClose
|
class: Alpha158
|
||||||
args:
|
args:
|
||||||
dropna_label: True
|
dropna_label: True
|
||||||
filter:
|
filter:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ model:
|
|||||||
batch_size: 4096
|
batch_size: 4096
|
||||||
GPU: '0'
|
GPU: '0'
|
||||||
data:
|
data:
|
||||||
class: QLibDataHandlerClose
|
class: Alpha158
|
||||||
args:
|
args:
|
||||||
dropna_label: True
|
dropna_label: True
|
||||||
dropna_feature: True
|
dropna_feature: True
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import qlib
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from qlib.config import REG_CN
|
from qlib.config import REG_CN
|
||||||
from qlib.contrib.model.gbdt import LGBModel
|
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.strategy.strategy import TopkDropoutStrategy
|
||||||
from qlib.contrib.evaluate import (
|
from qlib.contrib.evaluate import (
|
||||||
backtest as normal_backtest,
|
backtest as normal_backtest,
|
||||||
@@ -54,7 +54,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# use default DataHandler
|
# use default DataHandler
|
||||||
# custom DataHandler, refer to: TODO: DataHandler API url
|
# 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
|
**DATA_HANDLER_CONFIG
|
||||||
).get_split_data(**TRAINER_CONFIG)
|
).get_split_data(**TRAINER_CONFIG)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"import pandas as pd\n",
|
"import pandas as pd\n",
|
||||||
"from qlib.config import REG_CN\n",
|
"from qlib.config import REG_CN\n",
|
||||||
"from qlib.contrib.model.gbdt import LGBModel\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.strategy.strategy import TopkDropoutStrategy\n",
|
||||||
"from qlib.contrib.evaluate import (\n",
|
"from qlib.contrib.evaluate import (\n",
|
||||||
" backtest as normal_backtest,\n",
|
" backtest as normal_backtest,\n",
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"# use default DataHandler\n",
|
"# use default DataHandler\n",
|
||||||
"# custom DataHandler, refer to: TODO: DataHandler api url\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",
|
||||||
"\n",
|
"\n",
|
||||||
"MODEL_CONFIG = {\n",
|
"MODEL_CONFIG = {\n",
|
||||||
|
|||||||
@@ -556,7 +556,7 @@ class QLibDataHandlerV1(ConfigQLibDataHandler):
|
|||||||
return df_labels
|
return df_labels
|
||||||
|
|
||||||
|
|
||||||
class QLibDataHandlerClose(QLibDataHandlerV1):
|
class Alpha158(QLibDataHandlerV1):
|
||||||
config_template = {
|
config_template = {
|
||||||
'kbar': {},
|
'kbar': {},
|
||||||
'price': {
|
'price': {
|
||||||
@@ -568,7 +568,7 @@ class QLibDataHandlerClose(QLibDataHandlerV1):
|
|||||||
|
|
||||||
def _init_kwargs(self, **kwargs):
|
def _init_kwargs(self, **kwargs):
|
||||||
kwargs['labels'] = ["Ref($close, -2)/Ref($close, -1) - 1"]
|
kwargs['labels'] = ["Ref($close, -2)/Ref($close, -1) - 1"]
|
||||||
super(QLibDataHandlerClose, self)._init_kwargs(**kwargs)
|
super(Alpha158, self)._init_kwargs(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
# if __name__ == '__main__':
|
# if __name__ == '__main__':
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import qlib
|
|||||||
from qlib.config import REG_CN
|
from qlib.config import REG_CN
|
||||||
from qlib.utils import drop_nan_by_y_index
|
from qlib.utils import drop_nan_by_y_index
|
||||||
from qlib.contrib.model.gbdt import LGBModel
|
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.strategy.strategy import TopkDropoutStrategy
|
||||||
from qlib.contrib.evaluate import (
|
from qlib.contrib.evaluate import (
|
||||||
backtest as normal_backtest,
|
backtest as normal_backtest,
|
||||||
@@ -79,7 +79,7 @@ def train():
|
|||||||
model performance
|
model performance
|
||||||
"""
|
"""
|
||||||
# get data
|
# 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
|
**DATA_HANDLER_CONFIG
|
||||||
).get_split_data(**TRAINER_CONFIG)
|
).get_split_data(**TRAINER_CONFIG)
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ QLIB_DIR.mkdir(exist_ok=True, parents=True)
|
|||||||
|
|
||||||
|
|
||||||
class TestDumpData(unittest.TestCase):
|
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))
|
QLIB_FIELDS = list(map(lambda x: f"${x}", FIELDS))
|
||||||
DUMP_DATA = None
|
DUMP_DATA = None
|
||||||
STOCK_NAMES = None
|
STOCK_NAMES = None
|
||||||
|
|||||||
Reference in New Issue
Block a user