Skip to content

Configuration reference

All configuration lives in backend/.env and is loaded once at startup into a single Settings object (ats/core/config.py). Every variable is prefixed ATS_. Because both the API and the worker read this at startup, changes take effect after a restart (scripts/stop.sh && scripts/start.sh).

You can edit the bring-your-own keys from the in-app Settings page (the header gear); it writes them to the same backend/.env file. Secrets are never logged or returned by the API. See the security model.

Naming: a setting shown as tiingo_api_token in code is the environment variable ATS_TIINGO_API_TOKEN. The tables below use the environment-variable form.

Variable Default Description
ATS_SESSION_SECRET (required, no default) Signing key for session cookies. Generate with python3 -c "import secrets; print(secrets.token_urlsafe(32))". The app won’t start without it.
ATS_DATABASE_URL postgresql+asyncpg://ats:ats@localhost:5432/ats Postgres connection (async driver).
ATS_REDIS_URL redis://localhost:6379/0 Redis connection (arq queue + pub/sub).
ATS_SECURE_COOKIES false Set the Secure flag on the session cookie. Leave off for local plain-HTTP; turn on when serving behind TLS, or the browser drops the cookie.
Variable Default Description
ATS_TIINGO_API_TOKEN "" Tiingo API token — free daily equity/ETF and crypto data.
ATS_DATABENTO_API_KEY "" Databento API key — intraday (1-minute) trades → bars + VWAP. Billed per request.
ATS_ANTHROPIC_API_KEY "" Anthropic API key — powers the Studio code generation, the research copilot, and the Ask the docs assistant. Bring-your-own.
ATS_CATALOG_DIR ./data/catalog The Parquet data catalog (system of record for bars).
ATS_RAW_DATA_DIR ./data/raw Scratch space for raw vendor downloads before they’re written to the catalog.
ATS_ARTIFACTS_DIR ./artifacts Where backtest run artifacts (equity, fills, per-kind JSON) are written.
Variable Default Description
ATS_STUDIO_MODEL claude-sonnet-4-6 The Anthropic model used for Studio code generation and the assistants. Override for cost/quality tuning.

(The Studio also uses ATS_ANTHROPIC_API_KEY, above.)

Variable Default Description
ATS_IB_PAPER_HOST 127.0.0.1 IB Gateway host for the paper account.
ATS_IB_PAPER_PORT 4002 IB Gateway port for paper.
ATS_IB_CLIENT_ID 1 The IB API client id for a running session.
ATS_IB_ACCOUNT_ID "" Your IB paper account id (a DU… id).
ATS_IB_PROBE_CLIENT_ID 999 A high, fixed client id used only for the read-only account/gateway probe, so it can never collide with a running session.

Live trading is unavailable unless ATS_ENABLE_LIVE_TRADING is true and a strategy has cleared an audited approve-to-live step. See live trading.

Variable Default Description
ATS_ENABLE_LIVE_TRADING true Edition flag. The sold/research build ships this false (paper + research only); personal builds leave it true.
ATS_IB_LIVE_HOST 127.0.0.1 IB Gateway host for the live account.
ATS_IB_LIVE_PORT 4001 IB Gateway port for live.
ATS_IB_LIVE_ACCOUNT_ID "" Your IB live account id (a U… id — must not be DU-prefixed).

Orders breaching these are denied before they reach the broker. Live defaults are deliberately tighter than paper.

Variable Default Description
ATS_RISK_MAX_NOTIONAL_PER_ORDER 25000.0 Paper: max notional value of a single order.
ATS_RISK_MAX_ORDER_SUBMIT_RATE 10/00:00:01 Paper: max order-submit rate (count/HH:MM:SS), i.e. 10/second.
ATS_LIVE_RISK_MAX_NOTIONAL_PER_ORDER 5000.0 Live: max notional per order.
ATS_LIVE_RISK_MAX_ORDER_SUBMIT_RATE 2/00:00:01 Live: max order-submit rate, i.e. 2/second.
Variable Default Description
ATS_GATEWAY_MONITOR_ENABLED true Whether the worker background task probes the IB Gateways for health.
ATS_GATEWAY_PROBE_INTERVAL_SECS 900 How often (seconds) to probe each gateway.

Unconfigured = the alert relay idles; nothing breaks. See alerts.

Variable Default Description
ATS_TELEGRAM_BOT_TOKEN "" Telegram bot token.
ATS_TELEGRAM_CHAT_ID "" Telegram chat id to send alerts to.
ATS_ALERT_DRAWDOWN_PCT 5.0 Alert when a session’s balance falls this % below its peak.

Container & gateway environment (not ATS_-prefixed)

Section titled “Container & gateway environment (not ATS_-prefixed)”

A few variables in backend/.env are not ATS_ settings — they’re read by the IB Gateway Docker container (the gnzsnz/ib-gateway image, with IBC inside), not by the app’s Settings. They are only needed when you run IB paper/live trading. See paper / live.

Variable Required for Description
TWS_USERID IB paper/live Your IBKR login username (enable 2FA on the account).
TWS_PASSWORD IB paper/live Your IBKR login password.
VNC_SERVER_PASSWORD optional Set to view the headless gateway’s GUI over VNC (bound to localhost).

These are never ATS_* and never read by pydantic; they pass straight to the gateway container. The gateway image supports other options (e.g. READ_ONLY_API) per its own documentation.

  • Edit backend/.env directly, or use the Settings page (gear icon). Both write the same file.
  • In Settings, each key has a Test button that makes a cheap, non-billed call to the vendor (Tiingo, Databento, Anthropic, Telegram, or the IB account via the read-only gateway probe) and reports whether the key actually works — so you catch a wrong/expired value immediately rather than on first use. The value is validated, never stored or echoed by the test.
  • Whichever you use, restart for the worker to pick up the change. The Settings UI shows the restart command. (The Anthropic key is the one exception: Studio/assistant generation, which runs in the API process, picks it up immediately on save.)
  • ATS_SESSION_SECRET, the database/Redis URLs, and the ports are boot/infra config and can only be changed by editing backend/.env, never from the UI.