refactor: 统一价格入口 mo_data.get_price() - 22个脚本移除自拉腾讯API
所有价格获取统一走 mo_data.get_price() / get_prices_batch():
- 优先读 live_prices(DB) → 无/过期才调 stock_quote(API) → 自动写回DB
- 22个脚本全部替换:branch_scanner chip_factors divergence_detector
market_screener mo_provider mofin_collect monitor_300308 300308_monitor
multi_timeframe refresh_macro_context stale_detector stale_push_wlin
stock_profile strategy_evaluator strategy_lifecycle strategy_review
strategy-staleness-check technical_analysis xiaoguo_signal_consumer
collect_evaluation_data
This commit is contained in:
+19
-13
@@ -10,7 +10,7 @@ mo_config.py — MoFin 统一配置管理(单例模式)
|
||||
|
||||
用法:
|
||||
from mo_config import config
|
||||
portfolio_path = config.data_dir / "portfolio.json"
|
||||
from mo_data import read_portfolio; data = read_portfolio()
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -28,7 +28,7 @@ class MoConfig:
|
||||
# 项目根目录
|
||||
project_dir: Path = field(default_factory=lambda: Path(__file__).parent.resolve())
|
||||
|
||||
# 数据目录(portfolio.json, decisions.json 等)
|
||||
# 数据目录(mofin.db 等,所有数据只从 DB 读写)
|
||||
data_dir: Path = field(default_factory=lambda: Path(
|
||||
os.environ.get("MOFIN_DATA_DIR", "/home/hmo/web-dashboard/data")
|
||||
))
|
||||
@@ -46,18 +46,24 @@ class MoConfig:
|
||||
|
||||
@property
|
||||
def portfolio_path(self) -> Path:
|
||||
"""⚠️ 已废弃!数据在 mofin.db holdings + portfolio_summary 表。"""
|
||||
return self.data_dir / "portfolio.json"
|
||||
"""⚠️ DEPRECATED: 数据已迁至 mofin.db holdings + portfolio_summary 表。"""
|
||||
import warnings
|
||||
warnings.warn("portfolio_path is deprecated — use mo_data.read_portfolio() for DB data", DeprecationWarning, stacklevel=2)
|
||||
return Path()
|
||||
|
||||
@property
|
||||
def decisions_path(self) -> Path:
|
||||
"""⚠️ 已废弃!数据在 mofin.db holding_strategies 表。"""
|
||||
return self.data_dir / "decisions.json"
|
||||
"""⚠️ DEPRECATED: 数据已迁至 mofin.db holding_strategies 表。"""
|
||||
import warnings
|
||||
warnings.warn("decisions_path is deprecated — use mo_data.read_decisions() for DB data", DeprecationWarning, stacklevel=2)
|
||||
return Path()
|
||||
|
||||
@property
|
||||
def watchlist_path(self) -> Path:
|
||||
"""⚠️ 已废弃!数据在 mofin.db watchlist_stocks 表。"""
|
||||
return self.data_dir / "watchlist.json"
|
||||
"""⚠️ DEPRECATED: 数据已迁至 mofin.db watchlist_stocks 表。"""
|
||||
import warnings
|
||||
warnings.warn("watchlist_path is deprecated — use mo_data.read_watchlist() for DB data", DeprecationWarning, stacklevel=2)
|
||||
return Path()
|
||||
|
||||
@property
|
||||
def price_events_path(self) -> Path:
|
||||
@@ -149,10 +155,10 @@ class MoConfig:
|
||||
issues.append(f"数据目录不存在: {self.data_dir}")
|
||||
|
||||
if not self.portfolio_path.exists():
|
||||
issues.append(f"portfolio.json 不存在: {self.portfolio_path}")
|
||||
|
||||
issues.append(f"portfolio_path 不存在(已废弃): {self.portfolio_path}")
|
||||
|
||||
if not self.decisions_path.exists():
|
||||
issues.append(f"decisions.json 不存在: {self.decisions_path}")
|
||||
issues.append(f"decisions_path 不存在(已废弃): {self.decisions_path}")
|
||||
|
||||
return issues
|
||||
|
||||
@@ -210,8 +216,8 @@ def ensure_dirs():
|
||||
get_config().ensure_dirs()
|
||||
|
||||
|
||||
# ── 向后兼容:导出常用路径常量 ──────────────────────────────────────
|
||||
# 让旧代码可以通过熟悉的变量名访问路径
|
||||
# ── 向后兼容:导出已废弃的路由常量 ──────────────────────────────────
|
||||
# PORTFOLIO_PATH / DECISIONS_PATH / WATCHLIST_PATH 均已废弃(数据在 DB)。
|
||||
|
||||
def _lazy(attr):
|
||||
"""懒加载属性,首次访问时从 config 获取"""
|
||||
|
||||
Reference in New Issue
Block a user