feat: 策略复盘闭环 Phase1
- 新增 scripts/strategy_review.py: 遍历所有active策略 - 腾讯API实时价对比止损/止盈/入场点 - 分类: correct/wrong/partial/pending - 失败模式归因: 止损过紧/入场过早/止盈过远等 - 写入 accuracy_stats 表(首条真实数据) - 新增 docs/strategy-review-loop.md: 完整闭环设计文档 - 含失败模式→修复方向映射表 Phase1 结果: 38条策略, 94.7%准确率(19条待定), 1条止损过紧
This commit is contained in:
+14
-1
@@ -1657,6 +1657,7 @@ def regenerate_all(stdout=True):
|
||||
"position_advice": result.get("position_advice", "中等仓位"),
|
||||
"time_horizon": result.get("time_horizon", "2周~3月"),
|
||||
}
|
||||
new_entry["trigger"] = trig
|
||||
# created_at: 首次创建时设置,后续 preserve
|
||||
old_entry = existing_decisions.get(code, {})
|
||||
if old_entry.get("created_at"):
|
||||
@@ -1786,7 +1787,19 @@ def regenerate_all(stdout=True):
|
||||
existing_pf = json.load(open(PORTFOLIO_PATH))
|
||||
except Exception:
|
||||
existing_pf = {}
|
||||
existing_pf["holdings"] = pf.get("holdings", [])
|
||||
# 保留 price/change_pct — price_monitor 维护的实时价,regenerate_all 不应清除
|
||||
_existing_holdings_map = {}
|
||||
for _h in existing_pf.get('holdings', []):
|
||||
if _h.get('code'):
|
||||
_existing_holdings_map[_h['code']] = _h
|
||||
_new_holdings = pf.get("holdings", [])
|
||||
for _h in _new_holdings:
|
||||
_code = _h.get('code')
|
||||
if _code and _code in _existing_holdings_map:
|
||||
_old = _existing_holdings_map[_code]
|
||||
_h['price'] = _old.get('price', 0)
|
||||
_h['change_pct'] = _old.get('change_pct', 0)
|
||||
existing_pf["holdings"] = _new_holdings
|
||||
existing_pf["updated_at"] = datetime.now().strftime('%Y-%m-%d %H:%M')
|
||||
json.dump(existing_pf, open(PORTFOLIO_PATH, "w"), ensure_ascii=False, indent=2)
|
||||
json.dump(wl, open(WATCHLIST_PATH, "w"), ensure_ascii=False, indent=2)
|
||||
|
||||
Reference in New Issue
Block a user