Claude Trading Bot: From Single Agent to Production Multi-Agent System
Most 'Claude trading bot' tutorials end at a single LLM call wrapped in a cron job. Useful for a weekend project; not useful for a real account. Here is what it takes to take Claude from one agent to a production multi-agent trading system.
What "Claude trading bot" usually means in 2026
In a Reddit post, "Claude trading bot" usually means a Python script that:
- Pulls OHLC data from a broker.
- Sends a prompt to Claude asking "should I buy or sell?"
- Parses the response.
- Sends an order back to the broker.
That works for a weekend project. It does not work for a real account, for the same reason a single-model bot of any kind does not work for a real account: there is nothing to veto the model when it is overconfident.
This post walks through what it takes to go from that weekend script to a production multi-agent system with Claude as the reasoning substrate.
The weekend version (and why it fails)
Here's roughly what every "Claude trading bot" tutorial on Medium produces:
import anthropic, requests, json, time
def get_market_data(symbol):
return broker.get_ohlcv(symbol, timeframe="H1", count=100)
def ask_claude(market_data):
response = anthropic.Anthropic().messages.create(
model="claude-sonnet-4-5",
max_tokens=500,
messages=[{
"role": "user",
"content": f"Here is recent market data for EURUSD: {market_data}. "
f"Output JSON with action (BUY/SELL/WAIT), entry, sl, tp."
}],
)
return json.loads(response.content[0].text)
def execute(decision):
if decision["action"] == "BUY":
broker.market_order("EURUSD", side="buy", sl=decision["sl"], tp=decision["tp"])
# ... etc
while True:
data = get_market_data("EURUSD")
decision = ask_claude(data)
execute(decision)
time.sleep(60 * 15)
This will trade. It will also, with reasonable probability, blow up the account within 30-60 days. The failure modes:
- No regime check. The same prompt fires in trending markets and choppy markets. Claude does its best with what it sees, but it has no veto if the strategy is wrong for the regime.
- No risk gate. There is no check on position size, drawdown headroom, correlation with existing positions, or news-window proximity.
- No fact-check. The market state moves while Claude is reasoning. By the time the order fires, the spread may have widened or news may have printed.
- No journal. When the bot loses money, there's no record of why. Postmortems are impossible.
All four failures are architectural, not prompt-engineering problems. No amount of better prompting fixes them.
The reason this pattern is so popular is that it's easy to ship. The reason it doesn't work is also that it's easy to ship — anyone with an Anthropic API key can build it in an afternoon. The hard work is everything that comes after.
What a real Claude trading bot looks like
A production-grade Claude trading bot has at minimum five additional layers on top of the weekend version:
Layer 1 — Specialised agents
Instead of one Claude call deciding everything, multiple Claude calls each handle one concern:
- Regime Classifier — Sonnet looking at H1/H4/M15 charts, outputs
STRONG_TRENDING_BULLISHetc. - Strategist — Opus reasoning over M15/M1 + volume, proposes trades for the active regime.
- Risk Gate — Sonnet checking stance, size, DD headroom, correlation, news window. Veto authority.
- FactChecker — Sonnet re-verifying inputs are still true at signing.
- DoubleChecker — Sonnet reaching the same conclusion blindly from a different angle.
- Journal Writer — Sonnet writing the postmortem-ready entry in plain English.
That's 5+ Claude calls per decision cycle, not one. The architecture earns its keep.
Layer 2 — Subscription-first routing
5 Claude calls per cycle at API rates costs real money. Running through the Claude Max x20 subscription via the claude CLI brings the cost to near-zero for retail-scale usage.
The pattern: try the CLI route first; if it fails (subprocess crash, fair-use cap, etc.), fall back to the API. Track every call in a cost ledger.
Read the full subscription-first routing architecture →
Layer 3 — Circuit breakers
When a Claude route fails repeatedly, the system needs to stop calling it before it cascades. A circuit breaker tracks consecutive failures per route; after N failures it "opens" the breaker and routes calls to the next route in priority order. After a cooldown, a single trial request tests recovery.
Three crucial details:
- Half-open allows exactly one trial. Letting multiple requests through during recovery defeats the purpose.
- Counter resets on success. Don't decrement; reset.
- Recovery is exponential (capped at ~1 hour).
Layer 4 — Message bus
Inter-agent communication does not happen through direct function calls. Every agent talks to every other agent through a Postgres table (agent_messages) using LISTEN/NOTIFY for real-time wakeup. The table is durable, append-only, and replayable.
Why this matters:
- Replay. You can
SELECT *from a time window and reconstruct exactly what each agent thought. - Resilience. If an agent crashes, the bus is unaffected.
- Auditability. Every message ever sent is in one queryable place.
Layer 5 — Watchdog outside the agent graph
The single most important layer. A separate process — not one of the Claude agents — watches the system's invariants:
- Heartbeat freshness from the EA.
- Drawdown vs the hard cap.
- Margin utilization vs broker limits.
- Open position stop-loss attachment.
If any invariant breaks, the watchdog issues an L4 HALT. The Claude agents — all of them, including the CEO — cannot countermand it. The CEO can ask the operator to lift the halt; the operator can lift it manually after reading the journal entry that triggered it. There is no auto-recovery.
Claude vs Codex vs OpenAI: the routing question
Production multi-agent systems do not pick one model and stick with it. They route by task type:
- Reasoning-heavy decisions (regime classification, trade reasoning, journal writing) → Claude (CLI preferred, API fallback).
- Code-shaped tasks (parsing JSON, validating regex, generating MQL5 fragments) → Codex CLI (with OpenAI API fallback).
- Edge cases (CLI down, fair-use exceeded) → whichever paid API is up.
The four-route stack (Claude CLI / Codex CLI / Anthropic API / OpenAI API) with circuit breakers is the production pattern. Single-provider lock-in is a fragility no real fund accepts; the same logic applies to retail multi-agent.
A reasonable 30-day path
If you're starting from "I have a Claude API key and an account at an MT5 broker," here's a sane progression:
- Day 1-3. Build the weekend-version single-agent bot. Run it on a demo account. Watch it lose money in a regime it wasn't designed for.
- Day 4-7. Add a Risk Gate. A second Claude call that checks the proposed trade against stance, size, and drawdown headroom. Reject overconfident trades.
- Day 8-14. Add a FactChecker and DoubleChecker. Independent re-verification before signing.
- Day 15-21. Add a Journal Writer. Every decision (vetoed or signed) goes into a markdown journal you read at end-of-day.
- Day 22-25. Wrap the LLM calls in a router with circuit breakers. Add a subscription CLI route if you have a Claude Max plan.
- Day 26-30. Add a separate watchdog process that can issue a hard halt. Configure the EA (or broker integration) to respect the halt unconditionally.
After 30 days, you have something resembling a multi-agent system. You don't have something resembling a production hedge-fund architecture — that takes longer. But the path is real and traversable.
Read about the production architecture in detail →
Where iQntX sits in this picture
iQntX is what the 30-day path described above looks like at maturity. The 32-agent fund uses Claude as the reasoning substrate for the majority of agents (Strategist, Risk Gate, FactChecker, DoubleChecker, Macro Officer, Journal Writer, ...) and uses Codex for code-shaped tasks. The four-route LLM router handles fallback. The watchdog runs outside the agent graph.
The architecture is portable. The discipline is what makes it work. The Claude API key is the start, not the end.
Keep reading
- Building Multi-Agent Trading Systems with Claude — the LLM-routing layer in detail.
- LLM Trading System Architecture — generalizing beyond Claude.
- What Is Multi-Agent Trading? — the architectural foundation.
- How a 32-Agent AI Hedge Fund Beats a Single-Model Bot — the full production system.
Try the production version
iQntX uses Claude across 32 agents in production. Join the waitlist to skip the 30-day path.
Writes about multi-agent AI trading architecture, hedge-fund operations, and risk discipline for retail and prop-firm traders.
Questions readers ask about this
If you find a question we should add, send it to hello@iqntx.com.
Can Claude actually trade?
Claude doesn't have direct broker access — it's a reasoning model, not a trading platform. What you can do is use Claude as the decision-making layer inside a system that connects to a broker. The pattern: market data flows in, Claude reasons over it, structured output flows out, your trading infrastructure executes the decisions. iQntX uses exactly this pattern across 32 agents.
Why Claude specifically and not GPT?
Three reasons that matter for trading workloads. First, Claude has been particularly strong at structured output and tool-use scenarios, which is what trading decision pipelines need. Second, the Claude Max x20 subscription gives flat-rate access at retail price, where per-token API would cost hundreds per month for an active multi-agent system. Third, Anthropic's safety-tuning means Claude is more likely to refuse over-confident outputs in ambiguous regimes — useful when the right answer is often WAIT.
Is Claude better than GPT for trading?
For reasoning-heavy structured-output tasks (regime classification, trade reasoning, journal writing), Claude is generally preferred. For code-shaped tasks (parsing regex, validating JSON, generating MQL5 fragments), Codex (OpenAI) is generally preferred. A production system uses both, with a router that picks the right model per task type. The two providers are complementary, not competitors.
Can I run a Claude trading bot on the API alone?
Yes, but it gets expensive fast for active multi-agent systems. A 32-agent setup running 7,000 LLM calls per day costs $1,500-2,400/month on the pure-token API at Sonnet rates. The same workload routed through the Claude Max x20 subscription costs ~$220/month flat. Subscription-first routing is what makes multi-agent affordable for retail.
Does Claude have a trading API?
Anthropic does not offer a 'trading API' as such — Claude is a general reasoning API. The trading-specific layer (broker integration, execution, risk management) is something you build (or buy) on top. The standard architecture: broker side runs on MT5/Alpaca/Interactive Brokers; brain side runs on Claude (via API or subscription CLI); a thin layer in between (FastAPI, ZeroMQ, whatever) brokers messages.
What's the simplest Claude trading bot setup?
A single Python process that (1) pulls price data from your broker, (2) calls the Claude API with a structured prompt asking for a trade decision, (3) parses the JSON response, (4) executes via the broker API. Maybe 300 lines of code, runs on a cron job. It works for proof-of-concept; it does not survive real money for long because there's no veto layer.
Why isn't a single Claude call enough?
Because single-model bots have nothing to veto themselves. Claude is excellent at reasoning, but no LLM should be the sole decision-maker on a real account. The architectural answer is multiple Claude calls with different roles — a Strategist Claude proposes, a Risk Gate Claude vetoes, a FactChecker Claude re-verifies. Independence of opinion is what catches the overconfident call.
Keep reading
RelatedBuilding Multi-Agent Trading Systems with Claude (the Subscription-First Way)
How a 32-Agent AI Hedge Fund Beats a Single-Model Bot
What Is Multi-Agent Trading? (And Why It Beats Single-Model Bots)
Ready to put this on autopilot?
The waitlist is your fastest path to a private cohort. We open in waves so the system never gets in front of itself.