feat: 筹码因子情景权重+共振检测修复
- detect_scenario()判定市况→动态调整筹码因子权重 震荡市(0.9) > 轮动市(0.6) > 上涨(0.4) > 急跌(0.2) - 共振检测: 筹码支撑 vs 枢轴弱支撑(同为最近支撑位) - 权重低时筹码即使一致也标记不可靠 - 止损/止盈仍以枢轴为主,筹码提供中线参考
This commit is contained in:
+42
-12
@@ -18,6 +18,7 @@ from datetime import datetime
|
||||
import technical_analysis as ta
|
||||
import multi_timeframe as mtf
|
||||
from mo_data import read_portfolio, read_decisions, read_watchlist
|
||||
from strategy_tree import detect_scenario
|
||||
|
||||
|
||||
def is_hk_stock(code):
|
||||
@@ -591,22 +592,51 @@ def reassess_strategy(code, name, price, cost, shares, current_action,
|
||||
except Exception as e:
|
||||
print(f" 多周期分析失败: {e}", file=sys.stderr)
|
||||
|
||||
# ----- 筹码分布支撑/阻力(中长线参考) -----
|
||||
# ----- 筹码分布支撑/阻力(中长线参考,加情景权重) -----
|
||||
chip_sr = None
|
||||
chip_weight = 0.5 # 默认中等权重
|
||||
regime = detect_scenario()
|
||||
regime_id = regime.get("id", "weak_consolidation")
|
||||
|
||||
# 情景决定筹码因子权重
|
||||
if regime_id == "weak_consolidation":
|
||||
chip_weight = 0.9 # 震荡市筹码最准
|
||||
elif regime_id == "bullish_recovery":
|
||||
chip_weight = 0.4 # 上涨趋势筹码阻力可能被突破
|
||||
elif regime_id == "sharp_decline":
|
||||
chip_weight = 0.2 # 急跌中筹码支撑可能失效
|
||||
elif regime_id == "sector_rotation":
|
||||
chip_weight = 0.6 # 轮动市中筹码有一定参考
|
||||
|
||||
try:
|
||||
chip_sr = calc_chip_sr(code, price)
|
||||
if chip_sr:
|
||||
print(f" 筹码: 强撑={chip_sr['chip_ss']} 强压={chip_sr['chip_sr']}")
|
||||
# 与枢轴点对比,判断共振/分歧
|
||||
if ss and ws and pivot:
|
||||
chip_ss_pct = (price - chip_sr['chip_ss']) / price * 100 if chip_sr['chip_ss'] > 0 else 0
|
||||
chip_sr_pct = (chip_sr['chip_sr'] - price) / price * 100 if chip_sr['chip_sr'] > 0 else 0
|
||||
pivot_ss_pct = (price - ss) / price * 100 if ss > 0 else 0
|
||||
pivot_sr_pct = (sr_resist - price) / price * 100 if sr_resist > 0 else 0
|
||||
if abs(chip_ss_pct - pivot_ss_pct) < 3:
|
||||
print(f" ⚡ 支撑共振: 筹码+枢轴均指向{chip_sr['chip_ss']:.0f}附近")
|
||||
if abs(chip_sr_pct - pivot_sr_pct) < 3:
|
||||
print(f" ⚡ 阻力共振: 筹码+枢轴均指向{chip_sr['chip_sr']:.0f}附近")
|
||||
print(f" 筹码: 撑={chip_sr['chip_ss']:.0f} 阻={chip_sr['chip_sr']:.0f} | 情景={regime_id} 权重={chip_weight:.1f}")
|
||||
# 与枢轴点对比
|
||||
if ss and ws and pivot and chip_sr['chip_ss'] > 0 and chip_sr['chip_sr'] > 0:
|
||||
chip_ss_pct = (price - chip_sr['chip_ss']) / price * 100
|
||||
chip_sr_pct = (chip_sr['chip_sr'] - price) / price * 100
|
||||
|
||||
# 共振检测:筹码支撑 vs 枢轴弱支撑(都是最近支撑位)
|
||||
if ws and ws > 0:
|
||||
resonance_ss = abs(chip_ss_pct - ((price - ws) / price * 100)) < 3
|
||||
else:
|
||||
resonance_ss = False
|
||||
# 共振检测:筹码阻力 vs 枢轴弱阻力(都是最近阻力位)
|
||||
if wr and wr > 0:
|
||||
resonance_sr = abs(chip_sr_pct - ((wr - price) / price * 100)) < 3
|
||||
else:
|
||||
resonance_sr = False
|
||||
|
||||
if resonance_ss and chip_weight >= 0.5:
|
||||
print(f" ⚡ 支撑共振({chip_weight:.0f}): 筹码+枢轴均指向{chip_sr['chip_ss']:.0f}")
|
||||
elif chip_weight < 0.5:
|
||||
print(f" 📎 支撑一致但权重低({chip_weight:.1f}): {regime_id}下筹码支撑不可靠")
|
||||
|
||||
if resonance_sr and chip_weight >= 0.5:
|
||||
print(f" ⚡ 阻力共振({chip_weight:.0f}): 筹码+枢轴均指向{chip_sr['chip_sr']:.0f}")
|
||||
elif chip_weight < 0.5:
|
||||
print(f" 📎 阻力一致但权重低({chip_weight:.1f}): {regime_id}下筹码阻力不可靠")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user