Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions qlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@
import copy
import logging
import platform
import multiprocessing
from pathlib import Path
from typing import Callable, Optional, Union
from typing import TYPE_CHECKING

from qlib.constant import REG_CN, REG_US, REG_TW
from qlib.constant import (
REG_CN,
REG_US,
REG_TW,
PROTOCOL_VERSION,
NUM_USABLE_CPU,
DISK_DATASET_CACHE,
SIMPLE_DATASET_CACHE,
DISK_EXPRESSION_CACHE,
DEPENDENCY_REDIS_CACHE,
)

if TYPE_CHECKING:
from qlib.utils.time import Freq
Expand Down Expand Up @@ -120,17 +129,6 @@ def register_from_C(config, skip_register=True):
C.register()


# pickle.dump protocol version: https://docs.python.org/3/library/pickle.html#data-stream-format
PROTOCOL_VERSION = 4

NUM_USABLE_CPU = max(multiprocessing.cpu_count() - 2, 1)

DISK_DATASET_CACHE = "DiskDatasetCache"
SIMPLE_DATASET_CACHE = "SimpleDatasetCache"
DISK_EXPRESSION_CACHE = "DiskExpressionCache"

DEPENDENCY_REDIS_CACHE = (DISK_DATASET_CACHE, DISK_EXPRESSION_CACHE)

_default_config = {
# data provider config
"calendar_provider": "LocalCalendarProvider",
Expand Down
12 changes: 12 additions & 0 deletions qlib/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT License.

# REGION CONST
import multiprocessing
from typing import TypeVar

import numpy as np
Expand All @@ -20,3 +21,14 @@
ONE_MIN = pd.Timedelta("1min")
EPS_T = pd.Timedelta("1s") # use 1 second to exclude the right interval point
float_or_ndarray = TypeVar("float_or_ndarray", float, np.ndarray)

# pickle.dump protocol version: https://docs.python.org/3/library/pickle.html#data-stream-format
PROTOCOL_VERSION = 4

NUM_USABLE_CPU = max(multiprocessing.cpu_count() - 2, 1)

DISK_DATASET_CACHE = "DiskDatasetCache"
SIMPLE_DATASET_CACHE = "SimpleDatasetCache"
DISK_EXPRESSION_CACHE = "DiskExpressionCache"

DEPENDENCY_REDIS_CACHE = (DISK_DATASET_CACHE, DISK_EXPRESSION_CACHE)