migrate: last 4 JSON files — live_prices, market, mtf_cache, capital_flow → DB
This commit is contained in:
+8
-6
@@ -12,7 +12,7 @@ from datetime import datetime
|
||||
|
||||
# ── MoFin unified model ──────────────────────────────────────────────
|
||||
from mo_models import is_hk_stock, get_hk_rate, calc_total_assets, calc_total_mv, calc_position_pct
|
||||
from mofin_db import get_conn, write_holdings_batch, write_portfolio_summary, write_price_event, write_watchlist_stock, write_holding_strategy
|
||||
from mofin_db import get_conn, write_holdings_batch, write_portfolio_summary, write_price_event, write_watchlist_stock, write_live_prices, read_capital_flow_cache, write_holding_strategy
|
||||
from mo_data import read_portfolio, read_decisions, read_watchlist
|
||||
|
||||
BREACH_PATH = "/home/hmo/.hermes/zone_breach.json"
|
||||
@@ -231,14 +231,16 @@ def refresh_data_prices():
|
||||
prices.update(hk_prices)
|
||||
updated = 0
|
||||
|
||||
# 保存全量实时价快照(供报告管道消费,确保分析用最新数据)
|
||||
# 保存全量实时价快照到 DB(替代 live_prices.json)
|
||||
try:
|
||||
live = {"updated_at": datetime.now().isoformat(), "prices": {}}
|
||||
live = {}
|
||||
for code in all_codes:
|
||||
if code in prices:
|
||||
p, c, chg = prices[code]
|
||||
live["prices"][code] = {"price": p, "change_pct": chg}
|
||||
json.dump(live, open("/home/hmo/web-dashboard/data/live_prices.json", "w"), indent=2)
|
||||
live[code] = {"price": p, "change_pct": chg}
|
||||
conn = get_conn()
|
||||
write_live_prices(conn, live)
|
||||
conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -663,7 +665,7 @@ def run_once(round_label=""):
|
||||
|
||||
# === 3.5 资金流异常检测(2026-06-27 新增)===
|
||||
try:
|
||||
cf = json.load(open("/home/hmo/web-dashboard/data/capital_flow_cache.json"))
|
||||
cf = read_capital_flow_cache(get_conn())
|
||||
# 检查所有 active decision 中的资金流异常
|
||||
for d in active:
|
||||
code = d["code"]
|
||||
|
||||
Reference in New Issue
Block a user