Skip to content

Commit

Permalink
modify the default value of exists_skip in the GetData.qlib_data para…
Browse files Browse the repository at this point in the history
…meter to False
  • Loading branch information
zhupr committed May 28, 2021
1 parent 8df7f2f commit 922aa4b
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/highfreq/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _init_qlib(self):
# use yahoo_cn_1min data
QLIB_INIT_CONFIG = {**HIGH_FREQ_CONFIG, **self.SPEC_CONF}
provider_uri = QLIB_INIT_CONFIG.get("provider_uri")
GetData().qlib_data(target_dir=provider_uri, interval="1min", region=REG_CN)
GetData().qlib_data(target_dir=provider_uri, interval="1min", region=REG_CN, exists_skip=True)
qlib.init(**QLIB_INIT_CONFIG)

def _prepare_calender_cache(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperparameter/LightGBM/hyperparameter_158.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def objective(trial):
if __name__ == "__main__":

provider_uri = "~/.qlib/qlib_data/cn_data"
GetData().qlib_data(target_dir=provider_uri, region=REG_CN)
GetData().qlib_data(target_dir=provider_uri, region=REG_CN, exists_skip=True)
qlib.init(provider_uri=provider_uri, region="cn")

dataset = init_instance_by_config(CSI300_DATASET_CONFIG)
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperparameter/LightGBM/hyperparameter_360.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def objective(trial):
if __name__ == "__main__":

provider_uri = "~/.qlib/qlib_data/cn_data"
GetData().qlib_data(target_dir=provider_uri, region=REG_CN)
GetData().qlib_data(target_dir=provider_uri, region=REG_CN, exists_skip=True)
qlib.init(provider_uri=provider_uri, region=REG_CN)

dataset = init_instance_by_config(DATASET_CONFIG)
Expand Down
2 changes: 1 addition & 1 deletion examples/model_interpreter/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# use default data
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir
GetData().qlib_data(target_dir=provider_uri, region=REG_CN)
GetData().qlib_data(target_dir=provider_uri, region=REG_CN, exists_skip=True)

qlib.init(provider_uri=provider_uri, region=REG_CN)

Expand Down
2 changes: 1 addition & 1 deletion examples/rolling_process_data/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _init_qlib(self):
"""initialize qlib"""
# use yahoo_cn_1min data
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir
GetData().qlib_data(target_dir=provider_uri, region=REG_CN)
GetData().qlib_data(target_dir=provider_uri, region=REG_CN, exists_skip=True)
qlib.init(provider_uri=provider_uri, region=REG_CN)

def _dump_pre_handler(self, path):
Expand Down
2 changes: 1 addition & 1 deletion examples/run_all_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
}

GetData().qlib_data(target_dir=provider_uri, region=REG_CN)
GetData().qlib_data(target_dir=provider_uri, region=REG_CN, exists_skip=True)
qlib.init(provider_uri=provider_uri, region=REG_CN, exp_manager=exp_manager)

# decorator to check the arguments
Expand Down
2 changes: 1 addition & 1 deletion examples/workflow_by_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# use default data
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir
GetData().qlib_data(target_dir=provider_uri, region=REG_CN)
GetData().qlib_data(target_dir=provider_uri, region=REG_CN, exists_skip=True)
qlib.init(provider_uri=provider_uri, region=REG_CN)

port_analysis_config = {
Expand Down
1 change: 1 addition & 0 deletions qlib/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ def setUpClass(cls) -> None:
interval="1d",
target_dir=cls.provider_uri,
delete_old=False,
exists_skip=True,
)
init(provider_uri=cls.provider_uri, region=REG_CN, **cls._setup_kwargs)
8 changes: 6 additions & 2 deletions qlib/tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def qlib_data(
interval="1d",
region="cn",
delete_old=True,
exists_skip=True,
exists_skip=False,
):
"""download cn qlib data from remote
Expand All @@ -132,7 +132,7 @@ def qlib_data(
delete_old: bool
delete an existing directory, by default True
exists_skip: bool
exists skip, by default True
exists skip, by default False
Examples
---------
Expand All @@ -145,6 +145,10 @@ def qlib_data(
"""
if exists_skip and exists_qlib_data(target_dir):
logger.warning(
f"Data already exists: {target_dir}, the data download will be skipped\n"
f"\tIf downloading is required: `exists_skip=False` or `change target_dir`"
)
return

qlib_version = ".".join(re.findall(r"(\d+)\.+", qlib.__version__))
Expand Down
4 changes: 3 additions & 1 deletion tests/test_get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def tearDownClass(cls) -> None:

def test_0_qlib_data(self):

GetData().qlib_data(name="qlib_data_simple", target_dir=QLIB_DIR, region="cn", interval="1d", delete_old=False)
GetData().qlib_data(
name="qlib_data_simple", target_dir=QLIB_DIR, region="cn", interval="1d", delete_old=False, exists_skip=True
)
df = D.features(D.instruments("csi300"), self.FIELDS)
self.assertListEqual(list(df.columns), self.FIELDS, "get qlib data failed")
self.assertFalse(df.dropna().empty, "get qlib data failed")
Expand Down

0 comments on commit 922aa4b

Please sign in to comment.