Personal project · 2026
Designing Guardrails for an AI Agent That Trades Real Money
A live AI trading agent on a small real-money account, and the guardrails that decide what it can and can’t do.
Still running; results as of the 11/2 postmortem
I built and run an AI agent that trades a small real-money account, a little over $500. This write-up is about the guardrails: what the agent is allowed to do, what it can’t do even if it tries, and what I had to fix when a rule either missed something or blocked too much. The returns were secondary to the learning from doing it. As of the 11/2 postmortem, the account is down $1.35 across 16 closed trades.
The setup
I’d wanted to try something like this for over a year, and when Robinhood released an MCP connector (a plug-in that lets Claude use Robinhood’s trading tools directly), I got serious. Investing has been a hobby of mine for decades, and experimenting with AI has become one too. So I combined them: what would happen if Claude and I ran a real portfolio together, as two analysts?
I had two goals: learn short-term trades and options (contracts that pay off if a stock moves a certain way by a certain date) by actually doing them, and learn how to work with Claude on live trading. This case study focuses mostly on the second one, but the two are tangled together: we’ve used different types of instruments and trades, and when I wasn’t fully versed in something, I relied on Claude for explanations.
How it works:
- Claude Code in my terminal does the research, scans for setups, and proposes trades with a buy price, a stop (the price where we’d sell to cap the loss) and a target (where we’d take the profit).
- Every order is previewed first, and nothing is placed until I give an explicit yes.
- A dedicated account, the sandbox, is the only one Robinhood lets an AI agent trade. My other accounts are off limits.
- Two scheduled cloud jobs watch open positions and email me. They’re read-only: they have no order-placing step.
- A git repo (a project folder that tracks every change) holds the rules: the agent’s instructions, a trading playbook, a journal, and a log of every trade, including the ones we skipped. That lets me run it from anywhere, including from my phone, using Claude Code’s remote-control feature.
How it unfolded:
- June: the first trades, all swing trades (held for days or weeks) under the original rules. Four positions (five closed trades), all closed by 7/1.
- July to mid-September: almost nothing. One trade, from 8/26 to 8/31. Otherwise the rules blocked everything (more on that below).
- 8/26: I moved the project into a git repo so I could run it from anywhere, and the order guard went live in code.
- 9/23 to 9/24: I reset the purpose and started a two-week trial of a new setup: the money split into three buckets (short-term trades, options and swing trades), each with its own budget, plus seven account-wide safety rules. One is a circuit breaker that blocks new buys after a bad day, a losing streak, or too many new positions in a week. Options trading started at this time.
- 10/7 to 10/8: Claude wrote up a review of the trial with seven recommendations, and I adopted them on 10/8. That review counts as the first postmortem (a scheduled look back at what worked and what didn’t) of the agentic trading account.
- 11/2: the first monthly postmortem. It covered 10/8 to 10/30 and graded every trade on process, not just profit. I adopted its recommendations the same morning, except one (below).
What could go wrong
The question behind the guardrails: with an AI agent that can place real orders, what are the ways money gets lost that have nothing to do with a bad trade?
- The agent gets talked out of a rule. Rules written in its instructions are context, not enforcement. A model can be talked out of them.
- Not paying close enough attention. A mis-tap on a phone can approve a preview I didn’t really read. A typo can send an order to my personal account or IRA instead of the sandbox, or turn 6 shares into 60.
- Trading through a bad run. Every order can look fine on its own while the account is having a bad day or a losing streak.
- A guard that traps me in a trade. A safety check that blocks a sell is worse than no check at all.
- Quiet failures. The dangerous ones don’t throw an error. The guard just stops running, and nothing tells you.
The design
Each check catches what the one before it can’t. My yes catches misreadings. The code catches what a tired yes lets through. The broker stops the agent from touching any account but the sandbox.
Every order Claude places from the project clears me, code and the broker
- only the sandbox account
- sells and stops are always allowed
- buys capped at $250
- no new buys after a bad day, a losing streak or a busy week
- if it can’t read the order or its status file, it blocks the buy
The guard is a small program that runs automatically every time Claude tries to place an order. It runs outside the AI model itself, so in a session started from the project folder, Claude can’t skip it or argue past it, and sells are never blocked, so it can’t trap me in a trade. Claude and I wrote the guard’s code together; the rules in it are mine.
| Check | Where it lives | Why there |
|---|---|---|
| Explicit yes on every order | Me | It’s my money. Keeping the final yes with me is what lets the agent propose aggressively. |
| Sandbox account only | Code and the broker | A typo or the wrong session can’t reach my other accounts. |
| $250 cap on buys | Code | Catches a wrong size, like 60 shares instead of 6, which a quick yes might miss. |
| Circuit breaker (daily loss, losing streak, weekly budget) | Code, reading a status file the agent keeps up to date | Each order can look fine while the account is having a bad run. |
| Sells and stops always allowed | Code | A guard that traps you in a trade is worse than none. |
| Stops held at the broker (required for every stock entry since 10/22) | Broker | A fast drop can’t wait for my reply. |
| One position per sector | Checked at preview, not in code | Adopted 10/8 as one open position per sector, checked by eye. The 11/2 postmortem kept it by sector, with no separate rule for positions driven by the same thing. |
| Options price cap, no buying in the first 15 minutes of trading, no chasing a stock that’s already run up | Prompt and playbook | Not in code. Claude checks them, and I see them on the preview. |
When the rules got too strict
Guardrails have a cost, and for a while the cost was that no trades happened.
I made rules. Then I wanted to go deeper and wider, so I added more rules. The playbook let a stock in through any one of several signals, but then every candidate had to pass every check (we called them gates) before Claude could even propose it. The rules became too restrictive, because every rule had to be met before any trade.
The journal shows how that played out:
- July: nothing passed every check, so we made no new trades after 7/1. The journal’s verdict, again and again: “No entries — nothing passes all gates.”
- August: one check was relative strength: a stock had to be doing better than the overall market (the S&P 500). From 8/1 to 8/14, the market’s gains came from giant tech companies alone, and our rules excluded those. So all 34 stocks we were tracking trailed the market and failed that check automatically. The rule we wrote on 8/17: change a rule only when there’s evidence it’s flawed, never just because the money is sitting idle.
- Before the reset: 19 trading days in a row with no open positions.
On 9/23 I reset the purpose. This is play money for learning by doing, so “nothing” stopped being the default answer. We split the account into three buckets (short-term, options and swing), loosened the swing-trade rules, and two days later dropped one check that only repeated the other checks: it asked whether a stock met at least 3 of 4 conditions the other checks already tested.
On 10/8 we added one more kind of rule: at most one open position per sector, after two healthcare trades turned out to be the same bet.
The guard in code made a strictness mistake too. On 9/24 it blocked a legitimate $50 buy because it read the wrong field name for dollar-based orders. It failed safely, which is the right direction, and it was fixed and re-tested the same day.
Near-misses (and one test)
One of these was a deliberate test, and only one cost money, not much. Most of them changed the system.
| Date | What happened | What caught it | What changed |
|---|---|---|---|
| 8/26 | A Claude session started in the wrong project folder still had access to the brokerage, but none of the rules or the guard loaded. One direct command would have placed a real order. | Found by accident while testing the guard; that session reported it. Nothing was placed. | Trading sessions start from the project folder, and I check which project I’m in first. The guard belongs to the folder, not the brokerage account. |
| 8/26 | The connection to Robinhood came back under a different internal name. A guard looking for the old name would have silently stopped working. | Found while testing the guard. | The guard now recognizes the order tools under any name. Rule: never narrow it. |
| 10/1 | I wrote “next up is the next check in 15 minutes, not the 4:12 closing run.” Claude read it as an order to retry a stop on an options position, scheduled the retry and ran a preview. | Me, on the preview. Nothing was placed or cancelled. | If a message is ambiguous, ask before turning it into a trade action. |
| 10/5 | The losing-streak rule had no reset. Read literally, it would have locked the account until a winning trade, which the lock itself prevents. | Claude held the safe state (buys blocked) and asked instead of improvising. | I reset the count and wrote the reset rule. |
| 10/15 | I replied “great thank you” to a preview. | Claude didn’t treat it as a yes and asked. I gave a conditional yes, it re-checked the live price, re-previewed at a lower price, then placed. | Nothing new: the 10/1 ask-first rule held. A thank-you is not a yes. |
| 10/16 | A deliberate test, not a mistake. Trading from the Claude iOS app hadn’t worked before, so I checked whether it did now: a 1-share order at $1.00 that couldn’t fill, cancelled 45 seconds later. I didn’t tell the project about it. | The project’s scan two days later found an order it hadn’t placed and asked me about it. I explained, and that was that. | No code change. It confirmed the guard’s boundary: it doesn’t run in the app, so real orders still go through the project. |
| 10/22 | A price alert said a stock had fallen to its stop. The position was in fractional shares, which can’t have an automatic stop order at the broker, so the sale waited on my yes. By then the price had dropped further: the loss was 1.43 times what I’d planned to risk, instead of 1 times. | The brokerage alert, then me. | Hold whole shares only, with a stop order held at the broker. Adopted the same day. |
| 10/26 | The written rules allowed a buy even though the price had already moved, so the possible gain was only 0.87 times the risk instead of the planned 1.5 times. | Claude flagged it before the trigger. I passed. | Logged as a skip. The 11/2 postmortem turned it into a rule: every plan names a highest entry price, and above it we skip. |
What a yes looks like
- Claude Order preview Buy 1 XLU Nov 20 $43 call (an options contract)
- Me great thank you
- Claude paraphrased Is that a yes to place it?
- Me a conditional yes …if the setup is still right
- Claude Re-checked the live quote: XLU had faded to flat, and the spread was 10.1%, right at our limit. New preview: Buy 1 XLU Nov 20 $43 call at $0.50 ($50).
- Placed and filled at 9:58 AM, $0.50.
Results so far
The trading results are small and negative, and that’s fine for what this is.
- 16 closed trades since June, net −$1.35.
- The trial (9/24 to 10/7): 5 trades, 0 wins, −$24.17, plus 4 setups we skipped or missed.
- Zero rule breaks in the trial. Every order was previewed and placed on my explicit yes, no stop was widened, and no guardrail was overridden. That’s a claim about 5 trades, not a track record. The same review listed 4 process misses, and I caught 5 problems myself. (A rule break is an order that went around a rule. A process miss is a slip in how we worked that didn’t break one.)
- 10/8 to 10/30: 5 trades, 2 wins, +$8.20. Zero rule breaks again.
- None of the 10 trades since 9/24 reached its profit target. The median best gain along the way was 0.77R (R = the amount risked on the trade). Targets don’t change until there are 30 closed trades; that’s the sample-size rule.
The 10/7 review was a process review, not a statistical one. In it, Claude graded how we worked together a B−. On 10/8 I gave it a B+. At the 11/2 postmortem I gave it a B.
What I’d change
Gaps I found while writing this up. I had Claude read the guard’s code line by line for this write-up, and then asked it to lock the guard down. That turned up these:
- An out-of-date status file can switch off two checks. The guard tracks today’s losses and this week’s new positions in a small status file that Claude updates after each trade. Those two checks only work when the file’s dates are current. If Claude forgets to update it, the checks quietly don’t run. The guard blocks buys when the file is missing or can’t be read, but not when it’s simply out of date. On 10/16 the file was still dated the day before. And because Claude has to update this file after every trade, it can also change it, so these limits depend on Claude keeping it accurate.
- The $60 options limit is only a written rule. What you pay for an option is called the premium, and you can lose all of it. Our playbook says never pay more than $60 for one. But that rule lives only in Claude’s written instructions, not in the guard’s code. The guard only checks its general $250 limit on any buy, so an options buy between $60 and $250 would get through if Claude and I both missed it.
- Who can raise the $250 limit, or turn the guard off? The limit is a setting the guard reads. Before 10/27, Claude could have edited the guard or its settings if I approved it in the session. On 10/27 I had Claude lock that down: it can no longer edit those files with its normal tools, even with my OK. One gap is left: Claude could still write a small script that changes them. Closing that takes a system-level settings file that only I can change, with my Mac password. Claude drafted it, and at the 11/2 postmortem I decided to leave that gap open on purpose. Nothing so far has given me a reason to think it’s needed, and I think Claude works best in this experiment with some room to operate. Every order still needs my yes, and it’s a small cash account.
- The guard used to fail open. Fixed 10/27. While locking it down, Claude found that if the guard itself crashed or hung, the order went through anyway, because only one specific kind of “no” from the guard actually stopped it. Now it’s set so any failure blocks the order. Claude also found that the guard could be swapped out by a fake copy of the program it runs on, and fixed that too.
What the 11/2 postmortem decided:
- The whole-share rule is permanent: whole shares only, with a stop order held at the broker.
- A limit on chasing: every plan names a highest entry price, and above it we skip, so a buy can’t start with too little reward for the risk.
- Stocks we held off on after one weak day now get logged as skips, with what they would have done, so the ‘too strict?’ question gets answered with data.
- A wash-sale check is now part of the daily scan, so we don’t buy back a stock within 30 days of selling it at a loss. If you do, the tax rules won’t let you count that loss yet.
- Diversification stays by sector; no new rule for positions driven by the same thing.
- Still open: whether scheduled checks or price alerts should be the primary signal.
What I’ve learned so far
What surprised me most was how much of the work turned into writing rules and investment theses together, and how hard it’s been to actually make money.
A few things I’d carry into any product where an agent acts with real consequences:
- Written instructions aren’t enough for the rules that matter most. Claude follows its instructions most of the time, but it can misread them or be talked out of them. Anything that must never happen, like trading the wrong account, needs to be blocked by code that runs outside the AI.
- A human must approve every order. I should catch Claude’s misreadings, but I can make mistakes too, when I’m tired or not paying attention. So the code underneath has to hold either way.
- Strictness has a cost you can measure. Every rule that blocks a bad trade can also block a good one, so log the skips and look at what they would have done.
- The worst failures are the ones I don’t see. If a safety check stops running, nothing tells you. So it’s worth testing the safety checks themselves every so often, not just watching the trades.
Postmortems are monthly. The numbers here run through the 11/2 review.