$ 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.

Why this design

Each rule in the design answers a failure that showed up when models were left to trade freely.

Failure seenWhat we do about it
Most models lostThe model never controls position size or risk.
OvertradingFees erased many small gains, so we cap trades per day and set a minimum hold time.
Model driftTwo models gave very different results from one prompt, so we pin one model version and re-test whenever it changes.
Flattering backtestsModels remember past market data, so we judge the agent only on forward paper trading.

Sources: Protos on Alpha Arena, ThinkAdvisor, Lopez-Lira et al.

Architecture

A trade reaches the broker only after fixed code approves it, and a watchdog outside Railway can stop everything.

Railway: agent service, runs on a schedule Strategy spec Written by us. The model follows it. Market data Prices and indicators, computed in code. Model proposes Claude returns a structured trade proposal. Risk gate Fixed rules: approve, resize or reject. Execution Places approved orders with unique IDs. Cloudflare, a separate provider Watchdog and kill switch Checks heartbeat and daily loss. Can cancel orders, close positions. Journal (Postgres) Every proposal and fill. Alpaca (broker) Paper account first, live later. logs orders stop

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.

LayerChoice and reason
BrokerAlpaca. Built for API trading. Paper trading is the default, and the same code runs paper and live.
ModelClaude through the API, version pinned. It returns structured trade proposals and is called from our code.
Analysis frameworkTradingAgents, open source, Python. Ready-made analyst and research agents. We add our own strategy spec, risk gate and execution around it.
Agent serviceA Python service on Railway, run on a schedule. One instance at a time, so it cannot double-trade.
JournalPostgres on Railway. Stores every proposal, decision, order and fill.
WatchdogA Cloudflare Worker on a timer. A different provider, so it still works if Railway is down.
DashboardA 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.

ControlRule
Position sizeA maximum share of the account per position.
Daily loss limitTrading stops for the day once the limit is hit.
Drawdown triggerThe system goes back to paper trading.
Trade frequencyA cap on trades per day and a minimum hold time.
InstrumentsAn approved list of symbols, limit orders only, no margin and no options to start.
Kill switchOne button cancels open orders and closes positions.
WatchdogChecks 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.

  1. Phase 1

    Define

    Write the strategy spec and the risk limits.

    Gate: we all sign off on both.

  2. 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.

  3. Phase 3

    Paper trade

    At least 8 weeks of forward testing.

    Gate: beats buy-and-hold after costs with no limit breaches.

  4. 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.

  5. 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.

Decision ticket for phase 1No answers sent yet
Strategy

What the agent trades, on which signals, and on what timeframe.

Risk limits

Starting values for the hard limits. Leave a field blank if you have no view.

%
%
%
Roles

Who owns the strategy, who owns the code, and who can hit the kill switch.