# I Turned Claude Opus 4.7 Into a 24/7 Trader
<!--
ref: @content/youtube/nate-herk/2026-04-16-i-turned-claude-opus-4-7-into-a-24-7-trader
tags: [claude-code-routines, ai-trading-agents, agent-memory, opus-4-7, alpaca-api, guardrails, scheduled-agents, context-budget]
version: 2
updated_at: 2026-11-21T21:30:01.117Z
-->

**[Watch on YouTube](https://www.youtube.com/watch?v=6MC1XqZSltw)**


*Synthesized from Nate, 2026-04-16.*

Nate presents this solo tutorial on building a scheduled trading agent in Claude Code, migrating an earlier agent's strategy and memory into a project, and running it on Claude Code routines.

## Core Thesis
Nate argues that a scheduled Claude Code agent, which he calls "Bull", can run a paper or live trading strategy around the clock if its memory lives in files rather than in the model's context. Each routine wakes up with no memory, reads the project files, does its job, and writes lessons back so the next run inherits them. He says the files are what give the agent its discipline, and that the model's judgment on each run is the reason to prefer Claude Code over a plain automation.

## Key Insights
- **Mental model:** "Claude Code basically wakes up essentially stateless." Every routine reads the strategy, trade log, research log and weekly review, acts, then writes updates back to them.
- **Budget:** each routine has about 200,000 tokens. Nate treats every file the agent reads as a cost, because of context rot.
- **Stack:** Claude Code routines as the scheduler, Opus 4.7 as the model, Alpaca's trading API as the broker, the Perplexity API for research (instead of built-in web search), and ClickUp for notifications.
- **Migration:** he exported seven files from the old agent (instructions, strategy, trade log, research log, weekly review and so on), dropped them into a project, and used plan mode to have Claude reorganise them and update the project's CLAUDE.md, which came to about 156 lines.
- **Schedule:** five triggers on weekdays only, with the weekly review on Friday. Runs fire at 6:00, 8:30, noon and 3:00 p.m., plus a Friday 4:00 p.m. review (Central time in the video).
- **Roles:** pre-market finds catalysts and drafts trade ideas and messages only if urgent. Market open executes planned trades and sets 10% trailing stops. Midday cuts losers at -7% and tightens stops on winners. The weekly review grades the week; in the test run the agent gave itself a C.
- **Remote versus local:** local routines stop firing when the desktop app is closed. Remote routines clone a GitHub repo into a cloud environment, work, and destroy the copy, so every change must be committed and pushed or the next run will not see it.
- **Permissions:** each remote routine needs the "allow unrestricted branch pushes" setting, otherwise pushes are limited to claude-prefixed branches.
- **Secrets:** keys go in the cloud environment's variables, never in a .env file in the repo. The prompts must name each variable exactly; a mismatch in one word (an API key versus an "API secret" name) made the agent think the key was missing.
- **Guardrails he suggests:** paper mode first, a maximum of 5% of the portfolio per position, a daily loss cap, a limit of three new positions a week, and no options.
- **Results so far:** a prior 30-day challenge started at $10,000 and finished about 8% ahead of the S&P 500. A test run reported a balance of $9,859 from the Alpaca account.
- **Security:** the template from the old agent contained a live Alpaca key, which he rotated before going live.
- **Cost:** he says running this on a subscription is far cheaper than the equivalent API usage, but that auto mode costs more.

## Actionable Takeaways
1. Write the trading strategy and signals down in plain language before any code, then have the agent turn them into files.
2. Keep a strategy file, a trade log, a research log and a weekly review, and make every routine read them first and write to them last.
3. Put the Alpaca, Perplexity and ClickUp keys in the cloud environment, and check that each prompt names them exactly as they are set.
4. Enable "allow unrestricted branch pushes" on every remote routine, and commit and push after each run.
5. Run each new routine manually several times before trusting its schedule.
6. Set hard limits in the strategy file: 5% per position, a daily loss cap, three new positions a week, no options.

## Notable Quotes
> "4.7 plus routines means you can have a 24/7 AI agent" — Nate
> "files aren't just memory, but they're essentially the agent's full personality and discipline" — Nate
> "they have to be matching one-for-one, otherwise it will think that they're not there" — Nate

---

*Related: `@protocol/groom-protocols` · `@content/youtube/cole-medin/let-your-ai-agent-do-its-own-harness-engineering-heres-how` · `@content/youtube/aie/guardrails-first-engineering-member-facing-health-ai-rashi-agrawal-hinge-health` · `@content/web/lorekit/2026-11-07-agent-memory-opentelemetry-moment` · `@content/youtube/david-ondrej/my-agentic-engineering-workflow-after-6-775-sessions`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*