Skip to main content

System Configuration

Fonrex reads its settings from environment variables. Copy .env.example to .env and edit it: Docker Compose loads .env into the API container, and make run loads it for a local run.

Keep one KEY=value per line and put comments on their own lines — a comment written after an empty value is read as the value.

Authentication​

VariableDefaultDescription
FONREX_API_KEY(empty)Full-access API key. Generate one with echo "frx_live_$(openssl rand -hex 24)"
FONREX_API_KEYS(empty)Additional full-access keys, comma-separated
FONREX_READ_ONLY_API_KEYS(empty)Read-only keys, comma-separated: they read data but cannot clear the cache, clean the database, trigger ingestion or change subscriptions
FONREX_AUTH_REQUIREDtruefalse opens every route, only when no key is configured. Use it only for an instance reachable from no network

Clients send a key as Authorization: Bearer <key> or X-API-KEY: <key>. See First API call.

Database and cache​

VariableDefaultDescription
DATABASE_URLpostgresql://fonrex:fonrex_password@localhost:5432/fonrexAddress for a local run. With Docker Compose it is replaced by the db service address, built from POSTGRES_PASSWORD
ASYNC_DATABASE_URL(empty)asyncpg address; derived from DATABASE_URL when empty (Docker Compose empties it)
POSTGRES_DB / POSTGRES_USERfonrexKept for local tools; docker-compose.yml uses fixed values (user fonrex, database fonrex created by postgres-init.sh)
POSTGRES_PASSWORDfonrex_passwordChange it before the first start (letters, digits, -, _)
REDIS_URLredis://localhost:6379/0Replaced by the redis service address with Docker Compose
CACHE_TTL300Default Redis lifetime in seconds (each cached category has its own lifetime, listed by GET /cache/stats)
WEB_CONCURRENCY1Gunicorn workers (Docker Compose). Keep 1: the realtime worker and the daily canary live in the API process

Historical ingestion​

VariableDefaultDescription
INGEST_CONCURRENCY5Parallel ingestions of a bulk ingestion whose caller gives no concurrency
INGEST_YF_DELAY0.5Pause in seconds before falling back to TradingView
INGEST_TV_DELAY2.0Read but not used by the current code
INGEST_BATCH_SIZE1000Rows per database upsert

Real-time streaming​

VariableDefaultDescription
TV_MAX_CONNECTIONS10Simultaneous TradingView WebSocket connections
TV_RECONNECT_DELAY5First reconnection delay in seconds, doubled up to 60
REALTIME_QUOTE_TTL60Lifetime of a quote snapshot in Redis, in seconds

Technical indicators​

VariableDefaultDescription
TECHNICAL_CACHE_ENABLEDtrueCache indicator results in Redis
TECHNICAL_DEFAULT_LIMIT500Bars loaded when a request gives no limit (10 to 5000)
TECHNICAL_MAX_BATCH_TICKERS20Tickers accepted by POST /technical/batch
TECHNICAL_MAX_BATCH_INDICATORS10Indicators accepted by POST /technical/batch

News​

VariableDefaultDescription
NEWS_CACHE_TTL1800Lifetime of a news answer in Redis, in seconds
NEWS_DEFAULT_LIMIT20Articles returned for a ticker when the request gives no limit
NEWS_MAX_LIMIT100Largest limit a request may ask for
NEWS_DEDUP_SIMILARITY0.85Title similarity above which two articles are one

Valuation (DCF) and macro rates​

VariableDefaultDescription
DCF_CACHE_TTL21600Lifetime of a DCF answer in Redis (6 h)
DCF_DEFAULT_PROJECTION_YEARS5Projection years (3 to 10)
DCF_RISK_FREE_RATE0.04Risk-free rate used when FRED gives none
DCF_EQUITY_RISK_PREMIUM0.055Equity risk premium, as a ratio
DCF_TERMINAL_GROWTH_RATE0.025Terminal growth rate, as a ratio
FRED_API_KEY(empty)Free key from fred.stlouisfed.org; without it the stored rate or DCF_RISK_FREE_RATE is used
MACRO_RATES_CACHE_TTL21600Lifetime of the macro rates in Redis (6 h)

Provider monitoring​

VariableDefaultDescription
VALIDATION_OUTLIER_THRESHOLD0.50Deviation from the median above which a value is an outlier
VALIDATION_MIN_PROVIDERS2Providers needed for a consensus check
CANARY_RUN_HOUR6UTC hour of the daily canary run
CANARY_PROVIDER_SEMAPHORE3Providers checked in parallel by the canary
CANARY_PRICE_RANGE_TTL_SECONDS21600Validity of a dynamic price range (6 h)
CANARY_PRICE_RANGE_NEGATIVE_TTL_SECONDS300Retry delay after a range could not be computed
ALERT_CANARY_CRITICAL3Canary failures that raise a critical alert
ALERT_SUCCESS_RATE_CRITICAL0.70Success rate under which an alert is critical
ALERT_SUCCESS_RATE_WARNING0.85Success rate under which an alert is a warning

Providers and outbound requests​

VariableDefaultDescription
SEC_EDGAR_EMAILcontact@fonrex.ioContact address sent to SEC EDGAR (required by the SEC policy): put your own
OPENFIGI_API_KEY(empty)Optional OpenFIGI key (higher rate limit)
BARRONS_TOKEN, MARKETWATCH_TOKEN, WSJ_TOKEN(empty)Optional tokens of these websites
FONREX_PROVIDER_MAX_CONCURRENCY4Requests one provider may run at the same time (1 to 64)
FONREX_PROXY_URL(empty)Optional outbound HTTP proxy for the scraped websites (not for yfinance or TradingView)
FONREX_PROXY_PROVIDERS(empty)Providers that use the proxy, comma-separated; empty means all
LOGO_TOKEN(empty)Token for logo downloads from img.logo.dev

Usage log and start-up​

VariableDefaultDescription
USAGE_LOG_IPnonePart of the caller's IP kept in usage_logs: none, truncated (network only) or full
USAGE_LOG_RETENTION_DAYS90Days of usage log kept; 0 keeps everything
SEED_ON_FIRST_RUNfalseImport data/etf.csv at the first start when the database is empty
OPENBB_ALLOWED_ORIGINhttps://pro.openbb.coOrigins allowed by CORS, comma-separated