From 4db37c378f1e6c9cbbe38e8191225879d7a15ff4 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Wed, 3 Jun 2026 03:33:34 +0800 Subject: [PATCH 1/3] Enable HK low-vol dividend switch plan --- requirements.txt | 6 ++-- scripts/print_strategy_switch_env_plan.py | 14 ++++++-- tests/test_runtime_config_support.py | 43 ++++++++++++++++++++++- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8173619..ffa1716 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ flask gunicorn -quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.7.35 -us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@v0.7.49 -hk-equity-strategies @ git+https://github.com/QuantStrategyLab/HkEquityStrategies.git@71141ce9e8a343cec8e2140994071eea66422bc6 +quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.7.36 +us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@v0.7.50 +hk-equity-strategies @ git+https://github.com/QuantStrategyLab/HkEquityStrategies.git@1b7a357 pandas requests pytz diff --git a/scripts/print_strategy_switch_env_plan.py b/scripts/print_strategy_switch_env_plan.py index 0ca74ea..882e8d9 100644 --- a/scripts/print_strategy_switch_env_plan.py +++ b/scripts/print_strategy_switch_env_plan.py @@ -80,6 +80,12 @@ def _should_add_local_src(candidate: Path) -> bool: ] +def _feature_snapshot_filenames(profile: str, snapshot_contract_version: str | None) -> tuple[str, str]: + suffix = "factor_snapshot" if ".factor_snapshot." in str(snapshot_contract_version or "") else "feature_snapshot" + snapshot_filename = f"{profile}_{suffix}_latest.csv" + return snapshot_filename, f"{snapshot_filename}.manifest.json" + + def build_switch_plan( profile: str, *, @@ -222,10 +228,12 @@ def build_switch_plan( hints: dict[str, str] = {} if requires_feature_snapshot: - hints["feature_snapshot_filename"] = f"{definition.profile}_feature_snapshot_latest.csv" - hints["feature_snapshot_manifest_filename"] = ( - f"{definition.profile}_feature_snapshot_latest.csv.manifest.json" + snapshot_filename, manifest_filename = _feature_snapshot_filenames( + definition.profile, + runtime_requirements.get("snapshot_contract_version"), ) + hints["feature_snapshot_filename"] = snapshot_filename + hints["feature_snapshot_manifest_filename"] = manifest_filename if artifact_paths.bundled_config_path is not None: hints["bundled_strategy_config_path"] = str(artifact_paths.bundled_config_path) diff --git a/tests/test_runtime_config_support.py b/tests/test_runtime_config_support.py index 295655e..edc7bee 100644 --- a/tests/test_runtime_config_support.py +++ b/tests/test_runtime_config_support.py @@ -62,7 +62,13 @@ } ) OPTIONAL_LONGBRIDGE_PROFILES = frozenset({"global_etf_confidence_vol_gate"}) -HK_RUNTIME_ENABLED_PROFILES = frozenset({"hk_listed_global_etf_rotation"}) +HK_RUNTIME_ENABLED_PROFILES = frozenset( + { + "hk_high_dividend_low_vol_trend", + "hk_listed_global_etf_rotation", + "hk_low_vol_dividend_quality", + } +) HK_DISABLED_PROFILES = frozenset( { "hk_blue_chip_leader_rotation", @@ -971,6 +977,41 @@ def test_print_strategy_switch_env_plan_for_mega_cap_top50_balanced(self): "mega_cap_leader_rotation_top50_balanced_feature_snapshot_latest.csv", ) + def test_print_strategy_switch_env_plan_for_hk_low_vol_dividend_quality(self): + result = subprocess.run( + [ + sys.executable, + str(SWITCH_PLAN_SCRIPT_PATH), + "--profile", + "hk_low_vol_dividend_quality", + "--account-region", + "hk", + "--dry-run-only", + "--json", + ], + check=True, + capture_output=True, + text=True, + ) + + plan = json.loads(result.stdout) + self.assertEqual(plan["canonical_profile"], "hk_low_vol_dividend_quality") + self.assertTrue(plan["enabled"]) + self.assertEqual(plan["profile_group"], "snapshot_backed") + self.assertEqual(plan["input_mode"], "feature_snapshot") + self.assertEqual(plan["snapshot_contract_version"], "hk_low_vol_dividend_quality.factor_snapshot.v1") + self.assertEqual(plan["set_env"]["LONGBRIDGE_DRY_RUN_ONLY"], "true") + self.assertEqual(plan["set_env"]["LONGBRIDGE_FEATURE_SNAPSHOT_PATH"], "") + self.assertEqual(plan["set_env"]["LONGBRIDGE_FEATURE_SNAPSHOT_MANIFEST_PATH"], "") + self.assertEqual( + plan["hints"]["feature_snapshot_filename"], + "hk_low_vol_dividend_quality_factor_snapshot_latest.csv", + ) + self.assertEqual( + plan["hints"]["feature_snapshot_manifest_filename"], + "hk_low_vol_dividend_quality_factor_snapshot_latest.csv.manifest.json", + ) + def test_print_strategy_switch_env_plan_rejects_hk_disabled_profiles(self): for profile in sorted(HK_DISABLED_PROFILES): with self.subTest(profile=profile): From 3fa74ee17e6a257f3921f2a49c83bcb24d8504c8 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Wed, 3 Jun 2026 03:44:59 +0800 Subject: [PATCH 2/3] Update HK strategy live-enable dependency --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ffa1716..23d89e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ flask gunicorn quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.7.36 us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@v0.7.50 -hk-equity-strategies @ git+https://github.com/QuantStrategyLab/HkEquityStrategies.git@1b7a357 +hk-equity-strategies @ git+https://github.com/QuantStrategyLab/HkEquityStrategies.git@623ca96 pandas requests pytz From cb096ae4016493daf096388c86f8b8040b73bc39 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Wed, 3 Jun 2026 03:59:44 +0800 Subject: [PATCH 3/3] Pin HK low-vol strategy release --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 23d89e3..f6710a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ flask gunicorn quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.7.36 us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@v0.7.50 -hk-equity-strategies @ git+https://github.com/QuantStrategyLab/HkEquityStrategies.git@623ca96 +hk-equity-strategies @ git+https://github.com/QuantStrategyLab/HkEquityStrategies.git@hk-low-vol-dividend-quality-20260603 pandas requests pytz