Skip to Content
Forex ExecutionConfiguration

Configuration

Copy .env.example to .env and fill in credentials before starting. Configuration is validated with Zod on load.

Dual live gate

Live OANDA URLs are not used unless both flags are set:

VariableRequirement
OANDA_ENVMust be live
LIVE_TRADING_ENABLEDMust be true

If OANDA_ENV=live and LIVE_TRADING_ENABLED is not true, startup fails configuration validation. The service defaults to OANDA_ENV=practice.

Passing the dual live gate only selects the live OANDA REST/stream base URLs. Phases 1–2 still do not place orders. Keep practice credentials until you intentionally move to live account reads.

Resolved environments

OANDA_ENVREST baseStream base
practicehttps://api-fxpractice.oanda.comhttps://stream-fxpractice.oanda.com
livehttps://api-fxtrade.oanda.comhttps://stream-fxtrade.oanda.com

Application & security

VariableDefaultDescription
NODE_ENVdevelopmentNode environment
PORT3000HTTP port
HOST0.0.0.0Bind address
LOG_LEVELinfoLog level
APP_NAMEoanda-trading-serverService name
INTERNAL_API_KEYRequired (min 16 chars); sent as X-Internal-API-Key

OANDA

VariableDefaultDescription
OANDA_ENVpracticepractice or live
OANDA_ACCOUNT_IDOANDA account ID
OANDA_API_TOKENOANDA API token (secret)
LIVE_TRADING_ENABLEDfalseSecond half of the dual live gate
OANDA_ACCOUNT_ALIASprimaryLocal alias for the account

Infrastructure

VariableDefaultDescription
DATABASE_URLPostgreSQL URL (required)
REDIS_URLRedis URL (required)

Trading controls & risk (schema present)

These keys are validated in the env schema / .env.example. They do not imply that Phases 1–2 execute trades.

VariableDefault
TRADING_ENABLEDtrue
GLOBAL_KILL_SWITCHfalse
MAX_RISK_PER_TRADE_PERCENT0.50
MAX_DAILY_LOSS_PERCENT2.00
MAX_TOTAL_OPEN_RISK_PERCENT2.00
MAX_OPEN_TRADES5
MAX_OPEN_TRADES_PER_INSTRUMENT1
MAX_SPREAD_PIPS3
MAX_SIGNAL_AGE_SECONDS30
MAX_PRICE_AGE_SECONDS5
MAX_ORDER_UNITS100000
MIN_STOP_DISTANCE_PIPS5
DEFAULT_RISK_REWARD_RATIO2

Execution / sync / optional notifications

VariableDefaultDescription
ORDER_TIMEOUT_MS10000Request timeout-related setting in schema
REST_REQUEST_TIMEOUT_MS10000REST client timeout
MAX_RETRY_ATTEMPTS3Retry budget
RETRY_BASE_DELAY_MS500Retry backoff base
ACCOUNT_SYNC_INTERVAL_SECONDS15Account sync interval
TRANSACTION_SYNC_INTERVAL_SECONDS5Transaction sync interval
TELEGRAM_BOT_TOKENOptional
TELEGRAM_CHAT_IDOptional
SLACK_WEBHOOK_URLOptional

Keep .env out of version control. Treat OANDA_API_TOKEN and INTERNAL_API_KEY as secrets.

Last updated on