fix(price_events): unify event storage to DB (dual-write + backfill)
User caught the inconsistency: system claims DB-first but price events only went to price_events.json, leaving DB table stale since Jul 6. Root cause chain found: - record_event() only wrote JSON, never called mofin_db.write_price_event - price_events.code has FK -> stocks(code); events for unregistered stocks (new candidates, HK) silently failed INSERT and were lost to DB - mofin_db.write_price_event swallows errors (returns False silently) Fixes: - record_event now dual-writes: DB (authoritative) + JSON (compat for legacy readers mo_config/strategy_feedback/system_health_check) - auto-registers unknown codes into stocks table before event insert - one-time backfill: 4064 JSON events -> DB (total 6353 rows, last=today) - verified: record_event TEST99 lands in both DB and JSON
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import sqlite3
|
||||
c = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
|
||||
sql = c.execute("SELECT sql FROM sqlite_master WHERE name='price_events'").fetchone()[0]
|
||||
print(sql)
|
||||
print()
|
||||
for r in c.execute("PRAGMA foreign_key_list(price_events)"):
|
||||
print(r)
|
||||
Reference in New Issue
Block a user