Skip to content

Live Trading Gate (P0-3)

Production must remain paper-only until explicit operator promotion.

Required .env on droplet (/opt/trading/.env)

Variable Paper (default) Live (after sign-off)
ALPACA_BASE_URL https://paper-api.alpaca.markets https://api.alpaca.markets
QGTM_LIVE_TRADING_ENABLED false (or unset) true

Enforcement layers

  1. Settings validator (qgtm_core/config.py) — rejects incoherent pairs at import:
  2. Live URL without QGTM_LIVE_TRADING_ENABLED=trueValueError
  3. QGTM_LIVE_TRADING_ENABLED=true with paper URL → ValueError
  4. TradingDaemon.run() — refuses to start if is_live is false while URL is live-shaped (legacy path).
  5. AlpacaBroker.submit_order() — rejects orders when not paper and gate is false.

Verification (post-deploy)

curl -sf -H "X-QGTM-API-Key: $QGTM_API_KEY" \
  http://127.0.0.1:8000/api/v1/daemon/telemetry | jq '.paper, .live_trading_enabled'

Expect: paper: true, live_trading_enabled: false.

See also: docs/secrets-reference.md, SECURITY.md.