feat: add runtime diagnostics and path management

This commit is contained in:
2026-04-15 16:55:45 +08:00
parent 7586685d5f
commit 6eefabb9ff
14 changed files with 304 additions and 85 deletions

View File

@@ -10,12 +10,15 @@ from zoneinfo import ZoneInfo
import ccxt
BASE_DIR = Path.home() / ".coinhunter"
STATE_DIR = BASE_DIR / "state"
STATE_FILE = STATE_DIR / "precheck_state.json"
POSITIONS_FILE = BASE_DIR / "positions.json"
CONFIG_FILE = BASE_DIR / "config.json"
ENV_FILE = Path.home() / ".hermes" / ".env"
from .runtime import get_runtime_paths, load_env_file
PATHS = get_runtime_paths()
BASE_DIR = PATHS.root
STATE_DIR = PATHS.state_dir
STATE_FILE = PATHS.precheck_state_file
POSITIONS_FILE = PATHS.positions_file
CONFIG_FILE = PATHS.config_file
ENV_FILE = PATHS.env_file
BASE_PRICE_MOVE_TRIGGER_PCT = 0.025
BASE_PNL_TRIGGER_PCT = 0.03
@@ -66,13 +69,7 @@ def load_json(path: Path, default):
def load_env():
if not ENV_FILE.exists():
return
for line in ENV_FILE.read_text(encoding="utf-8").splitlines():
line = line.strip()
if line and not line.startswith("#") and "=" in line:
key, val = line.split("=", 1)
os.environ.setdefault(key.strip(), val.strip())
load_env_file(PATHS)
def load_positions():