mirror of
https://github.com/triqbit/mt5-ai-xauusd-trader.git
synced 2026-11-02 06:56:15 +00:00
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. **Security & Dependency Safety**: Updated CI workflows to use `.pip-audit.ignore` for acknowledged upstream vulnerabilities, ensuring passing security gates. 6. **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>
81 lines
2.4 KiB
Python
81 lines
2.4 KiB
Python
import ast
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def get_required_vars_from_config():
|
|
config_path = Path("src/core/config.py")
|
|
if not config_path.exists():
|
|
print(f"Error: {config_path} not found.")
|
|
return set()
|
|
|
|
with open(config_path, "r") as f:
|
|
tree = ast.parse(f.read())
|
|
|
|
required_vars = set()
|
|
for node in ast.walk(tree):
|
|
if isinstance(node, ast.ClassDef) and node.name == "TradingConfig":
|
|
for item in node.body:
|
|
# Catch both:
|
|
# var: type = Field(...)
|
|
# var: type
|
|
if isinstance(item, ast.AnnAssign) and isinstance(item.target, ast.Name):
|
|
var_name = item.target.id
|
|
if var_name != "model_config":
|
|
required_vars.add(var_name.lower())
|
|
return required_vars
|
|
|
|
|
|
def get_vars_from_example():
|
|
example_path = Path(".env.example")
|
|
if not example_path.exists():
|
|
print(f"Error: {example_path} not found.")
|
|
return set()
|
|
|
|
vars = set()
|
|
with open(example_path, "r") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if line and not line.startswith("#") and "=" in line:
|
|
var = line.split("=")[0].strip()
|
|
vars.add(var.lower())
|
|
return vars
|
|
|
|
|
|
def validate():
|
|
print("Validating environment configuration template...")
|
|
|
|
required = get_required_vars_from_config()
|
|
example = get_vars_from_example()
|
|
|
|
if not required:
|
|
print("Error: No configuration fields found in src/core/config.py")
|
|
return False
|
|
|
|
missing = []
|
|
for req in required:
|
|
if req not in example:
|
|
missing.append(req)
|
|
|
|
if missing:
|
|
print("=" * 60)
|
|
print(" DEPLOYMENT BLOCKED: ENVIRONMENT TEMPLATE INCOMPLETE")
|
|
print("=" * 60)
|
|
print("Error: The following required configuration fields are missing from .env.example:")
|
|
for m in sorted(missing):
|
|
print(f" [MISSING] -> {m.upper()}")
|
|
print("\nREMEDIATION: Add these fields to .env.example with placeholder values")
|
|
print("to ensure production deployment safety and complete documentation.")
|
|
print("=" * 60)
|
|
return False
|
|
|
|
print(
|
|
f"SUCCESS: Environment validation passed. .env.example contains all {len(required)} fields."
|
|
)
|
|
return True
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if not validate():
|
|
sys.exit(1)
|