When I set out to build Traders Regiment, I had one rule: no shortcuts. Every component had to be built the way an institutional quant team would build it — with the right tool for the right job, with explicit contracts between layers, and with failure modes that were designed for rather than discovered in production.
This is the architecture of that system. Every layer, every decision, every reason.
Traders Regiment is a monorepo with six independently deployable services:
React with Vite for fast hot-module replacement in development and optimized production builds. The frontend is purely presentational — it owns rendering and user interaction. All business logic lives in the BFF. Components are pure: props in, UI out. Heavy components lazy-loaded with React.lazy().
Express.js Backend-for-Frontend. All ML engine calls, news fetches, and Telegram messages are orchestrated here. This is where the async-first, concurrent-by-default rule lives: when a consensus call is made, all 12 models are queried simultaneously — not sequentially. Bottleneck is the slowest model, not the sum of all models.
Every model runs in its own isolated process. FastAPI handles routing. All responses follow a strict BaseResponse contract with ok, error, latency_ms, and timestamp. Every endpoint has a 5-second timeout and a circuit breaker.
Event-driven bot that delivers consensus signals, regime changes, and Watchtower alerts directly to the trader's phone. Low latency. Rate-limited. Never floods the chat.
No single language is best for everything. We chose each language for what it does best:
| Task | Language / Stack | Why |
|---|---|---|
| Real-time signal orchestration | Node.js |
Non-blocking async I/O — concurrent calls to 12 models at once |
| ML model inference | Python |
scikit-learn, LightGBM, PyTorch — mature, best-in-class ML ecosystem |
| Sequence modeling | PyTorch Mamba |
State-of-the-art long-range dependency modeling for market sequences |
| Regime detection | Python |
HMM, fractal analysis, anomalous diffusion — statistical foundations |
| Frontend UI | React |
Reactive component model — fast, declarative, easy to test |
| Data pipeline | Python (pandas, numpy) |
Best for numerical, time-series, and financial computation |
| Telegram bridge | Node.js |
Event-driven architecture matches Telegram's webhook model |
| Circuit breaking | Node.js |
Built-in async error handling + promise race conditions for timeouts |
This is the core of Traders Regiment. Every trading decision passes through five phases:
Each model is an independent analytical agent with its own specialty. They don't know about each other — they just produce their output. The ensemble aggregator collects all votes and converges on a consensus:
Phase 2 doesn't end with a simple vote. The ensemble aggregator runs a multi-round deliberation:
The result is not just a majority vote — it's a deliberated consensus that has been stress-tested against dissenting views.
The Board Room is our governance layer. It exists to prevent bad trades, not just to confirm good ones. It has veto power — and it uses it.
Consensus rule: 3 out of 5 Board Members must agree to proceed. Any single veto — from RiskOfficer, RegimeWatcher, or OptionsDesk — converts the signal to NEUTRAL. RiskOfficer always has the final word.
| Board Member | Specialty | Veto? |
|---|---|---|
| Tech_IB | Trendline + horizontal structure geometry | No |
| Tech_Candle | Candle patterns, wick noise filtering ("wick = noise, close = truth") | No |
| RegimeWatcher | CRISIS and CONTAGION regime detection | YES |
| OptionsDesk | Expiry day detection, LOW_IV regime | YES |
| RiskOfficer | Daily stop (2 losses), max positions (1 open) | YES — ALWAYS FINAL |
regime == "CRISIS" or "CONTAGION" → RegimeWatcher vetoesis_expiry_day == True or iv_regime == "LOW" → OptionsDesk vetoeslosses_today >= 2 or positions_open >= 1 → RiskOfficer vetoesdead_chop == True (ATR < ATR_avg × 0.5) → Tech_IB vetoeswick_alone == True (wick signal without close confirmation) → Tech_Candle vetoesThe Board Room cannot be overridden by any other component. RiskOfficer veto is absolute. No code, prompt, or agent may disable or bypass these conditions.
Watchtower is our performance monitoring and self-correction layer. It runs continuously, not on-demand.
Watchtower monitors:
Watchtower is the reason Traders Regiment doesn't just work on day one. It works better on day 30, and even better on day 300. The system learns from its own performance.
Traders Regiment uses Elastic Weight Consolidation (EWC) — a technique that allows the AI to learn new market patterns without catastrophically forgetting the patterns it already knows. This is critical in trading, where old regimes return and old patterns resurface.
The continual learning pipeline:
Security is not a feature. It's architecture. Every layer has explicit security controls:
| Security Measure | Layer | What It Prevents |
|---|---|---|
| No secrets in code | All layers | Credentials in git history |
| Parameterized SQL queries | ML Engine | SQL injection |
| Pydantic input validation | ML Engine | Malformed inputs |
| 5s timeout + circuit breaker | BFF | Cascading ML failures |
| Rate limiting | BFF | API abuse / DoS |
| SSH key auth + fail2ban | VPS | Brute-force access |
| UFW firewall (SSH locked to known IPs) | VPS | Unauthorized network access |
| Zod validation on all BFF routes | BFF | Bad data entering the system |
dvc repro recomputes the full pipeline. dvc push/pull syncs models and data to/from remote storage.The current architecture is the foundation. Here's what's being built on top of it:
The architecture was designed for growth. Every layer has explicit contracts. Every service is independently deployable. Adding a new model family takes one new subdirectory and one new BFF route — nothing else needs to change.
12 models. Board Room governance. Watchtower self-correction. This is what institutional quant intelligence looks like — in your browser.
Access Traders Regiment →