Skip to content

Commit 02442fa

Browse files
committed
Align LongBridge runtime strategy profiles
1 parent ca98ce0 commit 02442fa

4 files changed

Lines changed: 18 additions & 59 deletions

File tree

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ Platform execution no longer depends on `strategy/allocation.py` or hard-coded s
3737
| `soxl_soxx_trend_income` | SOXL/SOXX Semiconductor Trend Income | Yes | Yes | `us_equity` | current SG deployment |
3838
| `tqqq_growth_income` | TQQQ Growth Income | Yes | Yes | `us_equity` | selectable growth line |
3939
| `tech_communication_pullback_enhancement` | Tech/Communication Pullback Enhancement | Yes | Yes | `us_equity` | current HK feature-snapshot line |
40-
| `mega_cap_leader_rotation_aggressive` | Mega Cap Leader Rotation Aggressive | Yes | No | `us_equity` | research-only archive |
41-
| `mega_cap_leader_rotation_dynamic_top20` | Mega Cap Leader Rotation Dynamic Top20 | Yes | No | `us_equity` | research-only archive |
42-
| `dynamic_mega_leveraged_pullback` | Dynamic Mega Leveraged Pullback | Yes | No | `us_equity` | research-only archive |
4340

4441
Check the current matrix locally:
4542

@@ -160,7 +157,7 @@ IAM: the Cloud Run service account needs **Secret Manager Admin** (or Secret Acc
160157
基于 LongPort OpenAPI 和 Google Cloud Run 的量化交易系统。
161158

162159
这个仓库通过 `QuantPlatformKit` 复用 LongPort token 处理、上下文初始化、账户快照、行情读取和下单逻辑。Cloud Run 直接部署这个仓库。
163-
`LongBridgePlatform` 现在可直接执行 `UsEquityStrategies` 里的 6 条 `runtime_enabled` `us_equity` 策略:`global_etf_rotation``mega_cap_leader_rotation_top50_balanced``russell_1000_multi_factor_defensive``soxl_soxx_trend_income``tqqq_growth_income``tech_communication_pullback_enhancement``dynamic_mega_leveraged_pullback``mega_cap_leader_rotation_aggressive``mega_cap_leader_rotation_dynamic_top20` 保留为 research-only 存档,不进入 LongBridge rollout。仓库本身继续保留 LongPort 运行时、token 刷新、执行和通知流程。
160+
`LongBridgePlatform` 现在可直接执行 `UsEquityStrategies` 里的 6 条 `runtime_enabled` `us_equity` 策略:`global_etf_rotation``mega_cap_leader_rotation_top50_balanced``russell_1000_multi_factor_defensive``soxl_soxx_trend_income``tqqq_growth_income``tech_communication_pullback_enhancement`。较弱或重复的研究 profile 已从 LongBridge 可配置入口移除。仓库本身继续保留 LongPort 运行时、token 刷新、执行和通知流程。
164161

165162
完整策略说明现在放在 [`UsEquityStrategies`](https://github.com/QuantStrategyLab/UsEquityStrategies)。下面这些章节只保留 LongBridge 运行时、profile 启用状态、部署和凭据说明。
166163

@@ -185,9 +182,6 @@ IAM: the Cloud Run service account needs **Secret Manager Admin** (or Secret Acc
185182
| `soxl_soxx_trend_income` | SOXL/SOXX 半导体趋势收益 | Yes | Yes | `us_equity` | 当前 SG 部署线路 |
186183
| `tqqq_growth_income` | TQQQ 增长收益 | Yes | Yes | `us_equity` | 可选增长线路 |
187184
| `tech_communication_pullback_enhancement` | 科技通信回调增强 | Yes | Yes | `us_equity` | 当前 HK feature-snapshot 线路 |
188-
| `mega_cap_leader_rotation_aggressive` | Mega Cap Leader Rotation Aggressive | Yes | No | `us_equity` | research-only 存档 |
189-
| `mega_cap_leader_rotation_dynamic_top20` | Mega Cap Leader Rotation Dynamic Top20 | Yes | No | `us_equity` | research-only 存档 |
190-
| `dynamic_mega_leveraged_pullback` | Dynamic Mega Leveraged Pullback | Yes | No | `us_equity` | research-only 存档 |
191185

192186
本地可直接查看当前矩阵:
193187

notifications/telegram.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@
9494
"strategy_name_russell_1000_multi_factor_defensive": "罗素1000多因子",
9595
"strategy_name_tech_communication_pullback_enhancement": "科技通信回调增强",
9696
"strategy_name_qqq_tech_enhancement": "科技通信回调增强",
97-
"strategy_name_mega_cap_leader_rotation_aggressive": "Mega Cap 激进龙头轮动",
98-
"strategy_name_mega_cap_leader_rotation_dynamic_top20": "Mega Cap 动态 Top20 龙头轮动",
9997
"strategy_name_mega_cap_leader_rotation_top50_balanced": "Mega Cap Top50 平衡龙头轮动",
100-
"strategy_name_dynamic_mega_leveraged_pullback": "Mega Cap 2x 回调策略",
10198
},
10299
"en": {
103100
"rebalance_title": "🔔 【Trade Execution Report】",
@@ -176,10 +173,7 @@
176173
"strategy_name_russell_1000_multi_factor_defensive": "Russell 1000 Multi-Factor",
177174
"strategy_name_tech_communication_pullback_enhancement": "Tech/Communication Pullback Enhancement",
178175
"strategy_name_qqq_tech_enhancement": "Tech/Communication Pullback Enhancement",
179-
"strategy_name_mega_cap_leader_rotation_aggressive": "Mega Cap Leader Rotation Aggressive",
180-
"strategy_name_mega_cap_leader_rotation_dynamic_top20": "Mega Cap Leader Rotation Dynamic Top20",
181176
"strategy_name_mega_cap_leader_rotation_top50_balanced": "Mega Cap Leader Rotation Top50 Balanced",
182-
"strategy_name_dynamic_mega_leveraged_pullback": "Dynamic Mega Leveraged Pullback",
183177
},
184178
}
185179

tests/test_runtime_config_support.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ def test_platform_eligible_profiles_are_exposed_by_capability_matrix(self):
8282
get_eligible_profiles_for_platform(LONGBRIDGE_PLATFORM),
8383
frozenset(
8484
{
85-
"dynamic_mega_leveraged_pullback",
8685
"global_etf_rotation",
87-
"mega_cap_leader_rotation_aggressive",
88-
"mega_cap_leader_rotation_dynamic_top20",
8986
"mega_cap_leader_rotation_top50_balanced",
9087
"russell_1000_multi_factor_defensive",
9188
"tqqq_growth_income",
@@ -176,9 +173,6 @@ def test_platform_profile_status_matrix_matches_current_longbridge_rollout(self)
176173
set(by_profile),
177174
{
178175
"global_etf_rotation",
179-
"dynamic_mega_leveraged_pullback",
180-
"mega_cap_leader_rotation_aggressive",
181-
"mega_cap_leader_rotation_dynamic_top20",
182176
"mega_cap_leader_rotation_top50_balanced",
183177
"russell_1000_multi_factor_defensive",
184178
"tqqq_growth_income",
@@ -210,21 +204,12 @@ def test_platform_profile_status_matrix_matches_current_longbridge_rollout(self)
210204
self.assertTrue(by_profile["tech_communication_pullback_enhancement"]["eligible"])
211205
self.assertTrue(by_profile["tech_communication_pullback_enhancement"]["enabled"])
212206
self.assertEqual(by_profile["tech_communication_pullback_enhancement"]["display_name"], "Tech/Communication Pullback Enhancement")
213-
self.assertTrue(by_profile["mega_cap_leader_rotation_dynamic_top20"]["eligible"])
214-
self.assertFalse(by_profile["mega_cap_leader_rotation_dynamic_top20"]["enabled"])
215-
self.assertEqual(by_profile["mega_cap_leader_rotation_dynamic_top20"]["display_name"], "Mega Cap Leader Rotation Dynamic Top20")
216207
self.assertTrue(by_profile["mega_cap_leader_rotation_top50_balanced"]["eligible"])
217208
self.assertTrue(by_profile["mega_cap_leader_rotation_top50_balanced"]["enabled"])
218209
self.assertEqual(
219210
by_profile["mega_cap_leader_rotation_top50_balanced"]["display_name"],
220211
"Mega Cap Leader Rotation Top50 Balanced",
221212
)
222-
self.assertTrue(by_profile["mega_cap_leader_rotation_aggressive"]["eligible"])
223-
self.assertFalse(by_profile["mega_cap_leader_rotation_aggressive"]["enabled"])
224-
self.assertEqual(by_profile["mega_cap_leader_rotation_aggressive"]["display_name"], "Mega Cap Leader Rotation Aggressive")
225-
self.assertTrue(by_profile["dynamic_mega_leveraged_pullback"]["eligible"])
226-
self.assertFalse(by_profile["dynamic_mega_leveraged_pullback"]["enabled"])
227-
self.assertEqual(by_profile["dynamic_mega_leveraged_pullback"]["display_name"], "Dynamic Mega Leveraged Pullback")
228213

229214
def test_loads_feature_snapshot_env_for_tech_profile(self):
230215
with patch.dict(
@@ -302,9 +287,6 @@ def test_print_strategy_profile_status_json_matches_registry(self):
302287
self.assertEqual(by_profile["tech_communication_pullback_enhancement"]["input_mode"], "feature_snapshot")
303288
self.assertTrue(by_profile["tech_communication_pullback_enhancement"]["requires_snapshot_artifacts"])
304289
self.assertTrue(by_profile["tech_communication_pullback_enhancement"]["requires_strategy_config_path"])
305-
self.assertFalse(by_profile["mega_cap_leader_rotation_dynamic_top20"]["enabled"])
306-
self.assertFalse(by_profile["mega_cap_leader_rotation_aggressive"]["enabled"])
307-
self.assertFalse(by_profile["dynamic_mega_leveraged_pullback"]["enabled"])
308290
self.assertEqual(by_profile["mega_cap_leader_rotation_top50_balanced"]["profile_group"], "snapshot_backed")
309291
self.assertEqual(by_profile["mega_cap_leader_rotation_top50_balanced"]["input_mode"], "feature_snapshot")
310292
self.assertTrue(by_profile["mega_cap_leader_rotation_top50_balanced"]["requires_snapshot_artifacts"])
@@ -328,7 +310,6 @@ def test_print_strategy_profile_status_table_contains_expected_headers(self):
328310
self.assertIn("requires_snapshot_artifacts", result.stdout)
329311
self.assertIn("soxl_soxx_trend_income", result.stdout)
330312
self.assertIn("global_etf_rotation", result.stdout)
331-
self.assertIn("mega_cap_leader_rotation_dynamic_top20", result.stdout)
332313
self.assertIn("russell_1000_multi_factor_defensive", result.stdout)
333314
self.assertIn("Global ETF Rotation", result.stdout)
334315
self.assertIn("Russell 1000 Multi-Factor", result.stdout)

tests/test_strategy_runtime.py

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ def evaluate(self, ctx):
7979
return StrategyDecision(diagnostics={"signal_description": "broad risk on"})
8080

8181

82-
class _DynamicMegaLeveragedEntrypoint:
82+
class _MegaCapTop50Entrypoint:
8383
manifest = StrategyManifest(
84-
profile="dynamic_mega_leveraged_pullback",
84+
profile="mega_cap_leader_rotation_top50_balanced",
8585
domain="us_equity",
86-
display_name="Dynamic Mega Leveraged Pullback",
86+
display_name="Mega Cap Leader Rotation Top50 Balanced",
8787
description="test entrypoint",
88-
required_inputs=frozenset({"feature_snapshot", "market_history", "benchmark_history", "portfolio_snapshot"}),
88+
required_inputs=frozenset({"feature_snapshot"}),
8989
default_config={"safe_haven": "BOXX", "benchmark_symbol": "QQQ"},
9090
)
9191

9292
def evaluate(self, ctx):
9393
self.ctx = ctx
94-
return StrategyDecision(diagnostics={"signal_description": "leveraged pullback"})
94+
return StrategyDecision(diagnostics={"signal_description": "top50 balanced"})
9595

9696

9797
def _build_runtime_settings(
@@ -366,27 +366,24 @@ def test_feature_snapshot_runtime_loads_russell_snapshot_into_context(self):
366366
self.assertEqual(result.metadata["managed_symbols"], ("AAPL", "MSFT", "BOXX"))
367367
self.assertEqual(result.metadata["status_icon"], "📏")
368368

369-
def test_feature_snapshot_runtime_keeps_hybrid_inputs_for_dynamic_mega_leveraged_pullback(self):
370-
entrypoint = _DynamicMegaLeveragedEntrypoint()
369+
def test_feature_snapshot_runtime_loads_mega_cap_top50_snapshot_into_context(self):
370+
entrypoint = _MegaCapTop50Entrypoint()
371371
runtime = strategy_runtime_module.LoadedStrategyRuntime(
372372
entrypoint=entrypoint,
373373
runtime_adapter=StrategyRuntimeAdapter(
374-
status_icon="2x",
375-
required_feature_columns=frozenset({"symbol", "underlying_symbol", "sector", "candidate_rank", "product_leverage", "product_available"}),
376-
managed_symbols_extractor=lambda *_args, **_kwargs: ("AAPU", "BOXX"),
374+
status_icon="👑",
375+
required_feature_columns=frozenset({"symbol", "sector", "close"}),
376+
managed_symbols_extractor=lambda *_args, **_kwargs: ("NVDA", "META", "BOXX"),
377377
portfolio_input_name="portfolio_snapshot",
378378
),
379379
runtime_settings=_build_runtime_settings(
380-
"dynamic_mega_leveraged_pullback",
381-
feature_snapshot_path="gs://bucket/dynamic.csv",
380+
"mega_cap_leader_rotation_top50_balanced",
381+
feature_snapshot_path="gs://bucket/top50.csv",
382382
),
383383
merged_runtime_config={"safe_haven": "BOXX", "benchmark_symbol": "QQQ"},
384384
logger=lambda _message: None,
385385
)
386386

387-
def market_history_loader(*_args, **_kwargs):
388-
return [1.0, 2.0, 3.0]
389-
390387
portfolio = PortfolioSnapshot(
391388
as_of=datetime.now(timezone.utc),
392389
total_equity=1000.0,
@@ -403,31 +400,24 @@ def market_history_loader(*_args, **_kwargs):
403400
{
404401
"frame": [
405402
{
406-
"symbol": "AAPU",
407-
"underlying_symbol": "AAPL",
403+
"symbol": "NVDA",
408404
"sector": "Technology",
409-
"candidate_rank": 1,
410-
"product_leverage": 2.0,
411-
"product_available": True,
405+
"close": 880.0,
412406
}
413407
],
414408
"metadata": {"snapshot_guard_decision": "proceed", "snapshot_as_of": "2026-04-08"},
415409
},
416410
)(),
417411
):
418412
result = runtime.evaluate(
419-
market_history=market_history_loader,
420-
benchmark_history=[{"close": 1.0, "high": 1.0, "low": 1.0}],
421413
portfolio_snapshot=portfolio,
422414
translator=lambda key, **_kwargs: key,
423415
)
424416

425-
self.assertEqual(entrypoint.ctx.market_data["feature_snapshot"][0]["symbol"], "AAPU")
426-
self.assertIs(entrypoint.ctx.market_data["market_history"], market_history_loader)
427-
self.assertEqual(entrypoint.ctx.market_data["benchmark_history"][0]["close"], 1.0)
417+
self.assertEqual(entrypoint.ctx.market_data["feature_snapshot"][0]["symbol"], "NVDA")
428418
self.assertIs(entrypoint.ctx.portfolio, portfolio)
429-
self.assertEqual(result.metadata["managed_symbols"], ("AAPU", "BOXX"))
430-
self.assertEqual(result.metadata["status_icon"], "2x")
419+
self.assertEqual(result.metadata["managed_symbols"], ("NVDA", "META", "BOXX"))
420+
self.assertEqual(result.metadata["status_icon"], "👑")
431421

432422

433423
if __name__ == "__main__":

0 commit comments

Comments
 (0)