Skip to Content
cTrader MarketsConfiguration

Configuration

Settings load from a profile-scoped env file (.env.forex, .env.deriv, or .env). Any value still starting with replace-with- is rejected at startup — including API_KEY, whose template value is 32 characters and would otherwise satisfy the minimum length while being publicly known.

Credentials & account

VariablePurpose
CTRADER_CLIENT_ID / CTRADER_CLIENT_SECRETOpen API application credentials from openapi.ctrader.com.
CTRADER_ACCESS_TOKEN / CTRADER_REFRESH_TOKENInitial OAuth pair; thereafter rotated into TOKEN_CACHE_PATH.
CTRADER_ACCOUNT_IDNumeric ctidTraderAccountId (not the login number).
CTRADER_ENVIRONMENTdemo or live — fully separated connections.
CTRADER_HOST / CTRADER_PORTOptional endpoint override; leave unset to derive host from environment (demo.ctraderapi.com / live.ctraderapi.com, port 5035).

HTTP & auth

VariableDefaultPurpose
API_KEYAuth key (min 16 chars) for /v1/* via X-API-Key.
HOST127.0.0.1Bind address.
PORT8010Bind port — give each profile its own (8010 forex, 8011 deriv).
SYMBOLSExact, case-sensitive cTrader symbolName CSV.
MAX_CANDLES_LOOKBACK5000Cap on requested bar lookback for candles.

Connection & reconnect

VariableDefaultPurpose
HEARTBEAT_INTERVAL_SECONDS5Must stay under 10 — the broker drops silent connections.
REQUEST_TIMEOUT_SECONDS10Per-request timeout.
RECONNECT_INITIAL_BACKOFF_SECONDS1Initial reconnect backoff.
RECONNECT_MAX_BACKOFF_SECONDS60Cap on reconnect backoff.
RECONNECT_STABILITY_SECONDS30Connection must stay up this long before backoff counts as recovered.
STARTUP_READY_TIMEOUT_SECONDS20How long startup waits for the first handshake before serving anyway.
TICK_STALENESS_SECONDS60/health/ready not ready when newest tick is older than this.
HISTORICAL_REQUESTS_PER_SECOND4Under the broker’s 5 historical requests/second limit.

SSE & state

VariableDefaultPurpose
SUBSCRIBER_QUEUE_SIZE256Per-SSE-subscriber buffer; oldest tick dropped on overflow.
SSE_KEEPALIVE_SECONDS15SSE keepalive interval.
TOKEN_CACHE_PATHdata/token-cache.<profile>.jsonRotated OAuth token pair (mode 0600).
EVENTS_LOG_PATHlogs/events.<profile>.jsonlAppend-only durable event log.
LOG_LEVELINFOLog level.

Secrets stay in .env.<profile>. Nothing sensitive belongs in a launchd plist — they are world-readable.

Last updated on