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 = `