Projects / Multi-agent AI

Trading Bot.

Paper trading, by designIG demo account / Oracle Cloud, systemd

Four AI agents scan the FTSE 100 every weekday, rate every setup, and hold an absolute veto over every trade. 115+ sessions in, they have let zero impulsive trades through. That is the point.

4AI agents, one veto
115+sessions run
0trades placed
750GBPhard notional cap, in code
The problemThe operator was the risk

I studied financial markets and I understood them. Trading them profitably was another thing. I'd watch a stock I'd researched all week drop sharply on a single announcement and sell within five minutes, then watch it recover by close. After a red day I'd jump into something I hadn't properly analysed, just to make the loss back.

The analysis was usually fine. It was the real-time decisions that killed it. I'd override my own rules the moment I felt any pressure. So I set out to keep the analysis and take myself out of the execution.

The trading dayNo human input

Every weekday at 10:35 GMT, thirty minutes after London open once the opening noise has settled, the system runs. APScheduler fires five jobs through the day. Nothing is held overnight.

  1. 10:30Start 5-minute candle collection via Lightstreamer
  2. 10:35Full four-agent evaluation across its FTSE watchlist. The only entry window of the day
  3. 12:00Regime recheck: if the market fails the regime gate, close everything
  4. 14:00Second regime recheck
  5. 16:00Liquidate everything. No overnight gap risk, ever
The floorFour agents, one veto

First thing each session: kill-switch and market regime check. If either fails, nothing else runs. News gets scanned and classified by tier before the technical check: EMA, VWAP, RSI. Only setups that pass everything reach the quality gate, where Claude Sonnet rates them against a strict JSON schema. The last word belongs to Claude Opus as risk auditor. If it vetoes, the trade dies. The rails live in code, not prompts: the agents can assess and recommend, they cannot override the config.

OrchestratorGATE
Kill-switch and regime check. If the equity floor is breached or the FTSE fails its regime gate, the session never starts.
Context LeadSCAN
Same-day RNS announcements, classified Tier A (earnings, M&A), Tier B (upgrades, buybacks) or Tier C (skip). No catalyst, no conviction.
AnalystRATE
Technical quality gate. EMA, VWAP and RSI checks, then a structured 1 to 5 rating. Marginal setups score exactly what they deserve.
Risk AuditorVETO
Absolute veto, no appeal. Correlation risk, position sizing, session context. 115+ sessions, and nothing has got past the floor.
trading-bot : session record10:35:07.000 / Sample output
Session 115 is on file. Run it to watch the 10:35 window replay.
10:35:01 SCAN Kill-switch OK, equity above floor
10:35:02 SCAN FTSE 100: +0.12%, session active
10:35:04 PASS AZN: EMA OK, VWAP OK, RSI OK
10:35:04 SKIP SHEL: RSI overbought
10:35:04 SKIP ULVR: below trend
10:35:05 RATE AZN quality gate: 3/5, no catalyst
10:35:06 VETO Risk audit: marginal setup, capital preserved
10:35:07 Session 115 closed flat. Trades placed: 0
Run a 10:35 session and watch the floor vote.
Hard railsConfig, not prompts
RailRuleValue
Max notionalPer trade, absoluteGBP 750
Stop loss / take profitFixed levels, set in configIN CODE
PositionsOne at a time, no pyramidingMAX 1
Kill switchEquity floor: liquidate and stop until manual resetGBP 750
LeverageNone0
Overnight exposureEverything liquidated at 16:000
Every parameter lives in config.pyThe agents cannot touch it
EngineeringThe parts that mattered
  • Structured outputs, no fallback holesThe quality gate used to run on a model whose JSON sometimes failed to parse, and the fallback defaulted the score to 3: a safety hole that could let marginal trades through. Switched to Claude Sonnet with a guaranteed schema. No parse failures, no fallback needed. Prompt caching across parallel scans cut token spend by about 90%.
  • News before numbersEach ticker's RNS gets checked before the technical scan. One API call finds same-day announcements and classifies them by tier. This replaced a screen scraper that kept breaking; the scraper survives only as the fallback.
  • Walk-forward backtesting60-day default, up to two years. Evaluates at 10:35 on each historical day with no lookahead bias and a 0.2% round-trip spread cost deducted.
  • Atomic state, full audit trailA file-locked state manager prevents race conditions between the order manager and the kill switch. Every decision writes to a JSONL audit trail: timestamp, session, stage, ticker, outcome. The whole system is one long paper trail, which is how I like my systems.
What went wrongThe backtests said no

I built this bot to trade. Then I ran the walk-forward backtests, no lookahead, spread costs deducted, and they didn't make the case for going live. So it hasn't gone live. The rule that vetoes an impulsive trade also vetoed an impulsive launch.

The bot agrees with its own data.

Session ledger
Session ledger, reconstructed: walk-forward backtest checks passed but the case for going live was not made, so it stays on paper; a sample 10:35 session ends in no trade
Session ledgerReconstruction: figures real, session log sample
Stack
Python 3.127,000+ lines across 33 files
Claude OpusRisk auditor, the final veto
Claude SonnetQuality gate, structured outputs
IG REST APIDemo account, spread betting
LightstreamerReal-time 5-minute candles
pandas-taEMA, VWAP, RSI indicators
APSchedulerWeekday-only job scheduling
yfinance + ParquetCached history for backtests
Tenacity + filelockRetries and atomic state
Oracle CloudUbuntu VM, systemd, auto-deploy
Other projects
RefProjectSummaryStatus
01 OpsPilot The AI that answers my messages: 6,124+ documents, live finance data, one-click approval. Production
03 Uni-Nation Digital Website, inventory PWA and Hindi voice stock entry for the family fabric business. Being repaired
04 WhatsApp Smart A Chrome extension that gives WhatsApp scheduling, AI replies and summaries. Prototype
05 SCS Cockpit The study engine I built for my own CIMA Strategic Case Study. I passed. Retired, job done