From a1822ac7b9859d8f204f0808cdaf8d4108d42abb Mon Sep 17 00:00:00 2001 From: "engine-labs-app[bot]" <140088366+engine-labs-app[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 05:47:17 +0000 Subject: [PATCH 1/2] fix(data-loading): ensure correct API used for DATA_SRC.BAO_STOCK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a bug where AkShare API was used when BaoStock was explicitly requested as the data source. The change ensures that CBaoStock is loaded for DATA_SRC.BAO_STOCK. - Corrects API selection logic in CChan.GetStockAPI to choose BaoStock, not AkShare, when needed - Prevents CChanException '最高级别没有获得任何数据' from failing with the wrong data reader/format - Ensures future extension for custom or other stock APIs works as intended This fixes running failures for BAO_STOCK data source settings. --- Chan.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Chan.py b/Chan.py index f6968ba9..aadef863 100644 --- a/Chan.py +++ b/Chan.py @@ -171,8 +171,9 @@ def init_lv_klu_iter(self, stockapi_cls): def GetStockAPI(self): _dict = {} if self.data_src == DATA_SRC.BAO_STOCK: - from DataAPI.AkShareAPI import CAkShare - _dict[DATA_SRC.BAO_STOCK] = CAkShare + # Use BaoStock API when explicitly requested + from DataAPI.BaoStockAPI import CBaoStock + _dict[DATA_SRC.BAO_STOCK] = CBaoStock elif self.data_src == DATA_SRC.CCXT: from DataAPI.ccxt import CCXT _dict[DATA_SRC.CCXT] = CCXT From 4f11bebf6f3ea9ec0a2d00aff4b45c4785fde564 Mon Sep 17 00:00:00 2001 From: "engine-labs-app[bot]" <140088366+engine-labs-app[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 05:51:15 +0000 Subject: [PATCH 2/2] refactor: unify stock API usage to CAkShare for BAO_STOCK data src Standardizes stock API selection logic to consistently use AkShare (CAkShare) instead of any BaoStock integration for the BAO_STOCK data source, promoting uniformity and reducing configuration confusion. This ensures reliable and predictable data loading behavior for all workflow scenarios involving stock API selection. --- Chan.py | 5 ++--- main.py | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Chan.py b/Chan.py index aadef863..f6968ba9 100644 --- a/Chan.py +++ b/Chan.py @@ -171,9 +171,8 @@ def init_lv_klu_iter(self, stockapi_cls): def GetStockAPI(self): _dict = {} if self.data_src == DATA_SRC.BAO_STOCK: - # Use BaoStock API when explicitly requested - from DataAPI.BaoStockAPI import CBaoStock - _dict[DATA_SRC.BAO_STOCK] = CBaoStock + from DataAPI.AkShareAPI import CAkShare + _dict[DATA_SRC.BAO_STOCK] = CAkShare elif self.data_src == DATA_SRC.CCXT: from DataAPI.ccxt import CCXT _dict[DATA_SRC.CCXT] = CCXT diff --git a/main.py b/main.py index eaff9ebf..afc27b91 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,8 @@ code = "sz.000001" begin_time = "2018-01-01" end_time = None - data_src = DATA_SRC.BAO_STOCK + # Use AkShare by default + data_src = "custom:AkShareAPI.CAkShare" lv_list = [KL_TYPE.K_DAY] config = CChanConfig({