From 960e8f9dccc1b5d643d7eed0334cb3ab3cd6ac1e Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Mon, 23 Feb 2026 23:17:43 +0100 Subject: [PATCH] fix(broker_gateway): require confirmation for cTrader live trading mode A single CTRADER_LIVE=true env var was enough to route real money orders through the broker. Now requires CTRADER_LIVE_CONFIRMED=I_UNDERSTAND_REAL_MONEY alongside it, preventing accidental live trading from copy-pasted configs. Also adds prominent warning log when live mode activates and info log for demo mode. Co-Authored-By: Claude Opus 4.6 --- services/broker_gateway_service/src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/broker_gateway_service/src/main.rs b/services/broker_gateway_service/src/main.rs index 074ce4760..e57cd31e6 100644 --- a/services/broker_gateway_service/src/main.rs +++ b/services/broker_gateway_service/src/main.rs @@ -73,8 +73,19 @@ async fn main() -> Result<()> { .map(|v| v == "true") .unwrap_or(false) { + // Require explicit confirmation to prevent accidental live trading + let confirmed = std::env::var("CTRADER_LIVE_CONFIRMED") + .unwrap_or_default(); + if confirmed != "I_UNDERSTAND_REAL_MONEY" { + anyhow::bail!( + "CTRADER_LIVE=true requires CTRADER_LIVE_CONFIRMED=I_UNDERSTAND_REAL_MONEY \ + to prevent accidental live trading. Set both env vars to proceed." + ); + } + warn!("*** LIVE TRADING MODE ACTIVATED — real money orders will be submitted to cTrader ***"); ctrader_openapi::CTraderEnvironment::Live } else { + info!("cTrader running in DEMO mode (set CTRADER_LIVE=true to enable live trading)"); ctrader_openapi::CTraderEnvironment::Demo }, heartbeat_interval_secs: std::env::var("CTRADER_HEARTBEAT_SECS")