fix: 买入区用live_prices+统一DB读取+报告前验价
This commit is contained in:
@@ -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,)
|
||||
|
||||
Reference in New Issue
Block a user