Skip to content
Mitul Shah

Case Study — Personal Project

Autonomous Trading Agent

An autonomous AI agent that trades a real brokerage account on its own — under a risk constitution it can't override.

  • 4/day

    Autonomous trading sessions — no human approves a trade

  • ~20checks

    Hard pre-trade rules every order must pass

  • ~70tests

    Unit tests over the risk gate and event-sourced ledger

  • 3sleeves

    Core ETF, tactical swing, and defined-risk options

Why I built it

This is an experiment in giving an AI genuine autonomy over a real — deliberately small — brokerage account. Four times a day, on a fixed schedule, Claude wakes up in a cloud session, reads the market, forms a plan, places limit orders, sets protective stops, and writes up what it did, entirely on its own, with no human approving individual trades. What makes it more than a trading bot is the governance: a written constitution of hard rules it cannot rewrite, a paper-trading proving period before any real money moves, and a weekly self-review where it grades its own performance and tunes its strategy within fixed bounds. It is built to survive first and compound second.

How it works

  1. Think — before the open, it scans markets, macro data, and news, then writes the day's trading plan.

  2. Act — just after the open, it executes only that plan and places protective stops in the same session.

  3. Manage — at midday and the close, it services targets and trailing stops, then writes the daily report.

  4. Reflect — weekly, it grades its own performance, updates its lessons learned, and adjusts strategy within preset bounds.

Between sessions, protective orders rest at the broker, so the account is never unguarded. And every run reconciles the agent's own records against the live account before it acts — the broker is truth; the repository is memory.

The safety system

  • A constitution it can't override

    Every order must pass roughly twenty hard pre-trade checks. The agent cannot rewrite its own safety rules — changing them requires a human-approved pull request.

  • Capital preservation first

    Automatic kill switches freeze or liquidate the account on drawdowns. It places limit orders only, and every position carries a resting protective stop at the broker.

  • It only ever de-risks on bad news

    It reads Fed policy, inflation prints, and geopolitics — and downgrades its risk posture when the news turns bad. It never chases.

  • Proven on paper first

    No real money moves until the system has earned it through a paper-trading proving period. Real capital is the last step, not the first.

  • Tax-aware by construction

    A long-term-hold core sleeve, wash-sale fencing across the owner's other accounts, and reporting that's always net of a tax reserve.

Strategy

A three-sleeve approach: a buy-and-hold core ETF sleeve (~55%), a tactical swing-trading sleeve (~30%) that uses professional setups with strict risk-per-trade limits, and a small, defined-risk options sleeve (~15%) that stays dormant until the account grows. Entries lean on real technical analysis — trend, RSI, MACD, with ATR-based position sizing — never gut calls. It started with a deliberately small $500 stake: tuition, while the system proves itself.

Tech & engineering

  • AI: Claude (Opus) running as scheduled, autonomous Claude Code cloud sessions — no laptop, no human in the loop.
  • Brokerage: Robinhood's agent API over the Model Context Protocol (MCP).
  • Python core: hand-rolled indicators, an event-sourced ledger, a pure-function risk gate, and ~70 unit tests.
  • Data: market history with multi-source fallback, the Fed's FRED economic data, and live web search for news.
  • Transparent by default: a live dashboard and daily reports pushed to its own repository, plus a phone notification on every trade.
  • Git as the agent's memory and audit log — every decision is version-controlled.

This is a real experiment with real risk, run at a deliberately small scale. The point was never the P&L — it's whether an AI can operate safely and autonomously under rules it can't break. The most interesting results so far are about governance, not returns.