@metaharness/trading is a one-shot scaffold that drops a complete, opinionated quantitative-trading workspace onto your machine, ready to drive from Claude Code. It is built on top of metaharness — the generic harness generator — and pre-fills the trading-shaped pieces: a research-to-execution agent pipeline, a non-bypassable risk gate, paper-trading defaults, and a stub broker so you can run end-to-end without ever touching real capital.
It is intended for quants prototyping signals, algo-trading hobbyists who want a serious starting point instead of a notebook, and trading-platform integrators who want a sane reference layout. It is not a turnkey live-trading bot. There are no broker credentials, no live market-data subscription, and no production order router included. You bring those when you're ready.
The whole interaction is a single command:
npx @metaharness/trading@latest my-botThat fetches the latest published version, runs the bundled scaffold script, and forwards the request into metaharness@latest with --template vertical:trading --host claude-code --force. The result is a my-bot/ directory containing agents, MCP server stubs, policies, and Claude Code settings — wired together so the moment you open it in Claude Code, everything is addressable.
From there:
cd my-bot
npm install
harness doctorharness doctor is your sanity check. It confirms the paper-trading flag is on, the risk-officer agent exists, the deny-list is blocking live-order tools, and the bundled MCP servers can be reached. Run it before every session — it's the trading-equivalent of a flight checklist.
If you'd rather drive headlessly (CI, research notebooks, scheduled backtests), point Claude Code at the plugin directory directly:
claude -p --plugin-dir my-bot "Backtest momentum on QQQ 2018-2024."- Five-agent pipeline. Researcher (haiku) ingests market data and news. Strategist (sonnet) generates signals and engineers features. Risk-officer (opus) sizes positions, runs VaR/CVaR checks, and enforces drawdown limits. Executor (haiku) constructs orders. Backtester (sonnet) runs walk-forward simulations with cost models.
- Non-bypassable risk gate. Every order path goes through the risk-officer agent. The Claude Code settings file ships a deny-list that blocks
broker.live.*tools entirely until you explicitly remove it, and even then risk-officer must co-sign each order. You cannot prompt your way around it. - Paper-by-default.
PAPER_TRADING=trueis set in.claude/settings.json. The bundled paper broker accepts orders, fills them against a configurable slippage model, and writes a trade journal — but never touches a real market. - Pre-wired MCP servers.
mcp/market-data(OHLCV adapter, CSV-backed by default),mcp/paper-broker(order book + fills), andmcp/risk-policy(live policy lookups). Each is a small mjs file you can swap. - Editable risk policy.
policies/risk.yamllets you set max position size as a percentage of equity, hard drawdown caps, and per-symbol exposure limits.harness validatechecks the file before every session. - Three-tier model routing. Cheap research and execution route to haiku; signal design and backtesting route to sonnet; the risk officer always runs on opus. You get strong reasoning where it counts and don't pay for it where it doesn't.
The scaffold is intentionally hackable. Everything is plain markdown agent specs, plain mjs MCP servers, and a single YAML policy file — no compiled binaries, no hidden config.
To swap in a real broker, replace mcp/paper-broker/index.mjs with an adapter for your broker (Alpaca, IBKR, Tradier — anything with an order API). Keep the same tool names so the executor agent doesn't need to change. Then edit .claude/settings.json to remove the broker.live.* deny rule. The risk-officer gate stays in force; that is by design.
To plug in a real data feed, replace mcp/market-data/index.mjs the same way. The interface (getBars, getQuote, getNews) is documented in the server's README.
To add a strategy, drop a spec into strategies/momentum.md and ask the strategist agent to implement it. The backtester picks it up automatically on the next run. No harness-level changes required.
To run scheduled backtests, wire claude -p --plugin-dir my-bot ... into a cron job or GitHub Action. The harness is stateless between runs except for the trade journal under data/journal/.
Built on metaharness. MIT-licensed.