fix: 全面系统修复 — delivery目标修正 + 脚本同步 + refresh_mtf_cache import修复 + clean_watchlist硬编码修复
修复清单: - cron delivery修正:10个job从deliver=origin/all改为local,消除推送错误 - refresh_mtf_cache.py:替换strategy_lifecycle.PORTFOLIO_PATH导入为mofin_db直接读DB - clean_watchlist.py:修复mo_data导入名错误和JSON硬编码路径 - MoFin/scripts/与profile scripts互相补全,双向sync到一致 - price_monitor.py:现金源从portfolio_summary表改为cash_log(Dad确认的现金权威) - 更新watchlist.json加入000850华茂股份
This commit is contained in:
+15
-6
@@ -153,14 +153,23 @@ def refresh_data_prices():
|
||||
print(f"❌ DB写持仓失败(3次重试耗尽): {msg}", file=sys.stderr)
|
||||
break
|
||||
|
||||
# 重新计算市值(不变现金——DB的cash是权威)
|
||||
# 重新计算市值(现金从cash_log取最新Dad确认值——price_monitor不再持有现金权威)
|
||||
mv = calc_total_mv(db_holdings)
|
||||
# 读取DB当前的现金和冻结,不覆盖
|
||||
existing = conn.execute(
|
||||
'SELECT cash, frozen_cash FROM portfolio_summary WHERE id=1'
|
||||
# 从cash_log读取最新verified现金(Dad确认的才是权威),不读portfolio_summary
|
||||
latest = conn.execute(
|
||||
'SELECT cash_after, frozen_after FROM cash_log '
|
||||
'WHERE verified=1 ORDER BY id DESC LIMIT 1'
|
||||
).fetchone()
|
||||
db_cash = existing['cash'] if existing else 0.0
|
||||
db_frozen = existing['frozen_cash'] if existing else 0.0
|
||||
if latest:
|
||||
db_cash = latest['cash_after'] or 0.0
|
||||
db_frozen = latest['frozen_after'] or 0.0
|
||||
else:
|
||||
# 首次运行/无cash_log记录时回退到summary现存值
|
||||
existing = conn.execute(
|
||||
'SELECT cash, frozen_cash FROM portfolio_summary WHERE id=1'
|
||||
).fetchone()
|
||||
db_cash = existing['cash'] if existing else 0.0
|
||||
db_frozen = existing['frozen_cash'] if existing else 0.0
|
||||
assets = calc_total_assets({'holdings': db_holdings, 'cash': db_cash, 'frozen_cash': db_frozen})
|
||||
position_pct = round(mv / assets * 100, 2) if assets > 0 else 0
|
||||
write_portfolio_summary(conn, {
|
||||
|
||||
Reference in New Issue
Block a user