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:
@@ -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:
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user