PROJECT / hook-gated paper-trading agent
Trader Agent
A Claude Code skill for a hook-gated paper-trading agent.
- Claude Code
- Python
- Hooks
Source private: private repository (touches a brokerage account)
- Type
- AI
- Source
- Private
- Role
- Sole builder, using an AI-assisted flow: brainstorm, spec, plan, then a subagent-driven build of 16 tasks with per-task and final reviews.
- Built with
- Claude Code, Python, Hooks
01 / Overview
Overview
Scan
Daily price data is scanned for pullback and breakout candidates.
Filter
A small ML filter and a Claude news check can each say no.
Gate
Code issues a single-use, expiring risk ticket; a hook allows orders only with one.
Paper fill
A paper broker simulates the fills and a journal records them.
Review
A report rates the strategy KEEP, WATCH or KILL; KILL halts new buys.
02 / Context and problem
Context and problem
An on-demand Claude Code agent (a /trader skill) for swing-trading liquid US stocks and ETFs through a broker's agentic tool server. A Python package does the deterministic work and a hook is the hard gate. It runs in paper mode; per the project log of 2026-10-12 the broker connection was not set up and it had made 0 trades.
03 / My role
My role
Sole builder, using an AI-assisted flow: brainstorm, spec, plan, then a subagent-driven build of 16 tasks with per-task and final reviews.
04 / How it works
How it works
Fetch bars
Daily bars come from a cached price feed.
Scan
Pullback and breakout signals are found and features computed.
ML filter
A small model filters candidates, and is live only if it beats rules-only and the index out of sample in a promotion test.
News check
A Claude gatekeeper reads a news verdict; its veto applies.
Risk ticket
A code risk gate sizes the trade, bounds the stop and issues a single-use expiring ticket.
Guard hook
The hook denies tools by default; an order needs a ticket.
Paper broker and journal
Fills are simulated a day later and written to a SQLite journal; the report gives KEEP, WATCH or KILL.
Python package
Scanning, features, the ML filter, risk sizing, the paper broker and the journal: all deterministic code.
Claude agent
The /trader skill reads news and can veto; the risk gate is code, not the model.
PreToolUse hook
The hard gate: default-deny tool allowlist, orders need a ticket, and it fails closed.
05 / Key decisions
Key decisions
Rules, a small ML filter and a Claude gatekeeper
The project log records this choice over a pure-LLM or reinforcement-learning agent.
Accept the failed v1 promotion test
The log records the failure was accepted, with no threshold tuning.
A default-deny hook as the hard gate
The hook denies tools by default, orders need a risk ticket, and it fails closed.
A ring-fenced money lock
A separate account funded by hand only, a default-deny tool allowlist, deny tokens, and crypto and options blocked.
An autonomy ladder
Four rungs: paper, live_approve, live_auto, live_full. Only I can promote, in a real terminal with a typed phrase, and live buys need a clean guard check within 6 hours.
06 / Results and numbers
Results and numbers
337 tests
collected by pytest during the October 2026 fact check
07 / Testing and quality
Testing and quality
- pytest runs on Windows in GitHub Actions, with a frozen-backtest regression test.
- Fresh-context reviews found real holes: cancel-and-replace skipping tickets, NaN values skipping limits, the shell reaching the state file, and a Windows device name faking an interactive terminal.
- The test count has changed over time (227, 257, 270 at earlier dates), so only the collection count above is quoted.
08 / Limitations
Limitations
- Honest status: v1 failed its promotion test (8 selected trades, 30 required). Later versions passed on historical data only, with a thin edge and a survivorship-bias caveat. There is no live evidence.
- Paper mode only; per the project log of 2026-10-12 the broker connection was not set up.
- No live results exist for the news-adjusted trades.
09 / What I learned
What I learned
- Filters used in training must also apply in the scan.
- Safety guards also block harmless text.
- Fresh-context review finds holes on the money path that the builder misses.
- When a safety rule takes a number, check its units.
10 / What's next
What's next
- Review weekly and collect at least 15 closed paper trades.
- Check the news-adjusted trades.
- Fix the deferred minor issues before any live automation.
11 / Next project