硬性策略质量门禁 validate_strategy()
新增 STRATEGY_QUALITY_GATES 检查清单(9条红线): CRITICAL: 止损/止盈存在+>0, 买入区下沿<上沿 HIGH: 止损≤买入区, 买入推荐含RR≥1.5, 港股标currency=HKD MEDIUM: signal短词, tech_snapshot含技术位 enforce_strategy_quality() 插在写入链的两处: 1. reassess_with_context() return前 → 单只重评必过 2. regenerate_all() for d in decisions: 写DB前 → 批量重评必过 不过的:status=review_needed, signal降级→信号不充分 不会写进DB/JSON,除非修复了CRITICAL问题
This commit is contained in:
@@ -44,9 +44,11 @@ def _http_get(url, headers=None, timeout=10):
|
||||
|
||||
|
||||
def _detect_market(code):
|
||||
"""自动识别A股/港股"""
|
||||
"""自动识别A股/港股
|
||||
A股代码固定6位,港股代码5位(含前缀0如00700)。
|
||||
"""
|
||||
code = str(code).strip()
|
||||
if code.startswith("0") or code.startswith("3") or len(code) == 6:
|
||||
if len(code) == 6:
|
||||
return "ashare"
|
||||
if len(code) <= 5:
|
||||
return "hk"
|
||||
@@ -337,10 +339,10 @@ def _sina_hk(code):
|
||||
return {
|
||||
"code": code,
|
||||
"name": name,
|
||||
"price": price,
|
||||
"price": round(prev_close + change_amt, 2) if prev_close > 0 and abs(change_amt) > 0 else price,
|
||||
"change_pct": change_pct,
|
||||
"high": float(fields[5]) if fields[5] else None,
|
||||
"low": float(fields[6]) if fields[6] else None,
|
||||
"high": None, # Sina HK format不含high/low字段
|
||||
"low": None,
|
||||
"open": float(fields[4]) if fields[4] else None,
|
||||
"prev_close": prev_close,
|
||||
"volume": None,
|
||||
@@ -366,7 +368,7 @@ def _tencent_hk(code):
|
||||
prev_close = float(fields[4]) if fields[4] else 0
|
||||
if price <= 0:
|
||||
return None
|
||||
change_pct = float(fields[7]) if len(fields) > 7 and fields[7] else 0
|
||||
change_pct = round((price - prev_close) / prev_close * 100, 2) if prev_close > 0 else None
|
||||
return {
|
||||
"code": code,
|
||||
"name": name,
|
||||
|
||||
Reference in New Issue
Block a user