# I Turned Claude Opus 4.7 Into a 24/7 Trader
<!--
ref: @content/youtube/nate-herk/2026-04-16-claude-opus-24-7-trading-agent
version: 3
updated_at: 2026-10-31T20:04:40.912Z
-->

Nate Herk (2026-04-16): Nate Herk argues that the combination of Opus 4.7 and Claude Code routines is what makes a genuinely 24/7 autonomous agent possible — routines supply the scheduler, and the model supplies the agentic loop that a plain automation lacks.

*Synthesized from Nate Herk on Nate Herk AI Automation, 2026-04-16.*

Nate Herk builds AI automation systems and walks through migrating a live trading agent off an OpenClaw harness onto Claude Code scheduled routines running on Opus 4.7.

## Core Thesis

Nate Herk argues that the combination of Opus 4.7 and Claude Code routines is what makes a genuinely 24/7 autonomous agent possible — routines supply the scheduler, and the model supplies the agentic loop that a plain automation lacks. The hard part is not the trading strategy; it is memory architecture, because every routine fire wakes the agent stateless and it can only be disciplined if files carry the rules, the log, and the lessons forward.

## Key Insights

- The prior 30-day run used an OpenClaw agent on Opus 4.6 with $10,000 through Alpaca and beat the S&P 500 by roughly 8%. The new build ports that same strategy to Claude Code on Opus 4.7 rather than starting fresh.
- Opus 4.7 scored 64.4% on the agentic financial analysis benchmark, about a 4-point jump over 4.6. Nate Herk reads this carefully: it measures digesting filings and writing fundamentals-driven theses, which maps to swing and long-term strategies — not candlestick or MACD day trading. Agentic search actually regressed versus 4.6.
- Every routine invocation wakes stateless. The loop is: read files, do the job, write back what the next wake needs to know. Files are not just memory — Nate Herk frames them as the agent's personality and discipline.
- Context budget is a real constraint. Each routine gets about 200,000 tokens. He deliberately does not think in terms of the million-token window because of context rot; system instructions, strategy files, trade log, API docs, and research all draw against the same budget.
- The tech stack: Claude Code routines as scheduler, Opus 4.7 as model, Alpaca API as brokerage, Perplexity API for research (in place of native web fetch/search), ClickUp for end-of-day notifications, and self-authored skills for research, decisions, trade placement, and logging.
- Local routines require the desktop app to stay open; remote routines run in the cloud with the machine off. Remote runs clone a GitHub repo, work inside an ephemeral copy, then destroy the environment — so the agent must be instructed to commit and push memory-file updates back to main, or the next wake starts blind.
- API keys go in the cloud environment's environment variables, never in a `.env` file inside the repo. His first live test failed because the prompts named the keys slightly differently than the environment did — the variable names must match one-for-one, letter for letter.
- Remote routines also need `allow unrestricted branch pushes` enabled in the routine's permission settings, otherwise Claude can only push to `claude/` branches and cannot update main.
- The five-routine schedule: pre-market at 6:00am (research catalysts, draft trade ideas, only messages on urgency), market open at 8:30am (execute planned trades, set 10% trailing stops), midday at noon (cut -7% losers, tighten stops on winners), 3:00pm close, all weekdays only — plus a Friday 4:00pm weekly review. All Central time.
- Guardrails to define before trading logic: max 5% of portfolio per position, a daily loss cap, a cap on new positions per week, and hard bans like no options. An autonomous agent is eager and will drift without them.
- The migration trick: rather than re-teaching a fresh agent, he asked the existing OpenClaw bot to export its own strategy, sell signals, key learnings, trade log, research log, weekly review, and a technical cheat sheet of Alpaca endpoints — seven files — then dropped that zip into the new project.
- During migration, Claude Code flagged a live Alpaca key sitting in the exported template, prompting a credential rotation before production.
- On subscription limits: the prior 30-day run on four-plus daily wakes never hit his limits while he also did normal work. Running the equivalent agentic loop via raw API would, in his estimate, cost far more than the subscription setup.
- The first Friday weekly review ran end-to-end, committed changes to the repo as Claude, posted the portfolio and S&P comparison into ClickUp — and graded itself a C for the week.

## Actionable Takeaways

1. Write your strategy down first, by hand — how often you check news, what signals trigger a buy or sell, your gut heuristics — before opening Claude Code. The more of that intuition lands in the project, the better the agent behaves.
2. Structure every routine prompt as read-memory-first, act, then write-memory-last. Explicitly instruct it to read files before doing anything and update them at the end.
3. Set the guardrails before the trading logic: position size cap, daily loss cap, weekly new-position cap, and instrument bans.
4. Start in Alpaca's paper account (his had 100k) and only toggle to real money once you're comfortable; a funded account can take a few days to verify.
5. For remote routines, create a cloud environment first, put Alpaca, Perplexity, and ClickUp keys in it as environment variables, and reference those exact variable names verbatim in every routine prompt.
6. Turn on `allow unrestricted branch pushes` in each routine's permissions, and instruct the agent to commit memory-file updates back to main so state persists between wakes.
7. Run `Run now` on every new routine several times before trusting the schedule — this is how he caught the key-name mismatch.
8. Reset context between build phases: ask for a session summary, `/clear`, then paste the summary back in to resume with a fresh window.
9. Read the conversation history of every run early on and tune the prompts, project settings, and skills from what you see — expect to keep iterating rather than shipping once.

## Notable Quotes

> "Every routine basically wakes up, reads files, does the job, and then writes back any important lessons." — Nate Herk

> "Files aren't just memory, but they're essentially the agent's full personality and discipline." — Nate Herk

> "Treat tokens like money, obviously. Every file that you ask the agent to read it's going to cost you." — Nate Herk

> "This benchmark rewards models that can digest filings and write coherent fundamentals-driven theses." — Nate Herk

> "If you don't give it guardrails, it might just kind of start to go off the rails." — Nate Herk

---

*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).*