ad8dfa27d7
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
2.7 KiB
Python
52 lines
2.7 KiB
Python
"""
|
|
Configuration — loaded once at import time.
|
|
Values come from config.json (strategy params) and .env (secrets).
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
_root = Path(__file__).parent.parent
|
|
with open(_root / "config.json") as f:
|
|
_cfg = json.load(f)
|
|
|
|
# ── strategy ──────────────────────────────────────────────────────────────────
|
|
SYMBOLS: list[str] = _cfg["symbols"]
|
|
TIMEFRAME: str = _cfg["timeframe"] # "M15"
|
|
LOOKBACK: int = _cfg["lookback_candles"] # bars for indicator warmup
|
|
RSI_PERIOD: int = _cfg["rsi_period"]
|
|
ATR_PERIOD: int = _cfg["atr_period"]
|
|
OS_LEVEL: float = _cfg["os_level"]
|
|
OB_LEVEL: float = _cfg["ob_level"]
|
|
SL_ATR: float = _cfg["sl_atr"]
|
|
TP_ATR: float = _cfg["tp_atr"]
|
|
TREND_FAST: int = _cfg["trend_fast"]
|
|
TREND_SLOW: int = _cfg["trend_slow"]
|
|
SESSION_START: int = _cfg["session_start"]
|
|
SESSION_END: int = _cfg["session_end"]
|
|
|
|
# ── risk ──────────────────────────────────────────────────────────────────────
|
|
RISK_PER_TRADE: float = _cfg["risk_per_trade"] # fraction, e.g. 0.01
|
|
MAX_POSITIONS: int = _cfg["max_positions"]
|
|
MIN_SL_PIPS: float = _cfg["min_sl_pips"]
|
|
MAX_DAILY_LOSS: float = _cfg["max_daily_loss"] # fraction of balance
|
|
|
|
# ── mode ──────────────────────────────────────────────────────────────────────
|
|
PAPER_TRADING: bool = _cfg.get("paper_trading", True)
|
|
PAPER_INITIAL_BALANCE: float = _cfg.get("paper_initial_balance", 10_000.0)
|
|
REFRESH_INTERVAL: int = _cfg.get("refresh_interval_seconds", 15)
|
|
|
|
# ── broker secrets (from .env) ────────────────────────────────────────────────
|
|
MT5_LOGIN: int = int(os.environ.get("MT5_LOGIN") or "0")
|
|
MT5_PASSWORD: str = os.environ.get("MT5_PASSWORD", "")
|
|
MT5_SERVER: str = os.environ.get("MT5_SERVER", "")
|
|
|
|
# ── telegram secrets ──────────────────────────────────────────────────────────
|
|
TELEGRAM_BOT_TOKEN: str = os.environ.get("TELEGRAM_BOT_TOKEN", "")
|
|
TELEGRAM_CHAT_ID: str = os.environ.get("TELEGRAM_CHAT_ID", "")
|