Files
MoFin/deploy/profile-scripts/hk_strategies.py
T

75 lines
3.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""hk_strategies.py — 港股策略定义(独立于A股strategy_lab,零干扰)
港股策略库:各温区互补策略定义(单一来源)。
面板数据:/tmp/panel_12d_hk.pklbuild_panel_hk_v2 构建,含价量/大盘/行业动量/估值分位/资金流)
策略结构:
version: 策略名
regime: 适用温区(trend_up/trend_down/choppy/all
entry: 入场条件(面板因子,数据定阈值——step29 由果及因扫描)
exit: 出场(止盈/止损/最大持有,港股波动放宽)
"""
# ── 港股策略库(按温区互补)──────────────────────────────
HK_STRATEGIES = {
# trend_up:低PE + 行业动量高(由果及因:大涨率10.28%,2.35x基线)
"hk_pe_mom": {
"version": "hk_pe_mom",
"name": "港股低PE+行业动量(trend_up主战场)",
"regime": "trend_up",
"summary": "低PE(<0.2分位)+行业20日动量>10%。由果及因:大涨率10.28%(基线4.37%)。低PE+1.24pp(step27港股扫描)、行业动量高+1.47pp",
"entry": {
"pe_q_max": 0.2, # PE分位<0.2(低估值,+3.24pp
"mcap_q_max": 0.2, # 市值分位<0.2(小市值,+2.84pp
"sec_ret20_min": 10, # 行业20日动量>10%+1.47pp
},
"exit": {"tp_pct": 0.30, "sl_pct": 0.12, "max_hold_days": 40},
},
# trend_down:深度超卖反弹(由果及因:RSI<20/bias60<-20,持续下跌市避被埋,胜率72%)
"hk_mr1": {
"version": "hk_mr1",
"name": "港股深度超卖反弹(trend_down主战场)",
"regime": "trend_down",
"summary": "RSI<20+bias60<-20+止跌回升+放量。深度超卖只在极端恐慌出手:胜率72%,tp45%让反弹吃满,年化10.5%。持续下跌市(2022/2026H1)避被埋",
"entry": {
"rsi_max": 20,
"bias60_max": -20,
"rsi_delta_min": 2,
"vol_ratio_min": 1.5,
},
"exit": {"tp_pct": 0.45, "sl_pct": 0.15, "max_hold_days": 50},
},
# choppy:低PE+超跌反弹(震荡市价值修复)
"hk_pe_oversold": {
"version": "hk_pe_oversold",
"name": "港股低PE+超卖反弹(choppy主战场)",
"regime": "choppy",
"summary": "低PE(<0.2分位)+RSI超卖(<45)。由果及因:低PE+超卖组合大涨率6.93%(基线4.37%)",
"entry": {
"pe_q_max": 0.2,
"rsi_max": 45,
"bias60_max": 0,
},
"exit": {"tp_pct": 0.25, "sl_pct": 0.12, "max_hold_days": 40},
},
}
def get_hk_strategy(version):
"""按版本取港股策略定义"""
return HK_STRATEGIES.get(version)
def list_hk_strategies():
"""港股策略列表(按温区)"""
return [{"version": v, "regime": s["regime"], "name": s["name"]}
for v, s in HK_STRATEGIES.items()]
def strategies_for_regime(regime):
"""返回适用某温区的策略版本列表(regime 参数用于组合调度)"""
return [v for v, s in HK_STRATEGIES.items()
if s["regime"] == regime or s["regime"] == "all"]