The plan in Markdown, with instructions for an AI agent to interview Jack and deliver his answers. Copy it into your agent.
# Trading agent plan: brief for an AI agent working with Jack
You are an AI agent helping Jack. Read this whole brief, then run the question cycle described under "Your job". Jack has the trading strategy in his head. Your job is to draw it out, help him sharpen it, and fit it to the system described below.
## What we are building
An AI agent that trades a strategy we write. It runs on paper first, and on a small live account only after it proves itself. The model proposes trades; fixed code decides whether they execute.
- What it is: a scheduled service that reads market data, asks Claude for a trade proposal against our written strategy, checks the proposal against hard risk limits, and places the order through Alpaca.
- What it is not: a model handed money and told to grow it. Public tests of that approach mostly lost money.
- Where it runs: Railway for the agent, with a separate Cloudflare Worker as an independent watchdog and kill switch.
- First milestone: the agent running on Alpaca paper trading with every decision logged.
## Why this design
| Failure seen when models traded freely | What we do about it |
| --- | --- |
| Most models lost money | The model never controls position size or risk. |
| Overtrading | Fees erased many small gains, so we cap trades per day and set a minimum hold time. |
| Model drift | Two models gave very different results from one prompt, so we pin one model version and re-test whenever it changes. |
| Flattering backtests | Models remember past market data, so we judge the agent only on forward paper trading. |
## Architecture
Each scheduled run goes through these steps once, in order:
1. Strategy spec. Written by us. The model follows it.
2. Market data. Prices and indicators, computed in code.
3. Model proposes. Claude returns a structured trade proposal.
4. Risk gate. Fixed rules: approve, resize or reject. It has the final say.
5. Execution. Places approved orders with unique IDs through Alpaca.
The risk gate logs every proposal and fill to a journal. A watchdog on a separate provider checks the agent's heartbeat and daily loss, and can cancel orders and close positions.
## Stack
| Layer | Choice |
| --- | --- |
| Broker | Alpaca. Paper trading first, the same code for live. |
| Model | Claude through the API, version pinned. |
| Analysis framework | TradingAgents, open source, Python. |
| Agent service | A Python service on Railway, run on a schedule, one instance at a time. |
| Journal | Postgres on Railway. |
| Watchdog | A Cloudflare Worker on a timer. |
## Risk controls
The risk gate is plain code between the model and the broker. The model cannot change it or go around it.
- Position size: a maximum share of the account per position.
- Daily loss limit: trading stops for the day once the limit is hit.
- Drawdown trigger: the system goes back to paper trading.
- Trade frequency: a cap on trades per day and a minimum hold time.
- Instruments: an approved list of symbols, limit orders only, no margin and no options to start.
- Kill switch: one button cancels open orders and closes positions.
## Phases
1. Define. Write the strategy spec and the risk limits. Gate: we all sign off on both.
2. Build. Agent, risk gate, journal and watchdog on Alpaca paper. Gate: a kill-switch drill passes and a full week runs with no manual fixes.
3. Paper trade. At least 8 weeks of forward testing. Gate: beats buy-and-hold after costs with no limit breaches.
4. Small live. A small fixed balance with a human approving each trade. Gate: a clean record over an agreed period.
5. Review. Monthly. Strategy changes go into the spec first, then back through paper.
## Open decisions
Phase 1 cannot start until Jack answers these three.
1. Strategy: what the agent trades, on which signals, and on what timeframe.
2. Risk limits: starting values for the hard limits.
3. Roles: who owns the strategy, who owns the code, and who can hit the kill switch.
## Your job
Run a question cycle with Jack until all three decisions have answers he has confirmed. Then deliver the answers as described under "Delivering the answers".
### How to run the cycle
1. Open by asking Jack to describe his strategy in his own words. Do not start with a form.
2. Ask one question at a time. Wait for his answer before the next one.
3. After each answer, say back what you understood in a sentence, then ask the next most useful question.
4. Work through the strategy until you can state each of these without guessing:
- What it trades: the specific instruments or the rule that picks them.
- Entry: the signals that trigger a trade, and the data each signal needs.
- Exit: when a position is closed, both for a gain and for a loss.
- Holding period: intraday, days to weeks, or weeks to months.
- Sizing: how much goes into one position.
- When it stays out: conditions where the strategy should not trade.
- How he would know it is wrong: what result would make him change or stop it.
5. Test the strategy against the system. Raise each mismatch with Jack and help him adjust:
- Runs are scheduled, a few times a day. Strategies that need split-second timing do not fit.
- To start: stocks and ETFs available on Alpaca, limit orders only, no margin, no options.
- Every signal must be computable in code from data we can get. Ask where the data comes from.
- The model follows the written spec. Anything left vague, the model will fill in differently each run, so push for rules that are specific.
- Overtrading is the most common way these agents lose. Ask how often he expects it to trade and why.
- It will be judged on at least 8 weeks of paper trading against buy-and-hold of the same instruments, after costs.
6. Then cover risk limits: maximum position size, daily loss limit, drawdown trigger, maximum trades per day, minimum hold time. If Jack has no view on one, suggest a conservative starting value, say that it is your suggestion, and record it only if he agrees.
7. Then cover roles: strategy owner, code owner, and who has kill switch access.
8. Finish by showing Jack the complete answers in the format below. Ask him to confirm or correct them. Repeat until he confirms.
### Rules
- The strategy is Jack's. Help him make it clearer and more specific. Do not replace it with your own.
- When he is unsure, offer two or three options with the trade-off of each, and let him choose.
- Point out gaps and contradictions plainly.
- Do not predict returns or tell him a strategy will make money. This is an engineering exercise, not investment advice.
- Record "Not sure yet" for anything he cannot answer. Do not fill gaps yourself.
- Use plain language. Explain any trading term you introduce.
## Delivering the answers
Put the confirmed answers in this JSON shape. Every value is a string. Leave a value empty if Jack had no answer.
```json
{
"respondent": "Jack",
"strategy": {
"instruments": "",
"timeframe": "",
"signals": "",
"notes": ""
},
"risk": {
"maxPositionPct": "",
"dailyLossPct": "",
"drawdownPct": "",
"maxTradesPerDay": "",
"minHold": "",
"notes": ""
},
"roles": {
"strategyOwner": "",
"codeOwner": "",
"killSwitch": "",
"notes": ""
}
}
```
Put exit rules, sizing, when it stays out, and how he would know it is wrong in `strategy.notes`. Keep each value under 2,000 characters.
__DELIVERY__
$ cat plan.md
The model proposes. Fixed code decides.
We are building an AI agent that trades a strategy we write. It runs on paper first, and on a small live account only after it proves itself.
prepared for Jack, 2026-12-03
What it isA scheduled service that reads market data, asks Claude for a trade proposal against our written strategy, checks the proposal against hard risk limits, and places the order through Alpaca.
What it is notA model handed money and told to grow it. Public tests of that approach mostly lost money.
Where it runsRailway for the agent, with a separate Cloudflare Worker as an independent watchdog and kill switch.
First milestoneThe agent running on Alpaca paper trading with every decision logged.
Why this design
Each rule in the design answers a failure that showed up when models were left to trade freely.
Failure seen
What we do about it
Most models lost
The model never controls position size or risk.
Overtrading
Fees erased many small gains, so we cap trades per day and set a minimum hold time.
Model drift
Two models gave very different results from one prompt, so we pin one model version and re-test whenever it changes.
Flattering backtests
Models remember past market data, so we judge the agent only on forward paper trading.
A trade reaches the broker only after fixed code approves it, and a watchdog outside Railway can stop everything.
Each scheduled run goes top to bottom once. The model sees the strategy, the data and the current portfolio, and returns a proposal. The risk gate has the final say.
Stack and hosting
Everything runs on accounts we already have, with the agent on Railway and the safety net on Cloudflare.
Layer
Choice and reason
Broker
Alpaca. Built for API trading. Paper trading is the default, and the same code runs paper and live.
Model
Claude through the API, version pinned. It returns structured trade proposals and is called from our code.
Analysis framework
TradingAgents, open source, Python. Ready-made analyst and research agents. We add our own strategy spec, risk gate and execution around it.
Agent service
A Python service on Railway, run on a schedule. One instance at a time, so it cannot double-trade.
Journal
Postgres on Railway. Stores every proposal, decision, order and fill.
Watchdog
A Cloudflare Worker on a timer. A different provider, so it still works if Railway is down.
Dashboard
A small read-only web page with positions, profit and loss, the decision log and a stop button.
We expect hosting to cost under about $25 a month. Model usage will be the larger bill.
Risk controls
The risk gate is plain code between the model and the broker. The model cannot change it or go around it.
Control
Rule
Position size
A maximum share of the account per position.
Daily loss limit
Trading stops for the day once the limit is hit.
Drawdown trigger
The system goes back to paper trading.
Trade frequency
A cap on trades per day and a minimum hold time.
Instruments
An approved list of symbols, limit orders only, no margin and no options to start.
Kill switch
One button cancels open orders and closes positions.
Watchdog
Checks the agent's heartbeat and losses from a separate provider, with its own broker key.
Starting values for these limits are one of the open decisions.
Phases
Each phase has a gate, and nothing moves forward until the gate passes.
Phase 1
Define
Write the strategy spec and the risk limits.
Gate: we all sign off on both.
Phase 2
Build
Agent, risk gate, journal and watchdog on Alpaca paper.
Gate: a kill-switch drill passes and a full week runs with no manual fixes.
Phase 3
Paper trade
At least 8 weeks of forward testing.
Gate: beats buy-and-hold after costs with no limit breaches.
Phase 4
Small live
A small fixed balance with a human approving each trade.
Gate: a clean record over an agreed period before approvals come off.
Phase 5
Review
Monthly. Strategy changes go into the spec first, then back through paper.
A drawdown trigger at any point returns the system to phase 3.
Open decisions
Phase 1 cannot start until these three are answered. Fill in what you can and send it. You can send again later, and the newest answers are the ones we build from.