知微
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
知微
320353348d
feat: add todos table to mofin_db + DB_PATH fix for self_todo_executor
2026-07-05 01:37:40 +08:00
知微
bb9b3922c9
migrate: last 4 JSON files — live_prices, market, mtf_cache, capital_flow → DB
2026-07-03 13:44:10 +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
知微
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
知微
0aef122b69
feat: mofin_db get_price_from_db/get_prices_batch helpers + strategy_evaluator DB-first
2026-07-01 22:56:24 +08:00
知微
e3bf196a59
fix: ALTER TABLE migrations must run before CREATE TABLE + currency validation in write_holdings_batch
2026-06-30 23:53:57 +08:00
知微
dc68739ac4
feat: DB migration — enforce currency constraints on holdings/strategies/watchlist/summary tables + price_monitor DB writes
2026-06-30 23:46:08 +08:00
知微
1ff0c356ab
xiaoguo_scanner: 小果独立扫描线,5分钟一轮,三榜交叉发现
2026-06-21 02:28:22 +08:00
知微
a1d789ddab
trend_detector + xiaoguo_news_processor 全链路
...
- trend_detector.py: 6类信号检测(资金异动/涨跌比反转/领涨更替/趋势拐点/量价背离/普涨背离)
- xiaoguo_news_processor.py: akshare搜新闻+小果LLM情感分析
- mofin_db.py: 新增 sector_signals + signal_news 两张表
- 文档更新:新增第四章实时信号检测与小果情报处理
- 测试结果:趋势检测已通过,信号写入正常
2026-06-20 22:20:54 +08:00
hmo
1610f184a0
feat: 补全 SQLite 表结构 + 查询函数 + 迁移覆盖
...
mofin_db.py 新增:
- 4 张表: portfolio_summary, advice_timeline, accuracy_stats, strategy_feedback
- 18 个查询函数: query_holdings, query_watchlist, query_strategies,
query_advice_timeline, query_candidates, query_candidate_scores,
query_price_events, query_price_events_by_date, query_stock_sectors,
query_sector_stocks, query_accuracy_stats, query_strategy_feedback,
query_strategy_evaluations, query_latest_market, query_holding_by_code,
query_portfolio_summary
migrate_all.py 新增:
- 4 个迁移函数: migrate_portfolio_summary, migrate_advice_timeline,
migrate_accuracy_stats, migrate_strategy_feedback
- 迁移量: portfolio_summary(1), advice_timeline(2547),
accuracy_stats(1), strategy_feedback(37)
现在 13 张表全部覆盖,JSON→SQLite 数据完整迁移
2026-06-20 16:59:24 +08:00
hmo
0924cf3124
refactor: 数据层重构 — 统一 SQLite 访问层 + 多脚本双写
...
新建 mofin_db.py 共享数据库模块:
- get_conn() 统一连接管理 (WAL + Row factory + 外键)
- init_all_tables() 幂等建表 (12张表: market/sector/stock/kline/fundamentals/sectors/holdings/strategies/watchlist/candidates/score_history/events/evaluations)
- write_market_snapshot() 市场快照双写
- write_klines() K线数据双写 (stocks + daily/weekly/monthly + fundamentals)
- write_price_event() 价格事件双写
- migrate_stock_sectors() 一次性迁移 stock_sector_map.json
- query_*() 通用查询函数 (sector_trend/top_inflow/consecutive_inflow/market_mood/db_stats)
重构现有脚本:
- market_watch.py: 删除内联 DB 代码,改用 mofin_db
- multi_timeframe.py: _save_local_history() 加 SQLite 双写
- price_monitor.py: record_event() 加 SQLite 双写
- mofin_query.py: 改用 mofin_db 查询函数
新增:
- migrate_sectors.py: 一次性迁移脚本
清理:
- get_realtime_prices.py: 死代码 (只读 portfolio.json,不调API)
2026-06-20 16:26:17 +08:00