Commit Graph
26 Commits
Author SHA1 Message Date
hmo d5b8bec897 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
2026-07-20 18:10:05 +08:00
知微 b4a5020cf5 fix: 暴跌告警仅持仓触发 + 状态立即持久化防重复推送 2026-07-14 15:33:35 +08:00
知微 377bb4d1e4 price_monitor: 5min regenerate_all冷却 + 跳过冗余全量重评 2026-07-14 11:48:34 +08:00
知微 3ee3d9ba6c fix: price_monitor添加os.nice(10)降低优先级减少DB竞争 2026-07-14 10:47:58 +08:00
知微 93dce81413 fix: price_monitor DB写锁死锁根治 + mofin_db.py reassessed_at同步
1. price_monitor.py: 统一BEGIN IMMEDIATE包裹所有DB写操作,
   5次重试+指数退避(1→2→4→8→16s),重试耗尽后自动
   emergency WAL checkpoint,try/finally确保conn释放
2. 补充进程锁:防止cron每2分钟触发但脚本跑3分钟时的并发
3. mofin_db.py: 同步cron版本的reassessed_at列处理逻辑
2026-07-14 10:42:54 +08:00
知微 02d1c93923 fix(price_monitor): DB写锁死锁根治 - 统一BEGIN IMMEDIATE + 5次重试指数退避 + emergency WAL checkpoint
- 统一一个BEGIN IMMEDIATE事务包裹所有写操作,替代独立写函数调用
- 5次重试 + 指数退避 (1s,2s,4s,8s,16s),原3次+固定2s
- 重试耗尽后自动 emergency WAL checkpoint(TRUNCATE)释放死锁
- try/except确保连接始终释放,修复conn泄漏
- 三副本同步:profile/scripts + MoFin/scripts + MoFin/root
2026-07-14 10:30:15 +08:00
知微 be961c6af6 fix: _push_cooldown持久化到文件,避免每2分钟重复推送操作区间通知 2026-07-13 11:17:59 +08:00
知微 49ef74826a fix: 触发重评推送条件收紧(仅买入/加仓/卖出/止盈信号才推) 2026-07-10 13:43:39 +08:00
知微 b9ba737248 fix: 不构成操作建议不推XMPP+代码降级改报错+LLM失败=None 2026-07-10 13:29:32 +08:00
知微 c48429b994 feat: 单日暴跌>7%实时告警(不依赖zone边界) 2026-07-10 11:30:46 +08:00
知微 0c6dd82b30 fix: price_monitor同股同区间30分钟冷却去重 2026-07-09 23:05:00 +08:00
知微 bd744c252c feat: 历史K线(Sina)驱动S2多日确认+10只新候选入自选 2026-07-09 19:42:35 +08:00
知微 87b795f353 fix: 止盈区0.0美化显示+健康告警阈值放宽 2026-07-09 13:46:17 +08:00
知微 f2d80d1948 fix: price_monitor重评后不可操作→发说明(不再静默) 2026-07-09 11:33:03 +08:00
知微 bfb3309bc2 fix: ~/.hermes路径分裂导致price_monitor冷却失效+去重 2026-07-09 11:13:45 +08:00
知微 77150c37d0 fix: price_monitor买入提醒改为🔔通知(非🛒推荐)+标明已触发重评 2026-07-09 10:45:28 +08:00
知微 9e3c2ef170 fix: price_monitor.py 连环bug - 缺失import json + 元组解包不匹配 2026-07-08 18:54:33 +08:00
知微 2762ddf3ae fix: DB路径大面积修复——mofin_db/server/technical_analysis/strategy_tree等脚本的Path(__file__).parent/data错误指向scripts/data而非data/ 导致读写分离
- 量价分析: full_analysis输出volume_deep+成交量存储在price_history.json
- FK约束移除: holding_strategies外键->holdings阻止自选股写入
- #000850 重评已写入(止损3.74/止盈4.06/RR1.67)含量价信号
2026-07-08 12:34:39 +08:00
知微 26e2794cca fix: 代码级约束 —— 推荐前必须同步重评, 不输出无操作信号的信息
1. price_monitor: 区间突破后同步调reassess_with_context(), 明确信号推XMPP
2. stale_detector: 只输出有[PUSH]/[STRATEGY_STALE]标记的行, 静默无操作信号的买入区
3. mofin_collect: stale/无策略持仓同步重评, 不靠TODO异步
2026-07-07 10:31:50 +08:00
知微 66962ae190 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华茂股份
2026-07-06 14:01:54 +08:00
知微 8b114d6e9e refactor: remove duplicate scripts + JSON constants + update docs 2026-07-04 09:30:50 +08:00
知微 5bd8af20ac migrate: live_prices+mtf+capital_flow DB read/write, cleanup remaining JSON refs 2026-07-03 13:46:12 +08:00
知微 b3bedc8024 migrate: remove JSON, DB-only — mo_data, server, scripts, prompts (27 files) 2026-07-03 12:12:05 +08:00
知微 7c0e85af28 硬性策略质量门禁 validate_strategy()
新增 STRATEGY_QUALITY_GATES 检查清单(9条红线):
CRITICAL: 止损/止盈存在+>0, 买入区下沿<上沿
HIGH: 止损≤买入区, 买入推荐含RR≥1.5, 港股标currency=HKD
MEDIUM: signal短词, tech_snapshot含技术位

enforce_strategy_quality() 插在写入链的两处:
1. reassess_with_context() return前 → 单只重评必过
2. regenerate_all() for d in decisions: 写DB前 → 批量重评必过

不过的:status=review_needed, signal降级→信号不充分
不会写进DB/JSON,除非修复了CRITICAL问题
2026-07-02 13:46:53 +08:00
知微 6305204c7a feat: mo_data.py unified read layer (DB-first, JSON fallback) + cash_log table + batch JSON→DB migration (16 files) 2026-07-01 23:45:30 +08:00
知微 ec285669c4 fix: deploy scripts/ files properly (correct directory) 2026-07-01 23:00:28 +08:00