refactor: retire price_events.json completely — DB is the only store
User directive: no JSON, retire it fully, fix all related code. Changes: - price_monitor.py: record_event writes DB only; removed EVENTS_PATH/ load_events/save_events entirely - strategy_feedback.py: price events read from DB only (removed JSON fallback) - system_health_check.py: removed price_events.json from file-check list, DB-only event stats (was showing 0/0 due to wrong-DB resolution) - mo_config.py: removed dead price_events_path property (no callers) - mofin_health.py: price_events freshness reads DB table (authoritative now) - mofin_db.py: DATA_DIR/DB_PATH now ABSOLUTE (/home/hmo/MoFin/data) — was relative __file__.parent, so each hardlinked copy of mofin_db.py resolved to a DIFFERENT database (canonical vs web-dashboard vs profile-local third DB with 0 rows of everything except market_snapshots). This fragmentation was the real cause of health checks reading empty tables. - Unified all 4 mofin_db copies (root/scripts/deploy/profile) via hardlink - price_events.json archived to trashbox (fully backfilled: 6353 rows in DB) Verified: - record_event lands in DB only, JSON not recreated - system_health_check: 历史事件 6353 / 今日事件 2965 (was 0/0) - strategy_feedback + price_monitor full runs clean
This commit is contained in:
@@ -18,7 +18,6 @@ from mo_data import read_decisions
|
||||
|
||||
DATA_DIR = Path(__file__).parent.parent / "data"
|
||||
ACCURACY_PATH = DATA_DIR / "accuracy_stats.json"
|
||||
EVENTS_PATH = DATA_DIR / "price_events.json"
|
||||
FEEDBACK_PATH = DATA_DIR / "strategy_feedback.json"
|
||||
|
||||
|
||||
@@ -174,15 +173,16 @@ def generate_adjustment(decision, phase_check, accuracy_trend):
|
||||
|
||||
def run():
|
||||
decisions = read_decisions()
|
||||
# 优先从 SQLite 读取价格事件
|
||||
# 价格事件:只从 DB price_events 表读(JSON 已退役)
|
||||
try:
|
||||
from mofin_db import get_conn, query_price_events
|
||||
conn = get_conn()
|
||||
pe_rows = query_price_events(conn, limit=50000)
|
||||
conn.close()
|
||||
events = {"events": pe_rows}
|
||||
except Exception:
|
||||
events = load_json(EVENTS_PATH, {"events": []})
|
||||
except Exception as e:
|
||||
print(f"[strategy_feedback] DB价格事件读取失败: {e}", file=sys.stderr)
|
||||
events = {"events": []}
|
||||
accuracy_stats = load_json(ACCURACY_PATH, {})
|
||||
|
||||
accuracy_trend = compute_accuracy_trend(accuracy_stats)
|
||||
|
||||
Reference in New Issue
Block a user