mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-12 15:26:54 +08:00
update 1min docs
This commit is contained in:
@@ -118,7 +118,12 @@ Also, users can install the latest dev version ``Qlib`` by the source code accor
|
|||||||
## Data Preparation
|
## Data Preparation
|
||||||
Load and prepare data by running the following code:
|
Load and prepare data by running the following code:
|
||||||
```bash
|
```bash
|
||||||
|
# get 1d data
|
||||||
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
|
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
|
||||||
|
|
||||||
|
# get 1min data
|
||||||
|
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data_1min --region cn --interval 1min
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This dataset is created by public data collected by [crawler scripts](scripts/data_collector/), which have been released in
|
This dataset is created by public data collected by [crawler scripts](scripts/data_collector/), which have been released in
|
||||||
|
|||||||
@@ -48,8 +48,12 @@ Qlib Format Dataset
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# download 1d
|
||||||
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
|
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn
|
||||||
|
|
||||||
|
# download 1min
|
||||||
|
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/qlib_cn_1min --region cn --interval 1min
|
||||||
|
|
||||||
In addition to China-Stock data, ``Qlib`` also includes a US-Stock dataset, which can be downloaded with the following command:
|
In addition to China-Stock data, ``Qlib`` also includes a US-Stock dataset, which can be downloaded with the following command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ class GetData:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _delete_qlib_data(file_dir: Path):
|
def _delete_qlib_data(file_dir: Path):
|
||||||
logger.info(f"delete {file_dir}")
|
|
||||||
rm_dirs = []
|
rm_dirs = []
|
||||||
for _name in ["features", "calendars", "instruments", "features_cache", "dataset_cache"]:
|
for _name in ["features", "calendars", "instruments", "features_cache", "dataset_cache"]:
|
||||||
_p = file_dir.joinpath(_name)
|
_p = file_dir.joinpath(_name)
|
||||||
@@ -133,7 +132,11 @@ class GetData:
|
|||||||
|
|
||||||
Examples
|
Examples
|
||||||
---------
|
---------
|
||||||
|
# get 1d data
|
||||||
python get_data.py qlib_data --name qlib_data --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
|
python get_data.py qlib_data --name qlib_data --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
|
||||||
|
|
||||||
|
# get 1min data
|
||||||
|
python get_data.py qlib_data --name qlib_data --target_dir ~/.qlib/qlib_data/cn_data_1min --interval 1min --region cn
|
||||||
-------
|
-------
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pip install -r requirements.txt
|
|||||||
|
|
||||||
### CN Data
|
### CN Data
|
||||||
|
|
||||||
#### 1d
|
#### 1d from yahoo
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
||||||
@@ -33,18 +33,26 @@ python collector.py normalize_data --source_dir ~/.qlib/stock_data/source/cn_1d
|
|||||||
|
|
||||||
# dump data
|
# dump data
|
||||||
cd qlib/scripts
|
cd qlib/scripts
|
||||||
python dump_bin.py dump_all --csv_path ~/.qlib/stock_data/source/cn_1d_nor --qlib_dir ~/.qlib/stock_data/source/qlib_cn_1d --freq day --exclude_fields date,adjclose,dividends,splits,symbol
|
python dump_bin.py dump_all --csv_path ~/.qlib/stock_data/source/cn_1d_nor --qlib_dir ~/.qlib/qlib_data/qlib_cn_1d --freq day --exclude_fields date,adjclose,dividends,splits,symbol
|
||||||
|
|
||||||
# using
|
|
||||||
import qlib
|
|
||||||
from qlib.data import D
|
|
||||||
|
|
||||||
qlib.init(provider_uri="~/.qlib/stock_data/source/qlib_cn_1d", region="CN")
|
|
||||||
df = D.features(D.instruments("all"), ["$close"], freq="day")
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 1min
|
### 1d from qlib
|
||||||
|
```bash
|
||||||
|
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/qlib_cn_1d --region cn
|
||||||
|
```
|
||||||
|
|
||||||
|
### using data
|
||||||
|
|
||||||
|
```python
|
||||||
|
import qlib
|
||||||
|
from qlib.data import D
|
||||||
|
|
||||||
|
qlib.init(provider_uri="~/.qlib/qlib_data/qlib_cn_1d", region="CN")
|
||||||
|
df = D.features(D.instruments("all"), ["$close"], freq="day")
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 1min from yahoo
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
||||||
@@ -56,20 +64,28 @@ python collector.py normalize_data --source_dir ~/.qlib/stock_data/source/cn_1mi
|
|||||||
|
|
||||||
# dump data
|
# dump data
|
||||||
cd qlib/scripts
|
cd qlib/scripts
|
||||||
python dump_bin.py dump_all --csv_path ~/.qlib/stock_data/source/cn_1min_nor --qlib_dir ~/.qlib/stock_data/source/qlib_cn_1min --freq 1min --exclude_fields date,adjclose,dividends,splits,symbol
|
python dump_bin.py dump_all --csv_path ~/.qlib/stock_data/source/cn_1min_nor --qlib_dir ~/.qlib/qlib_data/qlib_cn_1min --freq 1min --exclude_fields date,adjclose,dividends,splits,symbol
|
||||||
|
```
|
||||||
|
|
||||||
# using
|
### 1min from qlib
|
||||||
|
```bash
|
||||||
|
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/qlib_cn_1min --interval 1min --region cn
|
||||||
|
```
|
||||||
|
|
||||||
|
### using data
|
||||||
|
|
||||||
|
```python
|
||||||
import qlib
|
import qlib
|
||||||
from qlib.data import D
|
from qlib.data import D
|
||||||
|
|
||||||
qlib.init(provider_uri="~/.qlib/stock_data/source/qlib_cn_1min", region="CN")
|
qlib.init(provider_uri="~/.qlib/qlib_data/qlib_cn_1min", region="CN")
|
||||||
df = D.features(D.instruments("all"), ["$close"], freq="1min")
|
df = D.features(D.instruments("all"), ["$close"], freq="1min")
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### US Data
|
### US Data
|
||||||
|
|
||||||
#### 1d
|
#### 1d from yahoo
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
||||||
@@ -82,12 +98,22 @@ python collector.py normalize_data --source_dir ~/.qlib/stock_data/source/us_1d
|
|||||||
# dump data
|
# dump data
|
||||||
cd qlib/scripts
|
cd qlib/scripts
|
||||||
python dump_bin.py dump_all --csv_path ~/.qlib/stock_data/source/cn_1d_nor --qlib_dir ~/.qlib/stock_data/source/qlib_us_1d --freq day --exclude_fields date,adjclose,dividends,splits,symbol
|
python dump_bin.py dump_all --csv_path ~/.qlib/stock_data/source/cn_1d_nor --qlib_dir ~/.qlib/stock_data/source/qlib_us_1d --freq day --exclude_fields date,adjclose,dividends,splits,symbol
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 1d from qlib
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python scripts/get_data.py qlib_data --target_dir ~/.qlib/qlib_data/qlib_us_1d --region us
|
||||||
|
```
|
||||||
|
|
||||||
|
### using data
|
||||||
|
|
||||||
|
```python
|
||||||
# using
|
# using
|
||||||
import qlib
|
import qlib
|
||||||
from qlib.data import D
|
from qlib.data import D
|
||||||
|
|
||||||
qlib.init(provider_uri="~/.qlib/stock_data/source/qlib_us_1d", region="US")
|
qlib.init(provider_uri="~/.qlib/qlib_data/qlib_us_1d", region="US")
|
||||||
df = D.features(D.instruments("all"), ["$close"], freq="day")
|
df = D.features(D.instruments("all"), ["$close"], freq="day")
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user