cTrader Markets
cTrader Markets is a profile-scoped FastAPI service that owns one persistent cTrader Open API connection and re-exposes it over HTTP: live spot ticks as Server-Sent Events, plus REST access to the latest tick, closed trendbars (OHLC), and symbol metadata.
Other apps in this repo consume this service over HTTP instead of embedding their own broker client.
Why a separate service
The cTrader Open API is a persistent, authenticated, protobuf-over-TLS session with a heartbeat and a reconnect protocol. Every consumer that wants a price should not have to own that. One process per broker account holds the connection, and everything else makes an HTTP call.
What it exposes
- SSE ticks — live bid/ask streams with replay of the last known quote on connect
- REST tick / candles / symbols — latest cache, closed trendbars, resolved catalog
- Health — unauthenticated liveness and readiness (connected + fresh ticks)
Explore the docs
venv install, OAuth token flow, and discovering accounts and symbols.
Getting Startedforex and deriv profiles, ports 8010/8011, one process per account.
ProfilesNo Twisted, asyncio protobuf, hub fan-out, and backpressure.
ArchitectureTOKEN_CACHE_PATH, rotation, and why losing the cache means redoing OAuth.
Token LifecycleEndpoints, candle END stamp, and SSE tick/status events.
API ReferenceEnv variables for credentials, bind, symbols, reconnect, and SSE.
Configurationops/install.sh, launchd units, and operational failure modes.
DeploymentUnit tests vs the never-run integration suite.
Development