From 0e8571415c9ef8084b162de8c2128e2b3492e306 Mon Sep 17 00:00:00 2001 From: "Linlang Lv (iSoftStone Information)" Date: Wed, 10 Apr 2024 13:58:35 +0800 Subject: [PATCH 1/3] fix issue 1729 --- scripts/data_collector/cn_index/collector.py | 10 ++-------- setup.py | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/data_collector/cn_index/collector.py b/scripts/data_collector/cn_index/collector.py index 96f68ef9cd..050221502a 100644 --- a/scripts/data_collector/cn_index/collector.py +++ b/scripts/data_collector/cn_index/collector.py @@ -396,14 +396,7 @@ def get_history_companies(self) -> pd.DataFrame: today = pd.Timestamp.now() date_range = pd.DataFrame(pd.date_range(start="2007-01-15", end=today, freq="7D"))[0].dt.date ret_list = [] - col = ["date", "symbol", "code_name"] for date in tqdm(date_range, desc="Download CSI500"): - rs = bs.query_zz500_stocks(date=str(date)) - zz500_stocks = [] - while (rs.error_code == "0") & rs.next(): - zz500_stocks.append(rs.get_row_data()) - result = pd.DataFrame(zz500_stocks, columns=col) - result["symbol"] = result["symbol"].apply(lambda x: x.replace(".", "").upper()) result = self.get_data_from_baostock(date) ret_list.append(result[["date", "symbol"]]) bs.logout() @@ -465,4 +458,5 @@ def get_new_companies(self) -> pd.DataFrame: if __name__ == "__main__": - fire.Fire(get_instruments) + # fire.Fire(get_instruments) + get_instruments(index_name="CSI500", qlib_dir="C:/Users/v-lvlinlang/Desktop/20230914175824_qlib_data_cn_1d_latest", method="parse_instruments") diff --git a/setup.py b/setup.py index adafefd614..4b7c060b48 100644 --- a/setup.py +++ b/setup.py @@ -82,7 +82,7 @@ def get_version(rel_path: str) -> str: "dill", "dataclasses;python_version<'3.7'", "filelock", - "jinja2<3.1.0", # for passing the readthedocs workflow. + "jinja2", # for passing the readthedocs workflow. "gym", # Installing the latest version of protobuf for python versions below 3.8 will cause unit tests to fail. "protobuf<=3.20.1;python_version<='3.8'", From 27ab49a0ab9a928e9f9412d87f900e08f31d10dc Mon Sep 17 00:00:00 2001 From: "Linlang Lv (iSoftStone Information)" Date: Wed, 10 Apr 2024 13:59:19 +0800 Subject: [PATCH 2/3] fix issue 1729 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4b7c060b48..adafefd614 100644 --- a/setup.py +++ b/setup.py @@ -82,7 +82,7 @@ def get_version(rel_path: str) -> str: "dill", "dataclasses;python_version<'3.7'", "filelock", - "jinja2", # for passing the readthedocs workflow. + "jinja2<3.1.0", # for passing the readthedocs workflow. "gym", # Installing the latest version of protobuf for python versions below 3.8 will cause unit tests to fail. "protobuf<=3.20.1;python_version<='3.8'", From 6443d86b8765281efa98cc4a0448d1cc29480928 Mon Sep 17 00:00:00 2001 From: "Linlang Lv (iSoftStone Information)" Date: Wed, 10 Apr 2024 14:00:45 +0800 Subject: [PATCH 3/3] fix issue 1729 --- scripts/data_collector/cn_index/collector.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/data_collector/cn_index/collector.py b/scripts/data_collector/cn_index/collector.py index 050221502a..237df6fe87 100644 --- a/scripts/data_collector/cn_index/collector.py +++ b/scripts/data_collector/cn_index/collector.py @@ -458,5 +458,4 @@ def get_new_companies(self) -> pd.DataFrame: if __name__ == "__main__": - # fire.Fire(get_instruments) - get_instruments(index_name="CSI500", qlib_dir="C:/Users/v-lvlinlang/Desktop/20230914175824_qlib_data_cn_1d_latest", method="parse_instruments") + fire.Fire(get_instruments)