Commit Graph
255 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
知微 6e03b62f69 chore: .gitignore排除运行时数据文件和db 2026-07-06 14:03:55 +08:00
知微 de6e5f6624 docs: 更新CHANGELOG — 2026-07-06全面系统修复记录 2026-07-06 14:03:27 +08:00
知微 e055485f53 chore: 加 .gitignore(取自code_only分支) 2026-07-06 14:02:24 +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
知微 3e2f0315eb 完全DB版: 移除JSON写入/回退,所有操作直走SQLite
- price_monitor: 完全DB版,不再读写 portfolio.json/watchlist.json
  - holdings代码从DB读取(SELECT code FROM holdings WHERE is_active=1)
  - 价格写入DB holdings表 + portfolio_summary + live_prices
  - 3次重试+指数退避防锁
- server.py: 移除API的JSON回退,DB失败直接返回500
- mofin_db.py: execute_with_retry/commit_with_retry + 15s timeout + busy_timeout
- mo_data.py: 已是纯DB模式(无JSON fallback)

这是推进的完全DB化。下一步可删除 data/portfolio.json data/decisions.json data/watchlist.json 等遗留JSON。
2026-07-06 12:08:08 +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
知微 320353348d feat: add todos table to mofin_db + DB_PATH fix for self_todo_executor 2026-07-05 01:37:40 +08:00
知微 574f1be3ec docs: reorganize — README index, archive old docs, add status headers 2026-07-04 10:22:51 +08:00
知微 58786d170b 00700 腾讯成本修复: 443.13 HKD
holdings/holding_strategies 表中 00700 的 cost 字段 =0,
从旧备份 data 追溯确认成本为 443.13 HKD,已修正。
portfolio.json 同步刷新。
验证: 00700 431.2 HKD 浮亏-2.7%(非-17.7%的币种错配数据)
2026-07-04 09:59:52 +08:00
知微 7f84471aca docs: development standards + test plan 2026-07-04 09:57:18 +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
知微 4e080d4fc5 docs: comprehensive test plan (10 categories, 70+ test cases) 2026-07-04 09:36:48 +08:00
知微 8b114d6e9e refactor: remove duplicate scripts + JSON constants + update docs 2026-07-04 09:30:50 +08:00
知微 7d6b08953c cash_log正式接入——所有现金变更写表审计
接入流程:
1. Dad确认/截图发送现金变更 → write_cash_log()记录before/after/frozen/source/note
2. portfolio_state + portfolio.json同时更新
3. cash_log表可审计查询,不再遗失任何现金变更
4. 清理重复cash_log条目(#4 #5)

当前已验证:cash=132,121.93 frozen=0.0
2026-07-03 23:53:04 +08:00
知微 a05b82cd6b fix: market_screener market.json→DB, remove all JSON refs 2026-07-03 23:48:29 +08:00
知微 b6959f73bc docs: update CHANGELOG + data model + mark decisions migration complete 2026-07-03 23:34:52 +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
知微 239590c0d4 现金132121.93/frozen=0写入DB portfolio_summary+portfolio.json
所有HK持仓currency=HKD,价格腾讯实时HKD原值
calc_total_mv正确汇兑处理
总资产953,295
2026-07-03 17:29:52 +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
知微 0bfb819110 DB港股价格+成本修复回HKD原值
笑笑重构把HK股的价格和成本都转CNY写入DB。
price_monitor同时改了新逻辑要写HKD,但DB已经是CNY,
两个方向打架导致建滔(-2.5%实际浮亏)被算成-15.5%。

修复:
  DB holdings表8只HK股的price和cost从CNY转回HKD
  currency改回HKD
  现金修正为132,121.93(Dad 7/3截图确认)
  总资产=957,656.13 仓位=86.2%
2026-07-03 14:42:30 +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
知微 7cc0ea0ef3 fix: Eastmoney 1-fail→Tencent + 2s interval + HKD→CNY + None-safe 2026-07-03 13:34:31 +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
知微 b1a79d962c fix: write_holding_strategy DELETE+INSERT (no UNIQUE constraint on code) 2026-07-03 10:46:14 +08:00
知微 6eecc4d4eb fix: currency+PnL+is_hk_stock+gate+zone+total_pnl 2026-07-03 10:27:17 +08:00
知微 cc55ff76ad 全面移除JSON数据源 移至mo_data/DB
- 宏观风险扫描(3个cron): portfolio.json -> mo_data.read_portfolio()
- 小果情感分析: decisions/portfolio.json -> mo_data read+write xiaoguo_insights.json
- 芯碁微装监控: decisions.json -> mo_data.read_decisions()
- 开盘/收盘简报: 去掉portfolio.json/decisions.json/watchlist.json文件读取,全部从mo_data
- 系统健康检查: 仅保留文件存在性检查,数据从DB
- 知识萃取: stale_staleness_report.json/decisions.json注入改为context注入

数据管道稳定:唯一入口price_monitor -> DB -> mo_data读 -> LLM cron输出
2026-07-03 10:22:13 +08:00
知微 24a73103ed price_monitor港股币种修复+calc_total_mv汇兑处理
问题链:
  price_monitor 从东方财富/腾讯拿HK股价(HKD) → x0.87转CNY写portfolio
  → DB存CNY→下游混读→建滔显示-24%浮亏(实为-0.6%)
修复:
  price_monitor不转CNY,港股存HKD原值
  calc_total_mv()增加币种判断:HK股用get_hk_rate()转CNY再汇总
  portfolio.json/watchlist的HK股价全部HKD原值
  DB同步修正所有HK股价格为HKD
  price_monitor DB写入加3次重试+database locked timeout
验证:
  建滔 87.7 HKD 浮亏-0.6%(不是-24%)
  现金 132,121.93 总资产 956,714.68
2026-07-03 10:19:09 +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
知微 e31bb9e089 所有LLM cron prompt移除JSON读取,全部走DB
开盘简报/收盘简报/盘前中监控/午后监控/策略评估-每日/系统全局审计
6个LLM cron的prompt统一改为:
  from mo_data import read_portfolio, read_decisions, read_watchlist
  禁止执行 json.load(portfolio.json/decisions.json/watchlist.json)
  港股价格统一标注HKD
  总资产/现金/仓位从digital twin字段读,不自算
2026-07-03 10:03:00 +08:00
知微 cd8eba74e4 HK股数据清洗:成本/价格双币种标记
portfolio.json: 港股cost_currency=HKD, cost_cny, price_hkd字段
decisions.json: 港股currency=HKD, 所有价格字段分存_hkd/_cny
修复建滔积层板浮亏-24%→-12.8%问题
根因:cost=88.22HKD被标成CNY,脚本转换价后错算浮亏
2026-07-03 09:31:27 +08:00