From a83c0ea11e9eba0f29d639772dfa6baa6714ae97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Thu, 9 Jul 2026 19:24:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20watchlist=20API=E6=94=B9=E7=94=A8holding?= =?UTF-8?q?=5Fstrategies+=E5=B8=82=E5=9C=BATabtrend=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 24 +++++++++++++++--------- static/index.html | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/server.py b/server.py index 3656155c..e7907568 100644 --- a/server.py +++ b/server.py @@ -103,17 +103,23 @@ def api_portfolio(): @app.route("/api/watchlist") def api_watchlist(): - """自选列表""" + """自选列表(从holding_strategies读取)""" try: - from mofin_db import get_conn, query_watchlist - conn = get_conn() - stocks = query_watchlist(conn) + import sqlite3 + conn = sqlite3.connect("/home/hmo/MoFin/data/mofin.db") + conn.row_factory = sqlite3.Row + rows = conn.execute(""" + SELECT code, name, entry_low, entry_high, stop_loss, take_profit, + timing_signal, action, price, rr_ratio, updated_at + FROM holding_strategies + WHERE status='active' AND decision_type='自选策略' + ORDER BY code + """).fetchall() conn.close() - if stocks: - return jsonify({"stocks": stocks}) - except Exception: - pass - return jsonify({"error": "数据库查询失败"}), 500 + stocks = [dict(r) for r in rows] + return jsonify({"stocks": stocks, "total": len(stocks)}) + except Exception as e: + return jsonify({"error": str(e)}), 500 @app.route("/api/overview") diff --git a/static/index.html b/static/index.html index 21120a9c..5ba9b450 100644 --- a/static/index.html +++ b/static/index.html @@ -374,6 +374,7 @@ function refreshMarketData() { const sectors = mkt.sectors || []; const sigs = signals || []; const cands = candidates || []; + const trend = sigs.filter(s => s.source && s.source !== 'xiaoguo'); el.innerHTML = `