04 / Trading systems
ClarttCapital
A Go trading engine and “alpha factory” that generates, tests and runs systematic strategies on crypto perpetuals, synthetic indices and FX.
- Role
- Sole author
- Status
- Running · research ongoing
- Period
- 2026 — now
- Type
- Trading systems
- lines of Go, tests included
- ~71k
- per event on the hot path
- µs
- variants in a single study
- 1,266
- locked holdout per candidate
- 120d
A / Architecture
Deterministic single-process engine
Market data, strategy, risk and execution run in one Go event loop, so live trading and simulation behave identically. A NestJS backend, a React dashboard, recording, research and AI supervision sit around the core — never inside its hot path.
00 Venues
- Bybit v5 · WebSocket
- Bybit v5 · REST
- Deriv API
01 Engine · Go
- Market-data normaliser
- Streaming alpha operators
- Risk gates
- Order manager
02 Research
- Order-book recorder
- Queue-aware simulator
- Alpha factory
- AI supervisor · shadow
03 Services
- Backend API · NestJS
- Dashboard · React PWA
- Web push
04 Data & ops
- PostgreSQL
- SQLite journal
- Prometheus · Grafana
Before
NestJS orchestration with separate Python strategy and execution engines, joined by Redis streams.
After
One Go core: market data, strategy, risk and execution in a single event loop with no network or disk on the hot path.
WHY · Every process hop added latency and non-determinism, and a blocking stream read once stalled the pipeline. One process removed that class of bug and made backtests trustworthy.
Engineering notes
- 01
One goroutine, no I/O on the hot path
The engine is a single-goroutine event loop with no network or disk while deciding. Risk gates check data freshness, leverage, price bands, order rate, daily loss and drawdown — and reduce-only orders always pass.
- 02
A language for alphas
Signals are expressions like tanh(ts_zscore(ts_return(close,42),200)/1.5), compiled to streaming operators that run identically in the live engine and in simulation.
- 03
A simulator that doesn’t flatter
Paper trading models queue position, post-only rejections, book sweeps and latency. A recorder writes hourly zstd-compressed order books, with a replay command.
- 04
Research that’s allowed to say no
Pre-registered tests, locked holdouts, placebo checks, Deflated Sharpe against the effective number of trials, de-duplication of correlated alphas and a daily decay review.
- 05
AI in a box
Claude proposes candidates under a $1/day budget and supervises hourly in shadow mode. It can only make bounded, risk-reducing changes and is never on the order path.
- 06
Push alerts, straight from the RFCs
Fills and risk halts reach a phone through Web Push implemented directly from RFC 8291 and RFC 8292 — since extracted into a zero-dependency Go package verified against the RFC’s test vector.
B / Infrastructure & delivery
How it ships, scales and stays up.
- Hosting
- Script-provisioned VPS; Docker Compose with an autoheal sidecar; Caddy terminates TLS.
- CI/CD
- Per-service change detection → Go and Node tests → matrix image builds to GHCR → sync and self-bootstrap on the VPS → smoke test.
- Observability
- Prometheus scraping the engine and backend; provisioned Grafana trading dashboards; mobile web-push alerts.
- Data
- PostgreSQL for research and results; SQLite journal for the engine; hourly zstd order-book recordings with replay.
- Risk
- Data-freshness, leverage, price-band and order-rate checks; daily-loss and drawdown halts; reduce-only always allowed.
- Testing
- 67 Go test files across engine, book, simulator, formula compiler and venue connectors.