36 Commits
Author SHA1 Message Date
xxm 320859e48b fix: 币种normalize——holdings中文币种(人民币/港币)→CNY/HKD,price_monitor校验raise改normalize(脏数据raise杀死整个refresh循环,live_prices停滞70分钟根因) 2026-08-25 14:27:39 +08:00
xxm e781f7fe47 fix: 价格更新后同步重算market_value(知微11:56修复,两次被deploy_guard回滚,代为入库)——持仓市值漂移根治 2026-08-25 14:08:01 +08:00
xxm 855c8631c2 fix: reassesed_codes定义挪到并发段引用之前——919行extend在937行定义之前→UnboundLocalError,price_monitor每次zones触发就崩(昨天并发重构引入,知微Kanban抓包) 2026-08-25 11:38:02 +08:00
xxm 20abd77e09 feat: price_monitor重评并发化——zones循环触发快判收集pending,循环后ThreadPoolExecutor(6=OCG router 6key)并发跑12维重评+结果推送(止损/区间两分支逻辑提取为_reassess_one,共享_can_push加锁), 老莫:6个key在搞什么串行 2026-08-24 16:04:15 +08:00
xxm b2f0c72977 fix: 重评timeout链放宽——per_stock call_llm 90→300(ocg_router单key上游180s+失败换key重试,90s客户端先断=自己限死自己),子进程180→600,alarm→600 2026-08-24 16:01:10 +08:00
xxm 936a9b8358 fix: price_monitor超时治理——alarm120→300(监控面36→112只后120s在refresh阶段就被杀,zones循环跑不到) + 指标联动整体预算10s(每只5s超时×114=必撞alarm) [603920盲区第三环] 2026-08-24 14:52:51 +08:00
xxm 896d0bb002 fix: check_codes拉价集合兜底——trig空但主层有止损/区间/止盈的策略也纳入(603920盲区第二环:zones兜底修了但价格根本没拉,price_info=None仍跳过) 2026-08-24 14:34:39 +08:00
xxm 69cd0478af fix: zones监控盲区根治——trigger_json='{}'的版本化策略(76/112条)完全脱离止损/止盈/买入区监控,zones循环改用主层字段兜底构建(603920破止损36.57无告警根因;8/21版本化改造写入trigger_json='{}'所致) 2026-08-24 14:23:26 +08:00
xxm 30dbb8a667 fix: 推荐链路+消息路由5修——①push_recommend_alert notify未导入(推荐推送全灭根因)②action判重(深套持有重复)③518880成本列错位h[2]shares→h[3]cost④_push_action分类路由:操作信号才上XMPP,异动/止损/急跌只进broadcast⑤anomaly_monitor delivery→broadcast 2026-08-24 11:08:16 +08:00
xxm f621e5466c fix: 重评链路全修——①strategy_lifecycle 942行detect_scenario残留(8/20四态废弃漏改,所有12维重评NameError全崩)②_do_llm_reassess子进程rc校验+reassessed_at新鲜度校验(防旧策略冒充重评结论)③952行result None判空(每2分钟NoneType刷屏)④重评未生效发原始告警+人工核查标注(02202鬼消息根治) 2026-08-24 10:29:56 +08:00
xxm 0afff445b6 fix: price_monitor record_event 名称守卫(上次被deploy_guard回滚,重打) 2026-08-22 12:03:02 +08:00
xxm 20c05b6e7c feat(messenger): 全部77个活跃cron脚本接入统一消息通道(install_stdio_hook) 2026-08-21 22:34:25 +08:00
xxm b3c2c4f8d9 feat(price_monitor): 接入统一messenger——操作推荐归档broadcast+xmpp推送 2026-08-21 20:13:59 +08:00
xxm 15edc92371 feat(加工层): 实时技术指标计算+price_monitor联动+collect_data改为读stock_indicators
- 新增realtime_indicators.py: 盘中实时计算MA/支撑阻力/RSI/bias60/dist_ma20/ATR/candle_pattern
- price_monitor: 更新价格后联动计算实时指标写入stock_indicators
- batch_reassess collect_data: 从stock_indicators读取(不再重新计算ta.full_analysis)
- stock_indicators表: 新增strong_support/weak_support/pivot/weak_resist/strong_resist/candle_pattern字段
2026-08-21 05:12:18 +08:00
xxm cf9b87ef4d fix: price_monitor三处进区触发改为真12维LLM重评(_do_llm_reassess调per_stock_reassess)+30min冷却(补上次被回滚的commit,根治技术快算) 2026-08-20 05:33:56 +08:00
xxm ec6bdcb648 fix: 破止损推送——重评后带完整操作原因+逻辑自洽(重评持有则不推卖出,止损更新到重评值) 2026-08-17 10:16:49 +08:00
hmo 7e37fec704 feat: price_monitor交易时段双市场——改用is_trading_now(A股9:30-15:00/港股9:30-16:00),港股持仓15:00-16:00最后一小时破止损止盈监控不再漏(A股收盘后价格不变不误报,集合竞价保护保留) 2026-08-14 19:18:56 +08:00
hmo 21b16751c5 feat: 阶段4温区溯源按市场感知——market_config加get_regime_temp(code)(A股行为不变读smoothed顶层,港股读markets.hk),stale_push_wlin/price_monitor信号溯源改用 2026-08-14 17:56:10 +08:00
hmo 4c2821aa67 feat: 市场抽象层market_config.py——市场判断/行情符号/市场配置唯一事实源,收敛6处散落实现(market_data/price_monitor x2/stale_push_wlin/technical_analysis/strategy_lab)。纯重构行为等价,为港股接入打底 2026-08-14 15:56:47 +08:00
hmo 72e94f20f9 feat: price_monitor温区感知+信号溯源——非激活策略买入/加仓机会抑制(🧊温区未激活跳过),风控(卖出/止盈)仍推; 风控和买入机会都记录signal_ledger溯源 2026-08-13 21:49:02 +08:00
xxm 3eb19ea357 refactor: 移除v_combo波段出场硬编码(连续2日破MA10)——k线形态由LLM提示词判断(老莫原则), swing持仓统一走zones→LLM重评→timing_signal维持才发 2026-08-13 01:39:36 +08:00
xxm ea77bd5afd 异常浮窗+统一告警通道+冷却1小时: alert_logger统一异常写入(alerts.json+history.log+XMPP), 前端右上角浮动异常区(自动展开5秒折叠,只显示active), price_monitor接入异常钩子(重评失败/拉取失败/DB同步), 冷却30分->1小时+15分5%突发例外 2026-08-13 00:35:53 +08:00
hmo 4e324cca8c fix: price_monitor 告警只在连续竞价时段(9:30-11:30/13:00-15:00)触发——9:17集合竞价误报688002暴跌根因修复,竞价期虚拟价格不触发告警 2026-08-11 09:40:20 +08:00
xxm 7da799d4db fix: price_monitor自愈式单例守卫(进程堆积事故)
- cron每2分钟拉起+外网抖动挂起+timeout仅SIGTERM杀不动 → 5并发烧155%CPU
- 新鲜实例在跑则退出(防堆积); 卡死>300s则SIGKILL接管(自愈)
- 符合进程生命周期铁律(防重复启动+卡死检测+自动清理)
2026-08-05 14:57:10 +08:00
hmo 650e67c082 feat: v_combo落地Step3——price_monitor按exit_mode分派出场(swing波段出场/再进检测) 2026-07-30 03:44:44 +08:00
hmo 228c40c970 fix: price_monitor策略追踪conn未定义——止盈止损触发检查持续报错,修复后恢复SL/TP告警链路 2026-07-29 03:33:58 +08:00
hmo c572bbc3ef feat: 策略追踪评估系统(版本化+理论盈亏+浮盈/浮亏+自动SL/TP检测+30s刷新) 2026-07-27 19:03:05 +08:00
hmo b18e0d2164 fix: 关停进区摘要推送(噪音)+ per_stock结束也flush推荐摘要(688428式漏发根治) 2026-07-22 10:39:20 +08:00
hmo 8c2226e2b4 feat: 信号权威层级+推荐转场推送统一+🔔分级修正
1. 权威层级: 新鲜(<20h)12维动作级信号, 技术路径(regenerate_all/
   price_monitor)无权降级为关注/信号不充分/持有——只有LLM路径或
   风险信号(卖出/止盈)可覆盖。根治推荐区'出现-消失'抖动
2. 推荐转场推送统一收拢到 mofin_db.push_recommend_alert:
   tag新转为current_recommend时推送(全路径), 含质量门禁;
   移除batch_reassess内联推送(防双重告警)
3. price_monitor 🔔分级: 只有持仓股的卖出/止盈才ACTION直推,
   买入/加仓机会一律进INFO摘要(老爸: 这种消息不要再发了)
2026-07-22 09:48:58 +08:00
知微 a245c8b4dd fix: price_monitor crash when shares is string + type guard in write_holding_strategy
Root cause: holding_strategies.shares field got set to literal string
'write_holding_strategy' for 6 records, causing TypeError at
price_monitor.py line 611 ('>' not supported between str and int).

Fixes:
1. price_monitor.py: Replace set comprehension with safe loop that
   checks isinstance before comparison. Non-numeric shares treated
   as holdings for safety.
2. mofin_db.py write_holding_strategy: Add type guard that resets
   non-numeric shares to 0 with warning.
3. Data fix: Updated 5 corrupted holding_strategies records from
   holdings table (300035/300308/300750/518880/00700).
   Set 002594 (watchlist) shares=0.
2026-07-21 13:47:52 +08:00
知微 c180129a1a fix: add SIGALRM 120s hard timeout to price_monitor lock
price_monitor.py 进程锁无硬超时,LLM策略重评耗时9-10分钟时
锁文件阻止后续*/2 cron执行,造成10分钟监控盲区。

新增:
- _handle_sigalrm: SIGALRM处理器,自动清理锁后退出
- signal.alarm(120): 获锁后设120s硬上限
- signal.alarm(0): 正常完成时取消定时器
2026-07-21 11:29:06 +08:00
hmo 29e0e6c8b4 fix(688775事件): bot不再静默吞消息 + 价格推送分级 + 小果假警报清理
1. bot call_hermes 失败: 10s重试一次, 仍失败回兜底消息(网关暂时不可用)
   ——此前连接被拒时用户消息被静默吞掉(688775事件根因)
2. price_monitor 推送分级: 破止损/重评确认信号/持仓急跌=ACTION直通;
   未确认进区提示=聚合成一条摘要走INFO(30min限1条+8行截断)
   ——今早一秒一条十几连发+思特威英诺特双发
3. alert_helper ACTION 增加5min内容去重(防竞态双发)
4. intraday_health_check 删除小果全部残留检查(已退役, 假警报
   导致知微旧自愈执行器烧150k+token/session去调查并直接改代码)
2026-07-21 10:41:32 +08:00
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
hmo efdfaf956a 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
2026-07-20 17:46:57 +08:00
hmo 17305bed0b fix(pipelines): clear today's real cron errors + kill monitoring false alarms
Real errors fixed (all verified by manual run):
- price_monitor.py: shares None -> TypeError at L584 (now completes 3m7s,
  full 39-stock reassess + zone triggers + Dad push)
- market_insight.py: net_inflow None -> TypeError at L142 (now 0.3s, 5 insights)
- promote_candidates.py: add busy_timeout=30s (DB lock under concurrent writes)
- premarket_full_review.py: 12-dim analysis now detached background launch
  (was doomed by cron 120s script timeout no matter what)

Systemic:
- HERMES_CRON_SCRIPT_TIMEOUT=600 drop-in for both gateway services
  (fixes mofin_health SIGTERM, market_watch timeout, memory_guardian timeout)
- sync_profile_scripts.sh: re-hardlink deploy->profile scripts after every
  deploy (scp replaces files = new inode = broken hardlink = cron silently
  runs stale code; this caused promote to keep failing after my first fix)

Monitoring false-alarm fixes (the '花瓶' problem):
- mofin_health.py: legacy JSONs that migrated to DB (multi_tf_cache/
  macro_context/market/live_prices/price_history/macro_risk_state) no longer
  warn 'no readers'; marked as migrated
- NEW db_freshness section: real pipeline health from DB tables
  (mtf_cache 0.4h / macro_context_log 2h / market_snapshots 2h /
  live_prices 0.4h / price_events.json 0.4h — ALL HEALTHY)
- price_events freshness reads live JSON store (DB table is legacy)
- market.json placeholder created (13+ scripts have fallback paths)

Investigation notes: wiki-self-growth 03:04 key1 429 predates full key6
activation on default gateway; current 8642 verified on key6 and working.
Weekend 'Blocked' jobs verified fixed (vacuum_state_db passes).
2026-07-20 17:30:15 +08:00
知微 80d59c9331 feat: 统一部署目录——所有运行时文件归入MoFin repo
- deploy/bot/ — XMPP bot核心(xmpp_agent_core + xmpp_zhiwei_bot)
- deploy/profile-scripts/ — cron脚本(price_monitor等)
- 运行时文件已替换为指向MoFin的符号链接
- 改代码只需改MoFin,系统自动生效
2026-07-17 23:12:35 +08:00