Skip to content

Commit 184ce34

Browse files
authored
[807] Move the REG_CONSTANT/EPS to constant.py. (#811)
* [807] Move the REG_CONSTANT to constant.py. * import REG_US. * Move EPS to constant.py.
1 parent 382abab commit 184ce34

File tree

26 files changed

+42
-35
lines changed

26 files changed

+42
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ We recommend users to prepare their own data if they have a high-quality dataset
195195
```python
196196
import qlib
197197
from qlib.data import D
198-
from qlib.config import REG_CN
198+
from qlib.constant import REG_CN
199199
200200
# Initialization
201201
mount_path = "~/.qlib/qlib_data/cn_data" # target_dir

docs/component/data.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ The `trade unit` defines the unit number of stocks can be used in a trade, and t
219219

220220
.. code-block:: python
221221
222-
from qlib.config import REG_CN
222+
from qlib.constant import REG_CN
223223
qlib.init(provider_uri='~/.qlib/qlib_data/cn_data', region=REG_CN)
224224
225225

docs/start/initialization.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Initialize Qlib before calling other APIs: run following code in python.
2727
2828
import qlib
2929
# region in [REG_CN, REG_US]
30-
from qlib.config import REG_CN
30+
from qlib.constant import REG_CN
3131
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir
3232
qlib.init(provider_uri=provider_uri, region=REG_CN)
3333
@@ -42,10 +42,10 @@ Besides `provider_uri` and `region`, `qlib.init` has other parameters. The follo
4242
- `provider_uri`
4343
Type: str. The URI of the Qlib data. For example, it could be the location where the data loaded by ``get_data.py`` are stored.
4444
- `region`
45-
Type: str, optional parameter(default: `qlib.config.REG_CN`).
46-
Currently: ``qlib.config.REG_US`` ('us') and ``qlib.config.REG_CN`` ('cn') is supported. Different value of `region` will result in different stock market mode.
47-
- ``qlib.config.REG_US``: US stock market.
48-
- ``qlib.config.REG_CN``: China stock market.
45+
Type: str, optional parameter(default: `qlib.constant.REG_CN`).
46+
Currently: ``qlib.constant.REG_US`` ('us') and ``qlib.constant.REG_CN`` ('cn') is supported. Different value of `region` will result in different stock market mode.
47+
- ``qlib.constant.REG_US``: US stock market.
48+
- ``qlib.constant.REG_CN``: China stock market.
4949

5050
Different modes will result in different trading limitations and costs.
5151
The region is just `shortcuts for defining a batch of configurations <https://github.com/microsoft/qlib/blob/main/qlib/config.py#L239>`_. Users can set the key configurations manually if the existing region setting can't meet their requirements.

examples/highfreq/highfreq_processor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
import pandas as pd
3+
from qlib.constant import EPS
34
from qlib.data.dataset.processor import Processor
45
from qlib.data.dataset.utils import fetch_df_by_index
56

@@ -27,7 +28,7 @@ def fit(self, df_features):
2728
part_values = np.log1p(part_values)
2829
self.feature_med[name] = np.nanmedian(part_values)
2930
part_values = part_values - self.feature_med[name]
30-
self.feature_std[name] = np.nanmedian(np.absolute(part_values)) * 1.4826 + 1e-12
31+
self.feature_std[name] = np.nanmedian(np.absolute(part_values)) * 1.4826 + EPS
3132
part_values = part_values / self.feature_std[name]
3233
self.feature_vmax[name] = np.nanmax(part_values)
3334
self.feature_vmin[name] = np.nanmin(part_values)

examples/highfreq/workflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import qlib
77
import pickle
8-
from qlib.config import REG_CN, HIGH_FREQ_CONFIG
8+
from qlib.constant import REG_CN
9+
from qlib.config import HIGH_FREQ_CONFIG
910

1011
from qlib.utils import init_instance_by_config
1112
from qlib.data.dataset.handler import DataHandlerLP

examples/hyperparameter/LightGBM/hyperparameter_158.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import qlib
22
import optuna
3-
from qlib.config import REG_CN
3+
from qlib.constant import REG_CN
44
from qlib.utils import init_instance_by_config
55
from qlib.tests.config import CSI300_DATASET_CONFIG
66
from qlib.tests.data import GetData

examples/hyperparameter/LightGBM/hyperparameter_360.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import qlib
22
import optuna
3-
from qlib.config import REG_CN
3+
from qlib.constant import REG_CN
44
from qlib.utils import init_instance_by_config
55
from qlib.tests.data import GetData
66
from qlib.tests.config import get_dataset_config, CSI300_MARKET, DATASET_ALPHA360_CLASS

examples/model_interpreter/feature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
import qlib
6-
from qlib.config import REG_CN
6+
from qlib.constant import REG_CN
77

88
from qlib.utils import init_instance_by_config
99
from qlib.tests.data import GetData

examples/model_rolling/task_manager_rolling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import fire
1313
import qlib
14-
from qlib.config import REG_CN
14+
from qlib.constant import REG_CN
1515
from qlib.workflow import R
1616
from qlib.workflow.task.gen import RollingGen, task_generator
1717
from qlib.workflow.task.manage import TaskManager, run_task

examples/nested_decision_execution/workflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
import qlib
101101
import fire
102102
import pandas as pd
103-
from qlib.config import REG_CN, HIGH_FREQ_CONFIG
103+
from qlib.constant import REG_CN
104+
from qlib.config import HIGH_FREQ_CONFIG
104105
from qlib.data import D
105106
from qlib.utils import exists_qlib_data, init_instance_by_config, flatten_dict
106107
from qlib.workflow import R

0 commit comments

Comments
 (0)