← Back to list

I Turned Claude Opus 4.7 Into a 24/7 Trader

What happened when I gave an AI agent a brokerage account, a schedule, and one job: beat the S&P 500.

Andrew Collins in Digital Currency Traders · 2026-06-20 10:35 · 0 claps · 7.8 min read paywalled
#ai-trading #claude #claude-code #trading #ai
Open on Medium ↗
Wiki topics: LLM · Large Language Models RAG · RAG & Retrieval AGT · AI Agents AI · AI · General INV · Investing & Markets

100% Human-Written Content

I Turned Claude Opus 4.7 Into a 24/7 Trader

What happened when I gave an AI agent a brokerage account, a schedule, and one job: beat the S&P 500.

For 30 days, I let an AI agent trade against the S&P 500.

I did not pick the stocks. I did not place the trades. I gave it a goal, a set of rules, and a schedule, then stepped back and watched.

It beat the market by around 8%.

That was enough to make me curious, so I rebuilt the whole thing properly. This is how it works.

First, what this is not. I was not trying to build a hedge fund from my bedroom. I was not day trading meme stocks, scalping candles, or pretending a language model can predict the future. The question I cared about was quieter and more practical:

Could an AI agent research the market, follow a disciplined strategy, make reasonable decisions, remember what it had done, and improve over time?

The first version ran on an earlier setup with Claude Opus 4.6. It worked better than I expected. When Claude Opus 4.7 arrived, I decided to rebuild everything around Claude Code routines and find out how far the idea could go.

The result is not a chatbot and not a spreadsheet helper. It is a scheduled agent that wakes up through the day, checks the market, researches companies, manages positions, logs its decisions, and sends me a summary.

The goal: beat the market without acting like a gambler

Before writing a line of code, I had to decide what I actually wanted the agent to do.

The answer was not “trade as much as possible.” That was the exact opposite of the point. I wanted it to behave like a disciplined long-term investor, not a hyperactive one. Its job was to:

  • Research the market before the open
  • Check current holdings
  • Look for news, earnings, catalysts, risk signals, and shifts in sentiment
  • Place trades through Alpaca only when the strategy allowed it
  • Avoid reckless position sizing
  • Keep a full trade journal
  • Update its memory after every run
  • Send me a clear daily summary

The benchmark was the S&P 500, and that mattered. It kept the experiment honest. I did not want an agent chasing random trades just to look busy. I wanted it making decisions only when it had a real reason to.

This is also why I left out crypto, options, and aggressive day trading. I am not saying those cannot be automated. I just did not want the experiment to turn into a casino with an AI interface. The question stayed clean: can Claude Opus 4.7 run a disciplined research and trading routine better than a passive benchmark?

The stack, and why the tools barely matter

The setup was simpler than people expect:

  • Claude Code routines as the scheduler
  • Claude Opus 4.7 for the reasoning
  • Alpaca for the brokerage
  • Perplexity for market research
  • ClickUp for notifications
  • GitHub for storing the project files

Here is the thing, though. The tools are interchangeable. Swap ClickUp for Slack, Telegram, or email. Use a different research API or broker if you prefer. None of that is the secret.

The structure is the secret. The agent needed somewhere to live, a way to wake up, a way to act, and a way to remember. That last part turned out to be the whole game.

The biggest lesson: agents need memory

Every time a scheduled routine runs, the agent wakes up fresh.

It does not remember yesterday’s logic. It does not carry forward what it concluded last session. Without structure, it behaves like a brilliant analyst with no short-term memory, which is a dangerous thing to put near a brokerage account.

So I treated files as memory.

At the start of every run, the agent had to read the files that mattered: the strategy, current portfolio notes, the trade log, the research log, the risk rules, the weekly review, and its own instructions. At the end of every run, it had to write back anything worth keeping:

  • If it bought something, it logged why.
  • If it sold something, it logged why.
  • If it made a mistake, it recorded the lesson.
  • If it changed its view on a stock, it updated the research notes.
  • If it spotted a risk in the portfolio, it flagged it for the next run.

That single habit is what turned a random automation into something that felt like an actual assistant. The files became the agent’s memory, its discipline, and honestly its personality.

Splitting the day into four routines

I did not want one giant routine trying to do everything at once. Markets move through the day, so I split the work into separate scheduled runs.

Pre-market is for research. The agent checks market conditions, overnight news, earnings, analyst updates, macro signals, and company-specific catalysts. It does not trade. Its only job is to prepare.

Market open is when it can act. It reviews the prepared ideas, checks prices and holdings, and places trades only if the strategy supports them.

Midday is a risk check. It reviews open positions, watches for sharp moves, looks at the losers, tightens stop logic where needed, and confirms nothing strange is happening.

Market close is for final decisions, daily notes, and the end-of-day report.

Then, every Friday, a weekly review. This became my favourite part. The agent grades its own week, compares the portfolio against the S&P 500, and asks what worked, what failed, and what should change.

That review is the feedback loop. Without it, the agent only acts. With it, the agent can learn.

Guardrails came before trading logic

Most people give AI agents too much freedom too early. That is risky in an ordinary workflow. It is far riskier when money is involved.

So the guardrails went in before anything traded. The agent had hard rules around position sizing, risk limits, trade frequency, and strategy boundaries. I did not want it dropping half the account into one stock because it liked a headline. I did not want daily impulse trades. No options. No overtrading. I wanted slow, explainable, research-backed decisions.

And it all started on paper.

That part is not optional. This is not financial advice, and I would not hand an autonomous agent real money until you have tested it hard, understood the risks, and know exactly what it is doing. Paper trading shows you how the agent behaves when markets move fast, when the data is confusing, and when its earlier assumptions turn out to be wrong. Those moments are where you find out whether your system is genuinely disciplined or just lucky.

Why a schedule changed everything

The exciting part was never that Claude could analyse a company. Models have written decent market summaries for a while.

The shift was that routines let Claude act on a schedule.

Instead of me opening a chat and asking “what should I look at today?”, the agent wakes up on its own. At 6am it researches. At the open it checks the portfolio. At noon it reviews risk. At close it summarises the day. On Friday it grades its week. The agent stops being a tool I reach for and becomes part of the operating system of my day.

One detail mattered more than I expected: where the routine runs. A local routine runs on your machine, which is fine for testing, but if the laptop is closed the routine may never fire. I wanted a remote routine running in the cloud.

Remote routines need a GitHub repo, because the cloud environment has to clone the project, run the task, and push the updates back. This is where memory becomes critical again. If the agent updates the trade log during a cloud run but does not push the file back, the next run never sees it. So I made sure every routine could update the project files and commit them to the main repo. That is what keeps each run connected to the one before it.

The unglamorous part: keys, environments, and a broken first run

Two things went wrong, and both are worth sharing because they are easy to repeat.

The first was security. While migrating, I found old files with live API keys sitting inside them. That happens fast when you are copying context from one setup into another. I rotated the keys and moved everything into environment variables. The agent now pulls its Alpaca, Perplexity, and ClickUp credentials from the environment, never from local files, and definitely never from anything committed to GitHub. Boring step, but if you are building anything connected to trading, do not paste keys into files that might end up in a repo.

The second showed up on the first real test. I did not just trust the routines, I ran them manually, and the agent immediately failed to reach Alpaca. The cause was almost funny: the environment variable names did not match exactly. One small naming mismatch broke the whole run.

I fixed it, ran it again, and this time it worked. The agent connected to Alpaca, checked the balance, read its memory files, completed a weekly review, sent the summary to ClickUp, and committed the updated files back to GitHub.

That was the moment it stopped being an idea and became a working trading routine.

What the agent does now

The agent now has a full daily rhythm. It wakes before the market, reads its memory, researches, checks the portfolio, decides whether anything needs doing, places trades only when the rules allow, logs its reasoning, updates its files, and sends me a summary. Then the next routine picks up where the last one left off.

That is the core loop:

Read. Think. Act. Record. Improve.

It is not perfect. I still review the runs, read the logs, and adjust the strategy. Nobody should treat this as a set-and-forget money machine. It is better understood as an autonomous research and execution assistant kept on a short leash.

This was never really about trading

This started as a trading experiment, but the bigger lesson has little to do with the stock market.

When you combine a strong reasoning model with scheduled routines, external tools, APIs, memory files, and a feedback loop, you get something well past a chatbot. You get a worker. A rough one that still needs guardrails, monitoring, and correction, but a worker all the same.

For trading, that means the agent watches the market while I do something else. For a business, the same structure could monitor competitors, update dashboards, prepare reports, triage an inbox, track projects, or write weekly summaries. The pattern does not change:

  • Give the agent a clear role.
  • Give it rules.
  • Give it tools.
  • Give it memory.
  • Give it a schedule.
  • Then inspect what it does and keep improving the system.

What I am actually taking away

Claude Opus 4.7 does not magically turn anyone into a profitable trader. That would be the wrong lesson to walk away with.

The real lesson is that AI agents are now practical enough to run structured, recurring work with real tools and real consequences. That is exciting, and it is risky, and the difference between the two comes down to discipline. Vague goals, weak memory, loose rules, and too much freedom, and an agent can make a mess in a hurry. Clear files, strict guardrails, scheduled responsibilities, and a feedback loop, and it starts to become genuinely useful.

For me, turning Claude Opus 4.7 into a 24/7 trader was never about replacing human judgement. It was about building a system that could support it. The agent does not need to be brilliant. It needs to be consistent, careful, and honest about why it made each call.

For now, the setup is live. The routines are running. The memory files are updating. The trade journal is growing. And every day, Claude wakes up, checks the market, and tries to beat the S&P 500.

Let us see how long it can keep up.


메타데이터
post_id
06abd8f6e396
slug
i-turned-claude-opus-4-7-into-a-24-7-trader-06abd8f6e396
url
https://digitalcurrencytraders.com/i-turned-claude-opus-4-7-into-a-24-7-trader-06abd8f6e396
canonical_url
https://digitalcurrencytraders.com/i-turned-claude-opus-4-7-into-a-24-7-trader-06abd8f6e396
author_url
https://medium.com/@kaywritesforyou
status
ok
fetched_at
2026-06-21 19:25:17