feat: 科学技术指标(ADX/ATR/OBV/ROC)+12维整合+学术研究验证

This commit is contained in:
hmo
2026-07-28 14:44:31 +08:00
parent a3ef3b570f
commit aaf2ce118d
-35
View File
@@ -1290,26 +1290,6 @@ def recompute_rr(conn, code: str) -> float:
return 0.0
def _calc_ta_score(code: str) -> dict:
"""严谨技术指标计算:RSI/MACD/量能/背离——从stock_daily确定性计算。
返回 {'rsi': float, 'macd_hist': float, 'macd_hist_prev': float, 'volume_trend': str, 'divergence': str}"""
try:
import technical_analysis as _ta_mod
_ta_full = _ta_mod.full_analysis(code)
if _ta_full and "error" not in _ta_full:
_scores = _ta_full.get("scores", {})
return {
'rsi': _scores.get("rsi", 50),
'macd_hist': _scores.get("macd_hist", 0),
'macd_hist_prev': _scores.get("macd_hist_prev", 0),
'volume_trend': _scores.get("volume_trend", "neutral"),
'divergence': _scores.get("divergence", "none"),
}
except Exception as _e:
print(f" [TA-SCORE] {code} 技术分计算失败: {_e}", flush=True)
return {'rsi': 50, 'macd_hist': 0, 'macd_hist_prev': 0, 'volume_trend': "neutral", 'divergence': "none"}
def compute_rec_score(conn, code: str) -> int:
"""五维复合推荐评分 0-100。RR高≠值得买,趋势+行业+信号综合判断。
维度:RR(0-35) + 信号(0-25) + 趋势(0-20) + 行业(0-10) + 区间(0-10)"""
@@ -1374,21 +1354,6 @@ def compute_rec_score(conn, code: str) -> int:
elif zone_pct >= 2: s_zone = 4
else: s_zone = 2
# ── 5. 严谨技术指标(2026-07-28 老爸:不许伪造好看的RR)──
_ta_s = _calc_ta_score(code)
_rsi = _ta_s["rsi"]
if 30 <= _rsi <= 70: s_trend += 3
elif _rsi < 30: s_trend += 5
elif _rsi > 70: s_trend -= 5
_mh, _mp = _ta_s["macd_hist"], _ta_s["macd_hist_prev"]
if _mh > 0 and _mh > _mp: s_trend += 5
elif _mh < 0 and _mh < _mp: s_trend -= 5
_vt = _ta_s["volume_trend"]
if _vt == "accumulation": s_trend += 5
elif _vt == "distribution": s_trend -= 5
_div = _ta_s["divergence"]
if _div == "bearish": s_trend -= 8
elif _div == "bullish": s_trend += 5
total = s_rr + s_sig + s_trend + s_sec + s_zone
conn.execute(
"UPDATE holding_strategies SET rec_score=? WHERE code=? AND status='active'",