Commit Graph

6 Commits

Author SHA1 Message Date
hmo 6abc2e45b0 refactor: phase 0-2 MoFin architecture reform — single source of truth
Phase 0 (止血):
- mo_models.py: unified calc_total_assets(), is_hk_stock(), get_hk_rate() — single source of truth
- Fixed 3 files missing frozen_cash: holdings_reconciliation, server, import_holding_xls
- Fixed stale_push_wlin: unified is_hk_stock detection, removed hardcoded 0.866
- Fixed price_monitor: consolidated 2 duplicate total_assets blocks into mo_models calls
- Fixed stock_scorer: replaced broken len()<=5 is_hk_stock heuristic
- Fixed strategy_lifecycle: replaced non-existent currency_utils import with mo_models

Phase 1 (DSA adapter):
- mo_provider.py: wraps DSA DataFetcherManager (16 fetchers, auto-fallback)
  - TDX relay as primary, DSA as backup for realtime/kline/news/fundamentals

Phase 2 (Integration):
- mo_bridge.py: injects DSA market review + news context into MoFin analysis prompts
- Graceful degradation if DSA not installed

Infrastructure:
- mo_config.py: centralized Config singleton replacing scattered hardcoded paths
- All 11 changed files pass python compile check

Impact: total_assets now computed in ONE place (mo_models).
        is_hk_stock now ONE implementation (no more false negatives).
        HK rate now ONE source (hk_rate API → cache → 0.87 fallback).
        No more hardcoded 0.866/0.8664/0.8700 divergence.
2026-06-29 23:25:54 +08:00
知微 6a97d93018 现金更正 + 法拉电子清仓记录
截图确认:
- 可用资金 92,664.20(含天添利)
- 冻结 39,481.40
- 总现金 132,145.60
- 总资产 = 持仓市值1,107,670 + 现金132,145.60 = 1,239,815.60

法拉电子 189.20卖出100股已记录
2026-06-29 12:40:50 +08:00
知微 b053103377 feat: 策略复盘闭环 Phase1
- 新增 scripts/strategy_review.py: 遍历所有active策略
  - 腾讯API实时价对比止损/止盈/入场点
  - 分类: correct/wrong/partial/pending
  - 失败模式归因: 止损过紧/入场过早/止盈过远等
  - 写入 accuracy_stats 表(首条真实数据)
- 新增 docs/strategy-review-loop.md: 完整闭环设计文档
- 含失败模式→修复方向映射表

Phase1 结果: 38条策略, 94.7%准确率(19条待定), 1条止损过紧
2026-06-25 19:58:00 +08:00
知微 eb294f05a5 import_holding_xls: 支持截图真实数字覆盖
regenerate_all 会覆盖 portfolio.json,所以导入流程改为:
1. 先更新 SQLite holdings 表
2. 再跑 regenerate_all(读 SQLite,写 decisions+portfolio)
3. 然后用真实数字覆盖 portfolio.json 汇总字段
4. 重建决策树

支持 --cash --total --mv 传入截图真实数字
用法:python3 import_holding_xls.py --cash 20230 --total 1008860 --mv 988512
2026-06-24 11:29:53 +08:00
知微 e2646c36cb 持仓导入完成:holding.xls→SQLite+portfolio.json全同步
1. 从 ~/stocks/holding.xls 导入25只持仓(14A/11H)
2. 同时写入 portfolio.json + SQLite holdings 表
3. stale_push_wlin 现金来源从 stale_report 改为 portfolio.json
4. portfolio.json 增加 total_assets 字段兼容 stale_detector
5. 导入脚本已规范化为 MoFin/scripts/import_holding_xls.py
   用法:python3 import_holding_xls.py [--cash 金额]
6. 全量策略重评+决策树重建立即执行

Dad下次更新holding.xls后跑:
  cd MoFin && python3 scripts/import_holding_xls.py
2026-06-24 11:21:51 +08:00
知微 df4f898bc4 持仓来源修复:holding.xls导入+持仓数据修正
老问题:scripts读的是 strategy_staleness_report.json 里的旧现金值,
portfolio.json 被 strategy_lifecycle.regenerate_all 反复覆盖。

修复:
1. import_holding_xls.py — 从 ~/stocks/holding.xls 导入TSV持仓
   (含25只真实持仓,14A/11H,总市值93万,现金8万,仓位92%)
2. stale_push_wlin 现金来源改读 portfolio.json(取代旧stale_report缓存)
3. 港股市值×汇率修正(之前按1:1当人民币算,总资产多估了)
4. 每条策略的决策树同步重建

脚本执行:python3 MoFin/scripts/import_holding_xls.py (含全量重评)
Dad你以后更新holding.xls后跑这条命令就行
2026-06-24 11:19:29 +08:00