From 0591fcbb10b6c3a7394552f45885329d78dd9772 Mon Sep 17 00:00:00 2001 From: D-X-Y <280835372@qq.com> Date: Wed, 3 Mar 2021 13:18:45 +0800 Subject: [PATCH] Update submodule --- .gitmodules | 2 +- .latent-data/init-configs/README.md | 5 + .latent-data/init-configs/bashrc | 3 + notebooks/Q/workflow-test.ipynb | 148 ++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 notebooks/Q/workflow-test.ipynb diff --git a/.gitmodules b/.gitmodules index e8aba82..09d12b9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule ".latent-data/qlib"] path = .latent-data/qlib - url = git@github.com:microsoft/qlib.git + url = git@github.com:D-X-Y/qlib.git diff --git a/.latent-data/init-configs/README.md b/.latent-data/init-configs/README.md index 00c8090..028e821 100644 --- a/.latent-data/init-configs/README.md +++ b/.latent-data/init-configs/README.md @@ -7,3 +7,8 @@ git submodule init git submodule update git pull orign main ``` + +Pylint check for Q-lib: +``` +python -m black __init__.py -l 120 +``` diff --git a/.latent-data/init-configs/bashrc b/.latent-data/init-configs/bashrc index b431eb3..ddfcf5e 100644 --- a/.latent-data/init-configs/bashrc +++ b/.latent-data/init-configs/bashrc @@ -92,6 +92,9 @@ alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' +# Change the Color +PS1='\[\e[1;35m\][\[\e[1;33m\]\u@\h \[\e[1;31m\]\w\[\e[1;35m\]]\[\e[1;36m\]\$ \[\e[0m\]' + # Add an "alert" alias for long running commands. Use like so: # sleep 10; alert alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' diff --git a/notebooks/Q/workflow-test.ipynb b/notebooks/Q/workflow-test.ipynb new file mode 100644 index 0000000..a48fb0c --- /dev/null +++ b/notebooks/Q/workflow-test.ipynb @@ -0,0 +1,148 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "[95290:MainThread](2021-03-03 12:14:32,922) INFO - qlib.Initialization - [config.py:276] - default_conf: client.\n", + "[95290:MainThread](2021-03-03 12:14:32,925) WARNING - qlib.Initialization - [config.py:291] - redis connection failed(host=127.0.0.1 port=6379), cache will not be used!\n", + "[95290:MainThread](2021-03-03 12:14:33,203) INFO - qlib.Initialization - [__init__.py:46] - qlib successfully initialized based on client settings.\n", + "[95290:MainThread](2021-03-03 12:14:33,205) INFO - qlib.Initialization - [__init__.py:47] - data_path=/Users/xuanyidong/.qlib/qlib_data/cn_data\n" + ] + } + ], + "source": [ + "import os\n", + "import sys\n", + "import qlib\n", + "import pprint\n", + "import numpy as np\n", + "import pandas as pd\n", + "\n", + "from qlib import config as qconfig\n", + "from qlib.utils import init_instance_by_config\n", + "\n", + "qlib.init(provider_uri='~/.qlib/qlib_data/cn_data', region=qconfig.REG_CN)\n", + "\n", + "dataset_config = {\n", + " \"class\": \"DatasetH\",\n", + " \"module_path\": \"qlib.data.dataset\",\n", + " \"kwargs\": {\n", + " \"handler\": {\n", + " \"class\": \"Alpha158\",\n", + " \"module_path\": \"qlib.contrib.data.handler\",\n", + " \"kwargs\": {\n", + " \"start_time\": \"2008-01-01\",\n", + " \"end_time\": \"2020-08-01\",\n", + " \"fit_start_time\": \"2008-01-01\",\n", + " \"fit_end_time\": \"2014-12-31\",\n", + " \"instruments\": \"csi300\",\n", + " },\n", + " },\n", + " \"segments\": {\n", + " \"train\": (\"2008-01-01\", \"2014-12-31\"),\n", + " \"valid\": (\"2015-01-01\", \"2016-12-31\"),\n", + " \"test\": (\"2017-01-01\", \"2020-08-01\"),\n", + " },\n", + " },\n", + " }" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'class': 'DatasetH',\n", + " 'kwargs': {'handler': {'class': 'Alpha158',\n", + " 'kwargs': {'end_time': '2020-08-01',\n", + " 'fit_end_time': '2014-12-31',\n", + " 'fit_start_time': '2008-01-01',\n", + " 'instruments': 'csi300',\n", + " 'start_time': '2008-01-01'},\n", + " 'module_path': 'qlib.contrib.data.handler'},\n", + " 'segments': {'test': ('2017-01-01', '2020-08-01'),\n", + " 'train': ('2008-01-01', '2014-12-31'),\n", + " 'valid': ('2015-01-01', '2016-12-31')}},\n", + " 'module_path': 'qlib.data.dataset'}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "[95290:MainThread](2021-03-03 12:18:43,481) INFO - qlib.timer - [log.py:81] - Time cost: 237.911s | Loading data Done\n", + "[95290:MainThread](2021-03-03 12:18:45,080) INFO - qlib.timer - [log.py:81] - Time cost: 0.465s | DropnaLabel Done\n", + "[95290:MainThread](2021-03-03 12:18:51,572) INFO - qlib.timer - [log.py:81] - Time cost: 6.491s | CSZScoreNorm Done\n", + "[95290:MainThread](2021-03-03 12:18:51,573) INFO - qlib.timer - [log.py:81] - Time cost: 8.090s | fit & process data Done\n", + "[95290:MainThread](2021-03-03 12:18:51,573) INFO - qlib.timer - [log.py:81] - Time cost: 246.003s | Init data Done\n" + ] + } + ], + "source": [ + "pprint.pprint(dataset_config)\n", + "dataset = init_instance_by_config(dataset_config)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'class': 'MLflowExpManager', 'module_path': 'qlib.workflow.expm', 'kwargs': {'uri': 'file:/Users/xuanyidong/Desktop/AutoDL-Projects/notebooks/Q/mlruns', 'default_exp_name': 'Experiment'}}\n", + "Wrapper(provider=)\n", + "\n" + ] + } + ], + "source": [ + "from qlib.workflow import R\n", + "from qlib.config import C\n", + "print(C.exp_manager)\n", + "print(R)\n", + "print(R.exp_manager)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}