08AI and automation · 2026 Interactive
Risk Gate
An AI trading system built to say no.
A day-trading bot for UK spread betting where deterministic code finds and sizes every trade, an AI reviewer can only approve or veto, and a risk gate that holds the broker keys decides whether anything is sent. Fire a signal below, then try to sneak a bad one through.
- Role
- System design, risk engineering, broker integration, AI review, operations
- Platforms
- Stack
- TypeScript · Node · IG REST API · LLM API · MCP · Tailscale
- Status
- Demo and practice accounts only
The request path needs JavaScript. It walks a trade through the strategy, an AI review and twelve gate checks.
Fire a signal to watch a clean trade pass.Then switch on anything under "Try to break it" and fire again.Hover a check to see what it measured.
- 12Checks between any signal and the broker, first failure rejects
- 1Thing the AI may do: veto. It never sizes or places a trade
- $10Default monthly cap on model spend; signals skip once it is reached
- 100%Of requests written to an append-only audit log
The principleCode decides, the model checks
A language model should never be the thing that moves money. Here the strategy is plain, testable code running on closed 15-minute candles, and the same code drives both the live scanner and the backtester. When it fires, a fast AI model reviews the setup and can veto it for about a third of a cent. Only then does the request reach the gate.
Every Sunday, a larger AI model writes a review of the week's trades with lessons and suggestions for a human to read. It changes nothing on its own.
EngineeringThe only path to the broker
The gate holds the IG credentials, fetches every account and market value itself, and takes nothing from the requester except the request. Checks run in order and the first failure rejects; any broker error rejects too. Stops can only be tightened, never widened, and closing a position is always allowed.
if (!c.record("kill_switch", !haltActive(), haltActive() ? "HALT_TRADING exists" : undefined)) return c.result();
const lossLimit = -Math.min(LIMITS.dailyLossFraction * acct.equity, caps?.maxDailyLossGBP ?? Infinity);
if (!c.record("daily_loss_cap", todayPnl >= lossLimit, `today ${todayPnl} vs limit ${lossLimit}`))
return c.result();
const spreadOk = spread > 0 && spread <= m.maxSpread
&& req.stop_distance >= LIMITS.minStopToSpread * spread;
if (!c.record("spread", spreadOk, `spread ${spread} (max ${m.maxSpread})`)) return c.result();
OperationsBuilt to be left alone
Cron runs the scan every 15 minutes and a position check every minute: flatten at session end, move stops to breakeven, record trades and send Telegram alerts. A kill switch blocks new entries from the strategy and the model, while manual closes and the end-of-day flatten still work, so a halt never traps a position overnight. Real-money trading refuses every entry until the account is explicitly armed on the server with pound caps.
The test suite covers every gate rejection, the kill switch, stop tightening, sizing, backtest costs and the approve, veto and budget paths, against a mock broker and a mock AI reviewer.
What this means for your project
- Safe AI integrationModels in advisory roles with hard limits, budgets and audit trails.
- Financial systemsBroker APIs, position sizing, risk limits and end-of-day operations.
- AutomationScheduled jobs, alerts and recovery that run without a human watching.
- Security engineeringCredential isolation, a threat model and a go-live checklist.