[<< BACK TO PROJECTS]
Agentic AI + Algorithmic Trading2026 · Operational Prototype

# TraderBro

A 24/7 self-improving agentic AI trader on Deriv and cTrader. A deterministic engine of ~30 indicators, market-structure signals, volume profile, and multi-timeframe checks gates every trade; an LLM council sits around it as a tie-breaker and risk-only veto. Learns from every outcome via a persistent SQLite journal, calibration, and backtested strategy promotion.

Agentic AIAlgorithmic TradingDerivcTraderLLM CouncilRisk GuardrailsPythonReact 19Vite

Overview

TraderBro is a 24/7 self-improving agentic AI trader on Deriv and cTrader. The part that places trades is ordinary code, not an AI: about 30 indicators, market-structure signals, volume profile, and trend checks across several timeframes, combined into a score. Every candidate trade passes through a fixed sequence of gates — quality score, expected-value check, then hard risk limits — and any one of them can kill it. An AI sits around that engine, not in front of it. It can break a tie, veto a trade the engine wanted, or shrink its size. It can never invent a trade, choose a position size, or loosen a risk limit. On a slower cadence, a council of AI agents — analysts, a bull and a bear that argue, a risk manager, a portfolio manager — reviews the market and files an opinion with read-only tools. Every decision and outcome goes into a local SQLite file: what it did, why, what it predicted, and what actually happened. It compares predictions to reality, writes lessons from losses, and keeps backtesting candidate strategies against the champion. A challenger only replaces the champion by beating it on out-of-sample data. Per-trade stake, total exposure, a daily loss stop, a drawdown kill-switch, and a cooldown after consecutive losses are enforced in code and are customer-editable with plain-language notes about what loosening each one costs. The system starts on a demo account and cannot touch real money until two independent locks are cleared: a settings switch and a track-record promotion gate (30+ trades, 50%+ win rate, profit, 50+ backtest trades, positive average return, wins ahead of losses, drawdown within limits).

Problem

Retail trading bots either hand all decisions to an LLM (uncontrollable, hallucinates prices) or freeze a single strategy (no adaptation). Neither survives contact with live markets. The task was to build a system where the AI can reason but can never invent data, loosen risk, or place a trade the deterministic gates did not approve.

Approach

Two brains, one loop. A fast deterministic pipeline scores every candidate through quality, expected-value, and hard risk gates; an LLM breaks ties inside the loop and can only veto or shrink size after the gates. A slower council (analysts → bull/bear debate → risk manager → portfolio manager) runs on a cadence with read-only data tools — no execution tool exists. Strategies are data (StrategySpec), not code; challengers replace champions only on out-of-sample data. Demo-first with a two-lock promotion gate before any real money.

Impact

  • * Brokers: Deriv (WebSocket + REST) and cTrader (Open API + MCP), behind a neutral BrokerAdapter so core modules never branch on broker.
  • * Risk guardrails enforced in code: per-trade stake, exposure caps, daily-loss stop, drawdown kill-switch, loss-streak cooldown — all customer-editable with plain-language hints; the LLM can only tighten them.
  • * Persistent memory: decision journal, outcome reconciliation, calibration (predicted vs realized), and lessons fed back into future reasoning.
  • * Ships as standalone binaries (macOS/Windows via Nuitka/PyInstaller) and a React 19 + Vite dashboard with an interactive agent-council graph and strategy builder.

Architecture

TraderBro is a two-layer agentic trading system: a deterministic decision engine that gates every trade, with an LLM council that can only reduce risk. The entry pipeline is a fixed sequence of gates — any one can kill a candidate — and the council runs on a slower cadence with read-only tools only.

Layer
Implementation
Purpose
Decision loop
agents/trader_loop.py — deterministic per-symbol pipeline
data + multi-timeframe snapshot → posture → exit management → stale-feed guard → session filter → calendar embargo → strategy gate → quality gate (0–100) → forecast gate (+EV) → risk guardrails → agentic override. Every layer must agree before a trade is placed.
Agentic layer
agents/agentic_trader.py + agents/council/
The LLM sits inside the loop as a tie-breaker and after guardrails as a veto that can only reduce risk. The council (analysts → bull/bear debate → risk → portfolio manager) runs on a cadence with read-only data tools. No execution tool exists for the council.
Strategy lab
strategy/ — backtest, walk-forward, improvement loop, registry
Strategies are data (StrategySpec), not hardcoded logic. Challengers backtest against the champion and replace it only on out-of-sample data. A promotion gate (30+ trades, 50%+ win rate, profit, 50+ backtest trades, positive avg return, wins > losses, drawdown in limits) must be satisfied before live trading.
Risk guardrails
risk/guardrails.py + risk/sizing.py
Per-trade stake, total exposure, daily-loss stop, drawdown kill-switch, loss-streak cooldown — enforced in code with conservative defaults. Customer-editable from the dashboard with plain-language hints; the LLM can only move them safer. Dangerous settings require typed confirmation.
Memory & learning
memory/ — SQLite journal, calibration, reflection, beliefs
Every decision and outcome is journaled. The system compares predictions to reality, writes lessons from losses, and keeps calibration data (predicted vs realized) to improve future reasoning.
Brokers
deriv/ + ctrader/ behind BrokerAdapter
Deriv (WebSocket + REST) and cTrader (Open API + MCP) sit behind a neutral adapter. Core modules never import or branch on broker-specific code. Reconnect-with-backoff, not per-call retry, avoids duplicate fills.
Dashboard
apps/web/ — React 19 + Vite + Tailwind 4
Trading terminal with live candles and indicators, interactive agent-council graph (drag nodes, wire connections), agent persona editor, strategy builder with backtest + walk-forward + council review, and a decision-pipeline view that names the gate that stopped each skipped trade.

Guardrails

  • * Never invent market data — every number traces to a real broker tick or stored artifact. Hallucination is treated as fatal.
  • * Demo-first: locked to demo until config explicitly allows live AND the promotion gate is satisfied. Customer can bypass with typed confirmation, accepting full responsibility.
  • * The LLM can only reduce risk, never increase it. Strategies are data, not code. Tests only get stronger.
  • * Survival-first doctrine ('Survive first. Trade only with an edge. Never invent a number. Cut losers fast.') is injected in code and cannot be edited away.