Commit Graph
124 Commits
Author SHA1 Message Date
知微 9f44715b61 feat: add watchlist auto-reassessment to per_stock_reassess
- Add scan_watchlist_stocks() function that scans watchlist_stocks table
- Deviation formula: max(|price-entry_low|,|price-entry_high|)/entry_low*100 > 20%
- Calls technical_analysis.full_analysis() to get latest support/resistance
- Updates entry_low/entry_high/stop_loss/price/analysis_json in DB
- Records changelog in analysis_json with old/new values
- Limits to 3 stocks per run, logs remaining=N for overflow
- Scans watchlist AFTER decisions scan in main() (no changes to decisions logic)
2026-07-07 11:48:45 +08:00
知微 43bd84a7c0 feat: 全局cron job健康监控, failed时主动推XMPP 2026-07-07 11:29:56 +08:00
知微 5ffc487659 fix: 审计度量修正——reassess写strategy_evaluations非holding_strategies 2026-07-07 11:27:56 +08:00
知微 ae35631208 自选股自动重评机制+000850华茂股份9维分析
fix: per_stock_reassess 现在支持自选股(不在decisions.json)触发的重评
  - 不在decisions_map的code→查watchlist_stocks表构建entry
  - 重评完成后同步回watchlist_stocks表
  - is_watchlist=True传给reassess_strategy确保正确分类

fix: stale_detector的[AUTO_REASSESS]路径现在能真正触发自选股重评
  - 价格偏离买入区中心>15%→触发per_stock_reassess
  - 结果写回DB watchlist_stocks表+decisions.json

feat: 000850华茂股份完整9维分析
  - 横: 大盘偏弱但个股独立/纺织板块/金融资产折价
  - 纵: PE72.79虚高(被金融收益摊薄)/PB0.80破净(安全垫)
  - 消息面: 7/16临时股东会催化
  - 技术面: MA5>MA10>MA20多头初成/缩量回踩健康
  - 资金流: 量比1.21放量上攻后缩量回踩(正常)
  - 买入区3.70~3.90现价3.81在区内→策略有效维持
  - 止损3.50/止盈4.30/RR=1.6
2026-07-07 11:27:46 +08:00
知微 4689849c9d fix: 管道审计+全局cron失败监控, 异常时主动推XMPP 2026-07-07 11:27:09 +08:00
知微 5320509893 fix: stale_detector per_stock_reassess参数修正(--code→位置参数) 2026-07-07 11:20:28 +08:00
知微 7b4826777a 自选股自动重评机制+000850华茂股份全面重评
1. stale_detector新增自选股买入区偏离自动重评:
   - 每轮扫描watchlist_stocks, price偏离买入区中心>15%自动触发per_stock_reassess
   - 之前只标记[STRATEGY_STALE]不输出,改为标记+触发重评两步完成
   - 策略完毕直接输出结果,不再等下次cron通知

2. 000850华茂股份全面重评:
   - 核心价值:纺织是壳,金融股权投资才是核心(国泰海通/广发/徽商银行)
   - PB=0.78破净, 7月3日分红3675万占年净利17.85%
   - 7/16临时股东会催化剂
   - 结论:3.70~3.90区间可建仓1~2%,止损3.50,止盈4.30
   - 修复:之前说'观望不建仓'是错的,低估了破净安全垫

3. watchlist_stocks DB加000850记录
2026-07-07 11:20:04 +08:00
知微 096fbbf5f6 fix: sqlite3.Row没有.get()方法, r.get('cost',0)静默失败→改为r['cost'] if r['cost'] else 0 2026-07-07 11:05:21 +08:00
知微 7c255d5234 fix: 统一DB路径+管道审计脚本
mo_data.py DB_PATH: /home/hmo/web-dashboard/data/mofin.db → /home/hmo/MoFin/data/mofin.db
新增 verify_reassess_pipeline.py:管道审计,静默时无声、异常时报警
2026-07-07 10:37:05 +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
知微 2138ae2bfd fix: 代码级强制约束——LLM看到数据前必须同步重评(stale/无策略), 不等TODO异步
mofin_collect.py步骤0改造:
  stale(>4h未更新) → 立即调reassess_with_context()强制重评, 不靠TODO异步
  无策略(holding_strategies无记录) → 立即调reassess_with_context()创建策略
  只有重评成功后才允许LLM给出建议
2026-07-07 10:14:21 +08:00
知微 bbd90a005e feat: 代码级策略新鲜度强制检查 — mofin_collect.py步骤0, 推荐前先检策略是否最新, 过期自动创TODO 2026-07-07 10:10:01 +08:00
知微 fbbb96020f fix: system_health_check不再误报market.json/decisions.json缺失(DB-only已迁移) 2026-07-07 09:20:49 +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
知微 e185b4e4dc feat: DB-first architecture with lock-safe writes
- price_monitor: writes live prices to both JSON and mofin.db (holdings + live_prices + portfolio_summary)
- mofin_db: added execute_with_retry/commit_with_retry with exponential backoff on 'database is locked'
- mofin_db: increased timeout 5s->15s, added PRAGMA busy_timeout=15000
- price_monitor retry loop: fixed break-before-if-ok bug (was not retrying on write failure)
- DB connection: WAL mode + retry decorator for all write operations
- cash sync: preserves DB authoritative cash (JSON cash not pushed to DB)

This is the DB-first version. JSON writes remain for dashboard compatibility.
Next step: remove JSON writes entirely for full DB-only architecture.
2026-07-06 12:02:11 +08:00
知微 687155487d feat: strategy-staleness-check auto-creates TODOs for STRATEGY_STALE stocks 2026-07-05 01:41:10 +08:00
知微 5b9f22a643 test: 33/33 pass + fix last 4 json.load in strategy_lifecycle + analytics dead code 2026-07-04 09:45:27 +08:00
知微 8b114d6e9e refactor: remove duplicate scripts + JSON constants + update docs 2026-07-04 09:30:50 +08:00
知微 9337130ca2 fix: HK stocks store HKD, calc_total_assets converts to CNY at aggregation 2026-07-03 23:29:37 +08:00
知微 8e487f400f fix: system_audit/stale_push_wlin/refresh_mtf → DB, remove final JSON refs 2026-07-03 23:19:32 +08:00
知微 9bc0cca174 fix: HK currency→CNY + portfolio_summary + LLM prompt evaluation.json→DB 2026-07-03 23:15:18 +08:00
知微 b15960ba38 全数据路径审计修复完成:所有脚本从DB读数据
最终修复:
1. price_monitor: HK股存HKD原值, currency=HKD (移除x0.87转换)
2. strategy_lifecycle: 质量门禁currency=CNY→HKD/CNY均可
3. strategy_lifecycle: 新建策略currency动态判断
4. stale_push_wlin: 所有read_decisions()+read_portfolio()替代json.load
5. stale_detector: read_portfolio()替代json.load(PORTFOLIO_PATH)
6. per_stock_reassess: json.dump(decisions.json)→mo_data写入
7. DB holdings/holding_strategies: 8只HK股currency=HKD,价格修正
8. 建滔84.45 HKD浮亏-4.3%(之前报-24%)
9. 现金132,121.93总资产953,295
10. LLM cron prompts已改为全部从mo_data读
2026-07-03 17:14:56 +08:00
知微 908dc6a897 全数据路径审计修复:price_monitor HK股价不再转CNY
审计发现(2026-07-03 15:00 systematic audit):
1. price_monitor 港股仍转 CNY (line 255, 306) → 改为存 HKD 原值, currency=HKD
2. strategy_lifecycle 质量门禁检查 currency=CNY (line 88-91) → 改为接受 HKD/CNY
3. strategy_lifecycle 新建策略写 currency='CNY' (line 2299) → 改为按代码判断 HKD/CNY
4. stale_push_wlin 两处直接 json.load(open(decisions.json)) → 改为 read_decisions()
5. stale_push_wlin 直接 json.load(open(portfolio.json)) → 改为 read_portfolio()
6. DB holdings/holding_strategies: 8只HK股currency从CNY改为HKD
7. calc_total_mv 增加港股HKD→CNY汇兑计算

验证:
- 建滔 84.45 HKD 浮亏-4.3%(不是-24%)
- 现金 132,121.93 总资产 953,295
- 所有8只HK股DB正确标记HKD
- price_monitor已重启,下个tick用新逻辑写HKD原值
- stale_push_wlin已换用mo_data读DB
2026-07-03 17:13:19 +08:00
知微 5bd8af20ac migrate: live_prices+mtf+capital_flow DB read/write, cleanup remaining JSON refs 2026-07-03 13:46:12 +08:00
知微 bb9b3922c9 migrate: last 4 JSON files — live_prices, market, mtf_cache, capital_flow → DB 2026-07-03 13:44:10 +08:00
知微 c1c4ba4a81 fix: price_monitor HKD→CNY + Eastmoney 2s timeout + None-safe + summary fix 2026-07-03 13:24:10 +08:00
知微 9124a7ad56 migrate: remove final JSON cold backup lines, prune/branch→DB 2026-07-03 12:41:20 +08:00
知微 b3bedc8024 migrate: remove JSON, DB-only — mo_data, server, scripts, prompts (27 files) 2026-07-03 12:12:05 +08:00
知微 6eecc4d4eb fix: currency+PnL+is_hk_stock+gate+zone+total_pnl 2026-07-03 10:27:17 +08:00
知微 1bb83c715d data_snapshot统一数据入口+DB银行locked修复+建滔/现金修正
data_snapshot.py: 所有报告脚本的唯一数据入口(通过mo_data读DB)
price_monitor.py: DB写入加了3次重试+PRAGMA busy_timeout=5000
quality gate: 新增GATE_PROFIT_EXISTS(止盈=0拦截)+GATE_9D_ANALYSIS
建滔(01888) DB已修正: price=84.9 HKD, cost=88.23 HKD, 浮亏-3.8%
现金已修正: 132,121.93 (frozen=0)
2026-07-03 10:12:21 +08:00
知微 400e4ee34d review_needed 跟进机制 + 质量门禁文档
新增 review_needed_watchdog.py:
- 每30分钟扫描 review_needed 策略
- 自动调 per_stock_reassess 重评
- 重试3次仍失败 → 推Dad XMPP人工介入
- cron: 交易日 9:30~15:30

news-flow-analysis skill 文档同步更新:
- 完整 review_needed 流程链
- 自动修复→重检→跟进→上报 闭环
2026-07-02 14:04:15 +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
知微 04b8a6d4bc mo_data: +write_cash_log 函数
cash_log表已存在,新增写入函数便于截图/交易变更时记录现金流水。
用于process_trade.py、手动改cash时调用,保证现金变更可追溯。

知识萃取-盘后 cron 已暂停(莫荷接手知识库报告)
2026-07-02 01:43:33 +08:00
知微 69c6c5633a feat: 筹码S/R集成到reassess_strategy
- calc_chip_sr(): 从筹码分布计算支撑/阻力
- reassess_strategy新增筹码S/R输出+共振检测
- 止损用枢轴(短期),目标参考筹码(中线)
- 两者差距<3%时标记共振
2026-07-02 00:57:54 +08:00
知微 7f8b27df3b feat: 筹码因子模块 + 分钟K线 + 历史数据回填
scripts/chip_factors.py:
- _build_chip_distribution(): 从60日日线OHLCV估算筹码分布
- calc_all(): 计算三大筹码因子(穿透率/当日穿透率/乖离率)
- batch_calc(): 批量计算全部持仓+自选
- chip_cache/: 缓存每日筹码状态(支持因子滚动计算)

mo_provider.py:
- get_minute_kline(): 1分钟K线获取(1s限流, 单次最多240条)

首次运行结果: 33只股票完成筹码分布计算
最高亏损筹码占比: 万科99.5% 神华98.6% 比亚迪股份98.7%
最低亏损筹码占比: 建滔4.0% 药明康德2.1%
2026-07-02 00:36:35 +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
知微 671fe4ecc2 feat: price_monitor cron entry + health check script (DB freshness monitoring) 2026-07-01 23:07:24 +08:00
知微 ec285669c4 fix: deploy scripts/ files properly (correct directory) 2026-07-01 23:00:28 +08:00
知微 8ed755bff9 feat: strategy_lifecycle + stale_detector + server — DB-first price reads, Tencent API as fallback only 2026-07-01 22:48:48 +08:00
知微 849495c4ba fix: remove stale_push_wlin hardcoded 0.87 fallback — imports mo_models directly, no shadow functions 2026-07-01 22:39:20 +08:00
知微 f50b93d427 feat: eliminate duplicate price fetches — stale_push_wlin + per_stock_reassess now read from DB instead of self-pulling Tencent API 2026-07-01 22:32:30 +08:00
知微 e8653acd37 sync: 全部cron脚本同步+游离代码归位+关键依赖部署
- 11个不一致cron脚本同步(MoFin→profile)
- 4个游离代码收入MoFin(300308_monitor/monitor_300308/refresh_mtf_cache/strategy-staleness-check)
- 6个关键依赖部署到profile(mo_models/mo_config/mo_provider/hk_rate/data_governance/data_validate)
2026-07-01 00:02:56 +08:00
知微 00b0e643d1 feat: holdings_reconciliation + process_trade + import_holding_xls → DB writes 2026-06-30 23:56:51 +08:00
知微 236e67fa71 fix: NEAR_SL false alarm — add cost check, relabel as PROFIT_PROTECT when floating profit >5% 2026-06-30 23:33:37 +08:00
知微 28c001684e 币种标记标准化 + data-pipeline诊断文档
stale_detector: HK股价格输出加(HKD)标记,防止LLM混读CNY/HKD
per_stock_reassess: 写回decisions.json的HK股加上currency: HKD
docs/data-pipeline-diagnosis.md: 完整数据管道重构需求文档

避免建滔积层板CNY/HKD错配类问题复发
2026-06-30 11:13:45 +08:00
知微 6cbc433c20 fix: 莫荷审计三个问题修复
1. macro_context_collector DB路径修复(__file__相对路径→绝对路径)
2. system_audit双cron移除no_agent版(保留LLM版,17:30单次)
3. deliver=origin问题已记录,属架构层需统一改deliver=local+中转
2026-06-30 03:20:47 +08:00
知微 fb74c8bbb5 fix: capital_flow_collector+per_stock_reassess归位 2026-06-30 03:12:59 +08:00
知微 fa45d8aa5f fix: 小果地址统一node122(兼容LAN+EasyTier)
- health_checklist.json: 192.168.1.122→node122
- ocr_client.py: docstring IP→node122
- docs/market-data-requirements.md: IP→node122
- 所有API调用通过ProxyHandler({})绕过系统代理
  Privoxy对node122:18003返回500,直连正常
2026-06-30 02:56:35 +08:00
知微 8f0ee37aa4 sync: 游离代码归位+node122地址
- stale_push_wlin.py/stock_scorer.py/xiaoguo_signal_consumer.py →
  同步MoFin(含mo_models更新)到profile
- xiaoguo_scanner.py → 从profile收入MoFin(游离归位)
- 小果地址从硬编码192.168.1.122改为node122(兼容内外网自动切换)
2026-06-30 02:48:27 +08:00
hmo f4b2467ae9 fix: replace hardcoded 192.168.1.122 with node122 (hostname resolves via /etc/hosts to LAN or EasyTier)
- mo_config.py: xiaoguo_host=node122, xiaoguo_api_url property
- market_screener.py, xiaoguo_scanner.py, xiaoguo_news_processor.py: use mo_config or node122 fallback
- scripts/intraday_health_check.py, scripts/ocr_client.py: node122
- EasyTier connects at 10.144.144.2 when off-LAN
2026-06-30 02:27:52 +08:00