fix: 根因-①promote INSERT price写死0→用实时价_price ②per_stock三表无价加stock_quote直查(600262无价格→重评计算全崩→推送14.87买/14.80止损)
This commit is contained in:
@@ -306,6 +306,19 @@ def main():
|
||||
if price > 0:
|
||||
print(f" 实时价: {price} (来自DB)")
|
||||
else:
|
||||
# 2026-08-18 修复:三表无价时 stock_quote 直查(600262 案例:promote 后未进价格表→price=0→计算全崩)
|
||||
try:
|
||||
import subprocess, json as _jj2
|
||||
_rq = subprocess.run(["python3", "/home/hmo/.hermes/profiles/position-analyst/scripts/stock_quote.py", code_raw],
|
||||
capture_output=True, text=True, timeout=10)
|
||||
_qq = _jj2.loads(_rq.stdout)
|
||||
_qprice = float(_qq.get("price", 0))
|
||||
if _qprice > 0:
|
||||
price = _qprice
|
||||
print(f" 实时价: {price} (stock_quote直查)")
|
||||
except Exception as _qe:
|
||||
print(f" stock_quote直查失败: {_qe}", file=sys.stderr)
|
||||
if price <= 0:
|
||||
# fallback to DB portfolio data
|
||||
_pf_data = read_portfolio()
|
||||
for _h in _pf_data.get("holdings", []):
|
||||
|
||||
@@ -248,7 +248,7 @@ def main():
|
||||
sector_context, quality_check)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,'自选策略','scan',
|
||||
'active',?,'关注',?,?,?,'', 'pending')
|
||||
""", (code, name, 0, el, eh, sl, tp, timing_signal, action, _rr, source_strategy, now, now))
|
||||
""", (code, name, _price, el, eh, sl, tp, timing_signal, action, _rr, source_strategy, now, now))
|
||||
newly_added = cur.rowcount > 0
|
||||
|
||||
conn.execute("UPDATE candidates SET promoted=1 WHERE code=?", (code,))
|
||||
|
||||
Reference in New Issue
Block a user