fix: lib 迁移后中控数据路径指向 manual_trading_hub

修复 hub_fund_history 等模块误读 lib/hub/manual_trading_hub 导致资金概况历史曲线丢失的问题。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-02 16:28:36 +08:00
parent 5797d49d8a
commit 55261b7812
7 changed files with 29 additions and 16 deletions
+3 -3
View File
@@ -36,9 +36,9 @@ def default_db_path() -> Path:
raw = (os.getenv("HUB_ENTRY_PLAN_DB_PATH") or "").strip() raw = (os.getenv("HUB_ENTRY_PLAN_DB_PATH") or "").strip()
if raw: if raw:
return Path(raw) return Path(raw)
hub_dir = Path(__file__).resolve().parent / "manual_trading_hub" / "data" from lib.paths import hub_data_dir
hub_dir.mkdir(parents=True, exist_ok=True)
return hub_dir / "hub_entry_plans.db" return hub_data_dir() / "hub_entry_plans.db"
def _now_ms() -> int: def _now_ms() -> int:
+3 -1
View File
@@ -9,7 +9,9 @@ from typing import Any, Optional
from lib.hub.hub_trades_lib import current_trading_day from lib.hub.hub_trades_lib import current_trading_day
HUB_DIR = Path(__file__).resolve().parent / "manual_trading_hub" from lib.paths import manual_trading_hub_dir
HUB_DIR = manual_trading_hub_dir()
FUND_HISTORY_PATH = HUB_DIR / "hub_fund_history.json" FUND_HISTORY_PATH = HUB_DIR / "hub_fund_history.json"
LEGACY_FUND_HISTORY_PATH = HUB_DIR / "hub_ai_fund_history.json" LEGACY_FUND_HISTORY_PATH = HUB_DIR / "hub_ai_fund_history.json"
+3 -3
View File
@@ -44,9 +44,9 @@ def default_db_path() -> Path:
raw = (os.getenv("HUB_KLINE_DB_PATH") or "").strip() raw = (os.getenv("HUB_KLINE_DB_PATH") or "").strip()
if raw: if raw:
return Path(raw) return Path(raw)
hub_dir = Path(__file__).resolve().parent / "manual_trading_hub" / "data" from lib.paths import hub_data_dir
hub_dir.mkdir(parents=True, exist_ok=True)
return hub_dir / "hub_kline.db" return hub_data_dir() / "hub_kline.db"
def _connect(db_path: Path | None = None) -> sqlite3.Connection: def _connect(db_path: Path | None = None) -> sqlite3.Connection:
+3 -3
View File
@@ -32,9 +32,9 @@ def default_db_path() -> Path:
raw = (os.getenv("HUB_MACRO_CALENDAR_DB_PATH") or "").strip() raw = (os.getenv("HUB_MACRO_CALENDAR_DB_PATH") or "").strip()
if raw: if raw:
return Path(raw) return Path(raw)
hub_dir = Path(__file__).resolve().parent / "manual_trading_hub" / "data" from lib.paths import hub_data_dir
hub_dir.mkdir(parents=True, exist_ok=True)
return hub_dir / "hub_macro_calendar.db" return hub_data_dir() / "hub_macro_calendar.db"
def _connect(db_path: Path | None = None) -> sqlite3.Connection: def _connect(db_path: Path | None = None) -> sqlite3.Connection:
+3 -3
View File
@@ -49,9 +49,9 @@ def default_db_path() -> Path:
raw = (os.getenv("HUB_ARCHIVE_DB_PATH") or "").strip() raw = (os.getenv("HUB_ARCHIVE_DB_PATH") or "").strip()
if raw: if raw:
return Path(raw) return Path(raw)
hub_dir = Path(__file__).resolve().parent / "manual_trading_hub" / "data" from lib.paths import hub_data_dir
hub_dir.mkdir(parents=True, exist_ok=True)
return hub_dir / "hub_symbol_archive.db" return hub_data_dir() / "hub_symbol_archive.db"
def _connect(db_path: Path | None = None) -> sqlite3.Connection: def _connect(db_path: Path | None = None) -> sqlite3.Connection:
+3 -3
View File
@@ -59,9 +59,9 @@ def default_cache_path() -> Path:
raw = (os.getenv("HUB_VOLUME_RANK_CACHE_PATH") or "").strip() raw = (os.getenv("HUB_VOLUME_RANK_CACHE_PATH") or "").strip()
if raw: if raw:
return Path(raw) return Path(raw)
hub_dir = Path(__file__).resolve().parent / "manual_trading_hub" / "data" from lib.paths import hub_data_dir
hub_dir.mkdir(parents=True, exist_ok=True)
return hub_dir / "hub_volume_rank.json" return hub_data_dir() / "hub_volume_rank.json"
def _safe_float(v: Any) -> float | None: def _safe_float(v: Any) -> float | None:
+11
View File
@@ -20,3 +20,14 @@ def embed_templates_dir(repo_root: str | Path | None = None) -> str:
def common_static_dir(repo_root: str | Path | None = None) -> str: def common_static_dir(repo_root: str | Path | None = None) -> str:
root = Path(repo_root) if repo_root is not None else REPO_ROOT root = Path(repo_root) if repo_root is not None else REPO_ROOT
return str(root / "lib" / "common" / "static") return str(root / "lib" / "common" / "static")
def manual_trading_hub_dir(repo_root: str | Path | None = None) -> Path:
root = Path(repo_root) if repo_root is not None else REPO_ROOT
return root / "manual_trading_hub"
def hub_data_dir(repo_root: str | Path | None = None) -> Path:
path = manual_trading_hub_dir(repo_root) / "data"
path.mkdir(parents=True, exist_ok=True)
return path