Files
google-labs-jules[bot]andxnessom bbc11ab687 feat: 💡 Jules02: CLI and operator UX improvement — Configurable polling and setup wizard enhancements
Institutional-grade algorithmic trading requires predictable interfaces and easy configuration. This PR improves the operator and developer experience by:

1. **Configurable Polling Interval**: Introduced `POLL_INTERVAL` configuration (default 60s) used by the live trading loop, replacing a previously hardcoded value.
2. **Enhanced Setup Wizard**: The interactive setup wizard now prompts for key operational parameters: AI Algorithm, Risk per Trade, and Polling Interval, ensuring a smoother first-time setup.
3. **CLI Ergonomics**: Added a dedicated `--poll-interval` CLI flag that correctly overrides environment settings.
4. **Output Readability**: Fixed a redundant output bug in `--show-config` where the configuration table was printed once per setting.
5. **Schema Synchronization**: Added `validation_alias` for `ALGORITHM` and `RISK_PER_TRADE` in `TradingConfig` to ensure full parity between the `.env` file, setup wizard, and system state.

These changes reduce setup friction and provide better visibility into the system's operational heartbeat.

Verified with:
- `python main.py --show-config`
- `python main.py --setup`
- `pytest tests/test_cli_ux.py tests/test_jules_setup_wizard.py tests/test_failure_propagation.py`

Co-authored-by: xnessom <255288032+xnessom@users.noreply.github.com>
2026-05-21 07:43:42 +00:00

110 lines
3.7 KiB
Bash

# MT5 AI/ML Trading Bot - Environment Configuration Template
# This file defines the required environment variables for the application.
# Copy this file to .env and fill in your actual values.
# ── MT5 Connection ──────────────────────────────────────────────────────────
MT5_LOGIN=0
MT5_PASSWORD=your_password_here
MT5_SERVER=your_server_here
MT5_PATH=C:/Program Files/MetaTrader 5/terminal64.exe
# ── MetaAPI (cloud fallback) ─────────────────────────────────────────────────
METAAPI_TOKEN=
METAAPI_ACCOUNT_ID=
# ── Trading parameters ─────────────────────────────────────────────────────
SYMBOL=XAUUSD
TIMEFRAME=M5
MODE=demo
ALGORITHM=ensemble
POLL_INTERVAL=60
# ── Risk Parameters (per RISK_LIMITS.md) ──────────────────────────────────
MAX_POSITIONS=5
RISK_PER_TRADE=0.01
MAX_POSITION_SIZE_PCT=0.10
MIN_LOT_SIZE=0.01
MAX_LEVERAGE=10.0
# Exposure Limits
MAX_SINGLE_DIRECTION_PCT=0.30
MAX_TOTAL_NOTIONAL_PCT=1.00
MARGIN_ALERT_PCT=0.70
MARGIN_HALT_PCT=0.80
MARGIN_LIQUIDATION_PCT=0.90
MAX_DRAWDOWN=0.30
# Daily Limits (Cascading)
MAX_DAILY_LOSS=0.05
DAILY_LOSS_LVL1=0.02
DAILY_LOSS_LVL2=0.03
DAILY_LOSS_LVL3=0.04
DAILY_LOSS_HARD_STOP=0.06
DAILY_WIN_CAP=0.10
MAX_TRADES_PER_DAY=20
MAX_LOSING_STREAK=3
MAX_WINNING_STREAK=5
# Weekly/Monthly Limits
MAX_WEEKLY_LOSS=0.10
MAX_MONTHLY_LOSS=0.15
# Capital Allocation
ALLOCATOR_MAX_TOTAL_HEAT=0.70
ALLOCATOR_MAX_SYMBOL_RISK=0.40
ALLOCATOR_MAX_FAMILY_RISK=0.40
ALLOCATOR_PERFORMANCE_STEP=0.05
ALLOCATOR_DECAY_RATE=0.001
ALLOCATOR_SOFT_LIMIT_BUFFER=0.10
# Volatility Thresholds
VOLATILITY_HIGH_THRESHOLD=1.5
VOLATILITY_VERY_HIGH_THRESHOLD=2.0
VOLATILITY_EXTREME_THRESHOLD=3.0
# Execution
MAX_SLIPPAGE_PIPS=1.0
MIN_SPREAD_PIPS=0.5
SPREAD_ALERT_PIPS=1.0
SPREAD_REDUCE_PIPS=1.5
SPREAD_HALT_PIPS=2.0
# ── Model ──────────────────────────────────────────────────────────────────
ALGORITHM=ensemble
MODEL_PATH=models/trained/ensemble_latest.pt
TRAIN_STEPS=1000000
DEVICE=auto
# Prediction Limits
MIN_CONFIDENCE=0.55
CONFIDENCE_THRESHOLD=0.60
CONSENSUS_THRESHOLD=0.60
MODEL_DRIFT_THRESHOLD=0.3
MODEL_ACCURACY_FLOOR=0.5
MODEL_WIN_RATE_FLOOR=0.45
MODEL_CALIBRATION_THRESHOLD=0.25
DATA_FRESHNESS_THRESHOLD=300
OUTCOME_NOISE_THRESHOLD=0.0001
SIGNAL_FLICKER_WINDOW=6
MAX_SIGNAL_CHANGES=3
# ── Database ────────────────────────────────────────────────────────────
DATABASE_URL=postgresql://trader:password@localhost:5432/mt5_trades
REDIS_URL=redis://localhost:6379/0
# ── Monitoring ──────────────────────────────────────────────────────────
PROMETHEUS_PORT=8000
DASHBOARD_PORT=8050
LOG_LEVEL=INFO
TELEGRAM_TOKEN=
TELEGRAM_CHAT_ID=
# ── Safety Gate ─────────────────────────────────────────────────────────
CONFIRM_LIVE_TRADING=NO
EXECUTION_LATENCY_THRESHOLD=1.0
# --- Macro Risk Settings ---
ENABLE_MACRO_GUARD=True
MACRO_PRE_EVENT_MINUTES={"1": 5, "2": 15, "3": 60, "4": 120}
MACRO_POST_EVENT_MINUTES={"1": 5, "2": 30, "3": 120, "4": 240}