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 <noreply@anthropic.com>
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user