fix: 统一退市/ST股票过滤逻辑
- 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过滤,确保分母与过滤后扫描范围一致
This commit is contained in:
@@ -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
|
||||
""")
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
""")
|
||||
|
||||
Reference in New Issue
Block a user