fix(ui): 盯盘推荐区RR三值+个股弹窗DB化

- /api/stock/<code>: 从holding_strategies读策略/三值RR/action/full_analysis
  (原先只读data/stocks/{code}.json, 与DB脱节, 弹窗打开=空白)
- openStock弹窗: 新增当前策略卡(信号/区间/损盈/三值RR/仓位/操作建议)+12维分析折叠区
- 盯盘推荐区RR列: 中值下方小字显示下沿~上沿(上次改错表了, renderWatchlist≠盯盘推荐区)
This commit is contained in:
hmo
2026-07-22 23:25:34 +08:00
parent 0f2c6555df
commit 440ce56b0b
2 changed files with 67 additions and 2 deletions
+30 -1
View File
@@ -503,8 +503,37 @@ def api_report(report_id):
@app.route("/api/stock/<code>")
def api_stock(code):
"""个股详情 + 操作建议历史"""
"""个股详情DB策略(12维分析/action/三值RR)为主,JSON历史为辅。
根治:弹窗只读 data/stocks/{code}.json,与DB脱节,打开=空白。"""
stock_data = _load_json(DATA_DIR / "stocks" / f"{code}.json", {})
try:
conn = get_conn()
conn.row_factory = sqlite3.Row
r = conn.execute("""
SELECT hs.code, hs.name, hs.timing_signal, hs.action, hs.position_advice,
hs.entry_low, hs.entry_high, hs.stop_loss, hs.take_profit,
hs.rr_ratio, hs.rr_low, hs.rr_high, hs.full_analysis, hs.reassessed_at,
hs.tag, hs.decision_type,
lp.price AS live_price, lp.change_pct
FROM holding_strategies hs
LEFT JOIN live_prices lp ON hs.code = lp.code
WHERE hs.code=? AND hs.status='active'
""", (code,)).fetchone()
conn.close()
if r:
stock_data.update({
"code": r["code"], "name": r["name"],
"timing_signal": r["timing_signal"], "action": r["action"],
"position_advice": r["position_advice"],
"entry_low": r["entry_low"], "entry_high": r["entry_high"],
"stop_loss": r["stop_loss"], "take_profit": r["take_profit"],
"rr_ratio": r["rr_ratio"], "rr_low": r["rr_low"], "rr_high": r["rr_high"],
"full_analysis": r["full_analysis"], "reassessed_at": r["reassessed_at"],
"tag": r["tag"], "decision_type": r["decision_type"],
"price": r["live_price"], "change_pct": r["change_pct"],
})
except Exception as _e:
stock_data.setdefault("db_error", str(_e))
return jsonify(stock_data)