feat: 历史K线(Sina)驱动S2多日确认+10只新候选入自选
This commit is contained in:
@@ -125,6 +125,8 @@ def refresh_data_prices():
|
||||
all_codes.add(r['code'])
|
||||
for r in conn.execute("SELECT code FROM watchlist_stocks"):
|
||||
all_codes.add(r['code'])
|
||||
for r in conn.execute("SELECT code FROM holding_strategies WHERE status='active'"):
|
||||
all_codes.add(r['code'])
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
print(f"⚠️ 从DB读代码失败: {e}", file=sys.stderr)
|
||||
@@ -190,6 +192,11 @@ def refresh_data_prices():
|
||||
# 写实时价格表(供 read_live_prices 消费)
|
||||
live = {h['code']: {'price': h.get('price',0), 'change_pct': h.get('change_pct',0)}
|
||||
for h in db_holdings if h.get('code')}
|
||||
# 补充自选股/策略股的价格(它们不在holdings表中)
|
||||
for code, pdata in prices.items():
|
||||
if code not in live:
|
||||
live[code] = {'price': pdata[0] if isinstance(pdata, (list, tuple)) else pdata.get('price',0),
|
||||
'change_pct': pdata[1] if isinstance(pdata, (list, tuple)) else pdata.get('change_pct',0)}
|
||||
write_live_prices(conn, live)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
Reference in New Issue
Block a user