From 037d9cd26cc2b5dbeb21f7961bf3f9b029068c8a Mon Sep 17 00:00:00 2001 From: freedakgmail Date: Wed, 22 Jul 2026 07:49:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E9=80=80=E5=B8=82/ST?= =?UTF-8?q?=E8=82=A1=E7=A5=A8=E8=BF=87=E6=BB=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sync_kline.py: get_all_stock_codes SQL 添加 ST 过滤 - full_signal_scan.py: get_all_stock_codes SQL 添加 ST 过滤 - routes/analysis.py: total_stocks/triggered_stocks/信号分布/推荐分布 统计查询统一添加退市/ST过滤,确保分母与过滤后扫描范围一致 --- stock-html/full_signal_scan.py | 1 + stock-html/routes/analysis.py | 9 +++++++-- stock-html/sync_kline.py | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/stock-html/full_signal_scan.py b/stock-html/full_signal_scan.py index a589721..8beb319 100644 --- a/stock-html/full_signal_scan.py +++ b/stock-html/full_signal_scan.py @@ -62,6 +62,7 @@ def get_all_stock_codes(conn): SELECT code, name FROM stock_realtime_price WHERE volume > 0 AND price > 0 AND name NOT LIKE '%%退%%' + AND name NOT LIKE '%%ST%%' AND name NOT LIKE 'PT%%' ORDER BY code """) diff --git a/stock-html/routes/analysis.py b/stock-html/routes/analysis.py index 3b5dc33..bf504c5 100644 --- a/stock-html/routes/analysis.py +++ b/stock-html/routes/analysis.py @@ -717,7 +717,8 @@ def get_scan_results(): ) total_scanned = cur.fetchone()[0] - cur.execute("SELECT count(*) FROM stock_realtime_price") + cur.execute("""SELECT count(*) FROM stock_realtime_price + WHERE name NOT LIKE '%%退%%' AND name NOT LIKE '%%ST%%' AND name NOT LIKE 'PT%%'""") total_stocks = cur.fetchone()[0] where_clauses = ["scan_date = %s"] @@ -893,6 +894,7 @@ def get_scan_results(): count(*) as cnt FROM stock_signal_scan, jsonb_array_elements(signal_status) s WHERE scan_date = %s AND (s.value->>'triggered')::boolean = true + AND name NOT LIKE '%%退%%' AND name NOT LIKE '%%ST%%' GROUP BY s.value->>'name', s.value->>'type' ORDER BY cnt DESC """, (scan_date,)) @@ -904,6 +906,7 @@ def get_scan_results(): cur.execute(""" SELECT count(*) FROM stock_signal_scan WHERE scan_date = %s AND triggered_count > 0 + AND name NOT LIKE '%%退%%' AND name NOT LIKE '%%ST%%' """, (scan_date,)) triggered_stocks = cur.fetchone()[0] @@ -919,6 +922,7 @@ def get_scan_results(): cur.execute(""" SELECT code, signal_status, indicators, triggered_count FROM stock_signal_scan WHERE scan_date = %s + AND name NOT LIKE '%%退%%' AND name NOT LIKE '%%ST%%' """, (scan_date,)) recommend_counts = {} for r in cur.fetchall(): @@ -1141,7 +1145,8 @@ def get_scan_status(): ) scanned = cur.fetchone()[0] - cur.execute("SELECT count(*) FROM stock_realtime_price") + cur.execute("""SELECT count(*) FROM stock_realtime_price + WHERE name NOT LIKE '%%退%%' AND name NOT LIKE '%%ST%%' AND name NOT LIKE 'PT%%'""") total = cur.fetchone()[0] cur.execute( diff --git a/stock-html/sync_kline.py b/stock-html/sync_kline.py index 563b004..289863c 100644 --- a/stock-html/sync_kline.py +++ b/stock-html/sync_kline.py @@ -60,6 +60,7 @@ def get_all_stock_codes(conn): SELECT code, name FROM stock_realtime_price WHERE volume > 0 AND price > 0 AND name NOT LIKE '%%退%%' + AND name NOT LIKE '%%ST%%' AND name NOT LIKE 'PT%%' ORDER BY code """)