fix: 买入区用live_prices+统一DB读取+报告前验价

This commit is contained in:
知微
2026-07-10 10:26:14 +08:00
parent dbff6b59f9
commit 73df767ac0
2 changed files with 17 additions and 5 deletions
+7 -2
View File
@@ -741,14 +741,19 @@ def batch_fetch_prices(codes):
# 主通道:从 DB 读取(price_monitor 唯一价格入口)
try:
import sqlite3
db = sqlite3.connect('/home/hmo/web-dashboard/data/mofin.db')
db = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
db.row_factory = sqlite3.Row
for raw_code in codes:
raw_code = str(raw_code).split('_')[0]
if not raw_code: continue
# 优先级:live_prices > holdings > holding_strategies
row = db.execute(
"SELECT price, change_pct FROM holdings WHERE code=? AND is_active=1", (raw_code,)
"SELECT price, change_pct FROM live_prices WHERE code=?", (raw_code,)
).fetchone()
if not row:
row = db.execute(
"SELECT price, change_pct FROM holdings WHERE code=? AND is_active=1", (raw_code,)
).fetchone()
if not row:
row = db.execute(
"SELECT price, change_pct FROM holding_strategies WHERE code=? AND status='active' ORDER BY updated_at DESC LIMIT 1", (raw_code,)