Skip to content
Get App

I Turned Claude Into a 24/7 Trader

Nate Herk shows how to build a 24/7 AI trading agent with Claude Opus 4.7 inside Claude Code, using Routines for scheduling, the Alpaca API for trades, and Perplexity for research.

Key Takeaways

  • Opus 4.7 combined with Claude Code Routines makes a practical 24/7 scheduled AI trading agent feasible.
  • Persistent memory files let each scheduled run learn from prior runs.
  • Paper trading and close monitoring of agent runs are recommended before risking real capital.

What the video covers

  • Opus 4.6 benchmarks show a ~4% jump on the Finance Agent analysis, motivating the upgrade to Opus 4.7.
  • The creator's previous 30-day paper trading challenge with Opus 4.6 and $10,000 beat the S&P 500 by about 8%.
  • The goal is a long-term investment strategy aimed at beating the S&P 500, not crypto or day trading.
  • The core unlock is Claude Opus 4.7 combined with Claude Code Routines, which enables always-on scheduled agents.
  • The tech stack includes Claude Code Routines as scheduler, Opus 4.7 as the model, custom skills, Alpaca API as brokerage, Perplexity API for research, and ClickUp for notifications.
  • Setup requires obtaining Alpaca API key and secret (paper trading account with $100K available), ClickUp API token, and Perplexity API key.
  • The agent runs on a schedule: pre-market (6:00 a.m.), market open (8:30 a.m.), midday (noon), and close (3:00 p.m.), with a weekly review on Fridays.
  • Each routine reads memory files, performs its task, and writes lessons back so future runs retain context.
  • Strategy extraction from prior experiments is used to define the agent's trading approach, with paper trading recommended first.
  • The creator stresses monitoring every run and reviewing conversation history to tune prompts over time.

Answers

Questions about this video

What model does the video use for the trading agent?

The video uses Claude Opus 4.7 inside Claude Code. The creator notes that 4.7 was built for agentic work, judgment over ambiguity, and self-verifying outputs, which makes it well suited to scheduled routines.

How does the agent run 24/7?

It uses Claude Code Routines, a scheduling feature from Anthropic. Routines wake the agent at set times such as 6:00 a.m., 8:30 a.m., noon, and 3:00 p.m., and each run reads memory files, does its job, and writes lessons back.

Which brokerage and research tools are used?

The agent trades through the Alpaca API, starting with a paper trading account. Research is done via the Perplexity API, and notifications are sent to ClickUp, though other tools like Slack or Telegram can be substituted.

Full Transcript — Download SRT & Markdown

00:00
Speaker A
So, Claude Opus 4.6 is finally here, and it got me thinking. As I was scrolling down and started looking at the benchmarks, I noticed right here we have a Finance Agent analysis, and we have about a 4% jump from Opus 4.6.
00:12
Speaker A
And about a week ago, I dropped this video where me and Simon traded stocks for 30 days with our open Claude agents, and my open Claude agent was set up with Opus 4.6, and I was able to beat the S&P
00:22
Speaker A
About a week ago, I dropped this video where me and Simon traded stocks for 30 days with our Open Claude agents. My Open Claude agent was set up with Opus 4.6, and I was able to beat the S&P by about 8%, as you can see right here. This green line is my chart, and this gray line is the S&P. If you guys want to check out this full video, I will link it right up here.
00:31
Speaker A
this challenge, I wanted to keep my agent running to see if it could keep beating the S&P, but now I want to upgrade it to 4.7 instead of 4.6. So, that's exactly what I want to cover with you guys today. How do we build a 24/7
00:42
Speaker A
After this challenge, I wanted to keep my agent running to see if it could keep beating the S&P, but now I want to upgrade it to 4.7 instead of 4.6. That's exactly what I want to cover with you guys today: How do we build a 24/7 AI trading agent with Opus 4.7 inside of Claude Code? We're not even going to touch Open Claude or Hermes Agent. We're going to do this entirely with Claude Code.
00:49
Speaker A
And this is all going to be thanks to another feature that we just got from the Anthropic team called routines. If you don't know what that is, I'm going to break it down in this video, but I also made a full one if you want to
00:57
Speaker A
This is all going to be thanks to another feature we just got from the Anthropic team called Routines. If you don't know what that is, I'm going to break it down in this video, but I also made a full one if you want to check that out, also right up here. So, basically, this is the unlock. 4.7 plus Routines means you can have a 24/7 AI agent. 4.7 was built for full-throttle agentic work, judgment over ambiguity, and self-verifying outputs. So it's perfect for these types of routines, and that's how I'm going to set up my 24/7 trading agent with Claude Code Routines.
01:10
Speaker A
So, it's perfect for these types of routines, and that's how I'm going to set up my 24/7 trading agent with Claude code routines. So, if you follow along with this video, you'll be able to pretty much duplicate my exact setup and
01:21
Speaker A
If you follow along with this video, you'll be able to pretty much duplicate my exact setup and have yourself a working agent and start trading with it. So, let's go ahead and get started. What are we building?
01:32
Speaker A
midday, and a close. It's going to research the market. It's going to place trades via the Alpaca API. It's going to journal and make sure that it's writing context into the file so it can learn.
01:42
Speaker A
We're going to create a Claude Code project that runs on a schedule, something like a pre-market cron, a market open, a midday, and a close. It's going to research the market. It's going to place trades via the Alpaca API. It's going to journal and make sure that it's writing context into the file so it can learn. And then it's going to send me every day, every day of the week, an end-of-day summary to my ClickUp.
01:52
Speaker A
just kind of doing this as a fun long-term investment. Just beat the S&P challenge. Like I said, in my first 30 days I gave Opus $10,000 and we were able to beat the S&P by about 8%, which is really good, especially in such a
02:04
Speaker A
The goal, obviously, is just to beat the S&P. We're not looking to do any crazy crypto or crazy day trading stuff. I'm just doing this as a fun long-term investment. Just beat the S&P challenge. Like I said, in my first 30 days I gave Opus $10,000 and we were able to beat the S&P by about 8%, which is really good, especially in such a short amount of time.
02:15
Speaker A
building our own as we go. It'll be stuff like how the agent does research or how it makes decisions or how it places trades or, you know, makes logs, things like that. We're going to use the Alpaca API as our brokerage. We're going
02:25
Speaker A
So, what is the tech stack? We're going to be using Claude Code Routines, which is our scheduler. For the AI model, we're going to use Opus 4.7. For the skills, we're going to build our own as we go. It'll be things like how the agent does research, how it makes decisions, how it places trades, or how it makes logs. We're going to use the Alpaca API as our brokerage. We're going to use the Perplexity API for research. You could also just use the native web fetch and web search, but I'm going to use Perplexity here. And then I'm going to get my notifications in ClickUp this time rather than Telegram, just because I live in ClickUp a lot more.
02:36
Speaker A
live in ClickUp a lot more. So, obviously some of these things can be interchangeable for you, but if you want to just copy my exact setup in this video, then feel free. Okay, so how to get started with these different tools
02:45
Speaker A
Obviously some of these things can be interchangeable for you, but if you want to copy my exact setup from this video, feel free.
02:50
Speaker A
You can see up at the top we even see want to trade using AI. We launched an Alpaca's MCP server to help you trade with natural language. So, you could use that. I'm just using the endpoints. I honestly like to use endpoints a lot
02:59
Speaker A
Okay, so how do you get started with the different tools we need for this video? The first one is Alpaca. Go to alpaca.markets. You can see up at the top, we even say "Want to trade using AI?" We launched an Alpaca MCP server to help you trade with natural language, so you could use that. I'm just using the endpoints. I honestly like to use endpoints a lot more. But anyway, you're going to sign up right here and click on Trading API. Once you get in there, you'll basically have a paper trading account, and right here you can see I've got a paper trading account with $100K. You could also open a new account right here, and that's how you could put real money in. You might have to verify your account, which could take a couple of days.
03:09
Speaker A
You could also open up a new account right here and that's how you could put real money in. You might, like I said though, have to just verify your account, which could take a couple days.
03:17
Speaker A
Both account types have the same credentials. Scroll down, and on the right-hand side you'll find your API keys. You get an endpoint and a key, but you also need a secret key. So you'll have a secret key and an ID. Hit regenerate, generate new keys, and this is where you get your key and your secret. Once you copy and paste them, make sure to save them, because the secret will disappear and you'll only be able to see the key again. You need both.
03:26
Speaker A
like a secret key and then you need like an ID. So, you'd hit regenerate, generate new keys, and this is where you get your key and your secret. And once you copy and paste this, just make sure to save it because then it's going
03:37
Speaker A
Next up is ClickUp. This is where I want to get my notifications. You don't have to use ClickUp; you can use Slack, Telegram, WhatsApp, or whatever you like. I'd go to my settings, scroll down to find the ClickUp API section, and copy the token right there.
03:40
Speaker A
Next up I have ClickUp. This is where I want to get my notifications. You don't have to use ClickUp, you can use Slack, you could use, you know, whatever, Telegram, WhatsApp. I would go up here and go to my settings, and then I scroll
03:51
Speaker A
Similarly with Perplexity, I'd go down and click on settings, I think. In there, I can see API Platform, and this is where I'd find my actual API key. Under API Keys, I can make a new one or copy an old one. Basically, every platform typically has API keys; you just have to find them in the settings somewhere. If you can't find them, do a quick Perplexity or Google search, or even ask Claude Code, and it should be able to help you get to your API keys. Now that you know how to get these keys, hold on to them. We'll plug them in later in the video.
03:54
Speaker A
And then similarly with perplexity, I would go down here and I would click on all settings, I think. And then in here I can see API platform and this is where I would be able to go find my actual API
04:05
Speaker A
The final piece of the puzzle is the Claude desktop app. You can have Claude chat, Claude Cowork, or be in Claude Code. This is where we'll set up these routines. If I go to my calendar, you can see that every day I have Bull, my trading agent, waking up at 6:00, 8:30, noon, and 3:00 p.m. On certain days, like Fridays, he does a weekly review. That's how I currently have mine set up, and we can manage everything right from the Claude desktop app because of the routines feature.
04:13
Speaker A
settings somewhere. If you can't find them, just do a quick perplexity or Google search or even ask Cloud Code and it should be able to help you get to your API keys. And now that you know how to get these keys, just hold on to them.
04:22
Speaker A
To use the Claude desktop app, just search for "Claude desktop app download" and install it. Go to the downloads page and choose the version for your operating system. The only other thing you need is an actual subscription: either the $20-a-month Pro plan or one of the Max plans.
04:30
Speaker A
co-work, or you can be in Cloud Code. And this is where we're going to set up these actual routines where now if I go to my calendar, you can see every single day I've got Bull, which is my trading
04:39
Speaker A
In this video, you might also see me use Claude Code inside something that looks like this, which is the VS Code IDE with the Claude Code extension. It's not mandatory, but it's where I typically prefer to use Claude Code, because I can see all my files over here. If you want to do that, search for VS Code in your browser, open it up, and download it. It's completely free. Then connect your Claude Code account.
04:47
Speaker A
So this is the way I currently have mine set up and we're able to manage everything right from here inside of the Cloud desktop app because of this whole routine feature. So all you need to do to use the Cloud desktop app is just
04:57
Speaker A
That's the tech stack we're going to use today to get all of this set up. Let's get back to the video.
05:07
Speaker A
is make sure that you are on an actual subscription. So it has to be a paid either 20 bucks a month plan or the max plans. Now in this video, you might also see me use Cloud Code inside of
05:16
Speaker A
Okay, before we get into the step-by-step build, we need to talk about the mental model. Understand this before you write anything. The trading strategy is only one piece of the work. The memory architecture you use is going to be huge.
05:27
Speaker A
want to do that, just type in VS Code in your browser, open this up. It's completely free to download and then go ahead and download it and connect your Cloud Code account. So that is pretty much the text stack that we're going to
05:36
Speaker A
Every time a routine fires at 7:00 a.m., Claude Code wakes up essentially stateless. It doesn't know anything from before. So how do you make a stateless agent act disciplined, remember its rules, and learn over time? You do that with files and with context. Every
05:46
Speaker A
So understand this before you write anything. The trading strategy is a piece of the work, but the memory architecture that you're going to use is going to be huge.
05:55
Speaker A
So, every time a routine fires at 7:00 a.m., Claude code basically wakes up essentially stateless. It doesn't really know anything. So, how do you make a stateless agent act disciplined and remember rules and learn over time? You do that with files and with context. So,
06:08
Speaker A
every routine basically wakes up, reads files, does the job, and then writes back any important lessons or anything in like that the next agent when it wakes up needs to know, it just writes that down.
06:20
Speaker A
And that's kind of at a very high level the type of framework that we're going to be using here. So, the final thing I wanted to talk about before we get into this is the context budget. So, treat tokens like money,
06:30
Speaker A
obviously. Every file that you ask the agent to read it's going to cost you.
06:33
Speaker A
Each routine gets about 200,000 tokens to work with. I mean, we do have the a million token context window models now, but I don't really like to think of it like I have a million tokens to play with because context rot. So, system
06:44
Speaker A
instructions will take some up, strategy files, your trade log, your API, your research. Every run is going to take a different amount of tokens, but just keep that in mind. And the reason here that we're using, if I go back to the
06:54
Speaker A
stack, Claude code instead of just using something like, you know, the agent's SDK or I mean, I guess that could work, but rather than just using like a standard automation, is because if we do this with routines, we basically get the
07:06
Speaker A
full autonomy of us working with Claude code manually because it goes through that whole agentic earnest loop of figuring things out. And especially with Opus for that 7, it's apparently going to be really, really good.
07:18
Speaker A
Whereas, if you just had like an automation that would do research and then, you know, make a trade, you're not getting that super variability that you probably want with something that could be very volatile like trading. All right, so now that we got all of that
07:30
Speaker A
stuff out of the way, let's get into the strategy. So, step one, think of this like you're teaching a kid to ride a bike. You have to explain how to balance before you go. You have to explain to the kid that he's going to
07:42
Speaker A
steer with his hands and he's going to pedal with his feet. And even once you put him on the bike, you're not just going to let him go. You're going to hold the handlebars, you're going to put your hand on his back, and you're going
07:51
Speaker A
to walk with him until he gets a little more comfortable. And then slowly you might take off, you know, you might stop steering, but you might just run behind him. And then slowly you'll put on some training wheels. And like you just keep
08:00
Speaker A
bumping it up in phases. You can't expect to just throw a kid on a bike and it's instantly going to be magic. So maybe you want to start with paper trading. This is obviously not financial advice and I'm not, you know,
08:09
Speaker A
recommending that you go put all of your life savings in here and expect to make money and then get mad at me. This is an experiment for me and I'm trying to show you guys what's possible. So just keep
08:18
Speaker A
that in mind. Start with paper trading first if you're not comfortable. But anyways, the idea is you need a strategy. So for me, what I'm going to do is I'm basically going to extract all of the strategy that we've been using
08:28
Speaker A
from my Open Claw agent, and I'm just going to say, "Hey, let's take this over to Cloud Code." So for me it's a little easier. But for you, if you actually are like a manual trader and every day you
08:36
Speaker A
think about things and you do research and you place trades or you sell things, then just write down your strategy. How often are you checking the news? What are the signals that make you realize I'm going to buy this or I'm going to
08:45
Speaker A
sell this? As much of your gut intuition and your routine about trading that you can get into this Cloud Code project, the better. And then I will over time you're going to help it learn from its mistakes, you're going to iterate, and
08:57
Speaker A
it's going to get better and better every time you use it. But if you're starting completely fresh, which in my case of the Open Claw trading challenge, I literally just said, "Hey, I'm doing a 30-day challenge. I'm trying to compete
09:08
Speaker A
against my friend Salmon. Go to research. Spin up a team of sub agents. You're my wealth advisor. Try to beat the S&P. Figure out the best plan possible." And that's like genuinely all that I said to it, which I think is
09:18
Speaker A
pretty cool. And it went off and it did a bunch of research. It figured out a strategy for me. And then for the next 30 days it just did that. And I barely had to touch it at all.
09:26
Speaker A
So if you want to start off by playing around with some research like that, then certainly do that. But if you guys remember at the beginning of this video, I kind of alluded to this benchmark here. So in the official release, and by
09:36
Speaker A
the way, I just dropped a full video on this new release. I'll tag that up here.
09:40
Speaker A
So, in the official release of Claude Opus 4.7, they always drop the benchmarks and they compare it to other models that are kind of leading in the industry as well. And so, this is the one I wanted to talk about in this case.
09:50
Speaker A
We have a genetic financial analysis 64.4%. We also have stuff like gradual level reasoning and you know, just the ability to think really well. Um genetic search actually is worse than Opus 4.6, which is interesting. But yeah, genetic
10:03
Speaker A
financial analysis. So, what does that actually mean? This basically means that it is really good at analyzing a company. But it's not basically a signal or a benchmark for how good this model is at trading and specifically day
10:15
Speaker A
trading. Like this doesn't mean that it's going to be able to look at like a technical analysis and look at the candlesticks and the MACD and figure out the exact best moment to buy and then the exact moment to sell. I'm not going
10:24
Speaker A
to try to day trade with these agents. I just don't know enough about it to do it. But that's not what this metric is saying. This benchmark rewards models that can digest filings and write coherent fundamentals-driven theses or
10:35
Speaker A
thesis, I guess. And that maps to long-term or swing or fundamentals-driven strategies, not day trading. So, that's why once again, we're just going to be trying to beat the S&P here. Okay, so that is the overall strategy. Let's talk about the
10:47
Speaker A
scaffold. So, what you need to do to spin up the Claude code project in about 60 seconds is you're going to open up a new folder and we're going to open up Claude code. So, let me hop over to my
10:56
Speaker A
project right here. This is a new folder. It's called trading I think trading routine. This is basically just a settings file. There's hardly anything in there. The Claude doesn't D is blank and then we have a read me just because
11:07
Speaker A
I turned this into a GitHub repo so I can pull it into a routine later. If you haven't done that yet, it's fine. We'll talk about that in a sec. The reason why we're starting here in VS Code is
11:15
Speaker A
because I want to get started in a place where I can see all of my files on this left-hand side. Because if you're in the desktop app, which we will move over to here later, you don't get to see all
11:24
Speaker A
your files open on the left-hand side. On the left-hand side, you see your routines and your other sessions, which is great, but when we're first getting set up, I like to be able to see everything in one spot. So, we're going
11:33
Speaker A
to start here in the VS Code um either terminal or the Cloud Code extension.
11:38
Speaker A
So, let me show you guys what I did. This is my Telegram chat with Bull, my trading bot, and I said, "Hey, I want to completely migrate you to a different AI agent setup. I need you to break down
11:47
Speaker A
the strategy, the cron jobs, what are you looking for when you're doing your research, what type of sub agents do you have, what are the different signals, give me the full breakdown, all of your learnings." And so, it gave me all this
11:58
Speaker A
stuff. And so, what I'm going to do is I'm just going to basically migrate over this strategy into my Cloud Code project. You can see we have all of these sell signals, we have all of these key learnings, and these kind of main
12:08
Speaker A
frameworks, and we have our current portfolio. Real quick, guys, when it comes time for you to get set up, I have this free resource for you. It's a 13-page PDF, and I am assuming if you dropped this thing into Cloud Code and
12:19
Speaker A
then started to brainstorm with it, it would help you out a lot as far as the infrastructure and the folder structure and the way you want to get things set up and the way you want to create your
12:27
Speaker A
routines and things like that. So, it should be very helpful. This you can download for completely free in my free school community. The link for that is down in the description. Once you get in there, just head over to the classroom,
12:36
Speaker A
click on YouTube resources, and you'll be able to find it right in there. So, let's get back to the video. So, if I pull that up real quick, you can see here's today. We had a bit of a a jump,
12:44
Speaker A
and then we came back down today. Here is the past month, so this is where we were with the um open cloud agent. But you guys are going to want to go to Alpaca and make an account, especially
12:52
Speaker A
if you want to put real money in. You might have to take a few days for your account to get approved. So, head over there and get an account. Then I also told it to give me a technical cheat
13:00
Speaker A
sheet as far as like the different API end points it uses and how it makes those requests, as you can see, just because it already has all this knowledge. So, why waste time trying to train a new agent if we could just
13:09
Speaker A
migrate over all of these memories and knowledge to this new agent. And then at the end of that, it even gave me an export of all of these important files, like the agent instructions, the trading strategy, the trade log, the research
13:20
Speaker A
log, the weekly review. And I'm just basically going to migrate all this over. So, let me show you what that's going to look like. So, you can see that it gave me this zip file of all of those
13:29
Speaker A
seven files and I'm just basically going to extract those into this project right here. So I'm choosing the trading routine project, select folder and then extract and we should see all those files just popped up right over here on
13:39
Speaker A
this left-hand side. Now what I'm going to do is just talk to my Claude. I'm going to switch over here to plan mode and I'm just going to start talking. All right, so I am creating you as a 24/7 AI
13:49
Speaker A
agent trade bot for me. I had a project set up with open Claude and we were trading, you know, $10,000 using Alpaca for the past 30 days and we were doing pretty well, but now I want to move it over here so we can set you up
14:02
Speaker A
as a Claude code routine. So I just dropped in a ton of context for you.
14:06
Speaker A
There's a ton of files in this project. Um if you want to just take a second to get sort of like acclimated to what I dropped in there.
14:13
Speaker A
There's going to be a lot of information, but basically that's like all of the knowledge and all of the strategies and all of the signals that our open Claude agent had and how it was able to be successful and I just
14:23
Speaker A
want to migrate that over here to you so that we're not losing any of our knowledge. I'm also going to paste in some of the key things that it told me that you should make sure to know. So
14:31
Speaker A
I'm going to drop in that stuff right below. Now some of this stuff you can take with a grain of salt because it might have been set up and optimized for an open Claude agent harness, but you're Claude code. You understand the best way
14:42
Speaker A
to set up your projects and to do things. So what's really important is that you're ingesting this information and you're understanding it and then you're helping yourself organize this project in a way that makes the most sense to you. Okay, so I know that that
14:55
Speaker A
is a ton of information that I just chucked into there and you guys might be sitting there like, okay, well I don't have all these files. What do I do? This is where you just start to brainstorm.
15:02
Speaker A
Literally treat this thing as if it is your best friend who is the best trader in the world and you are just trying to give it your strategy now. So if we think back to earlier in step one where
15:10
Speaker A
I talked about the strategy, when you open up a piece of paper or sorry, you take out a piece of paper, you open up a Google Doc and you just start writing down. How do you actually trade? What's
15:19
Speaker A
your approach? Once you write down all this stuff and you basically just brain dump about how you want to do it, then you plug it into the Claude code, and that's where you see how I set up this
15:27
Speaker A
project here. I'm just helping it get situated with what we want to do right now. And honestly, the more context and details that you give it right now, the more it asks you questions, the better.
15:37
Speaker A
As you can see, I'm using the brainstorming skill from Superpowers, and it's going to start off by asking me some questions. Okay, so I just answered some questions, and I did want to show you guys this. So, it alerted me about
15:46
Speaker A
something with security inside of this template that Open Claude gave me, it had my live Alpaca key in there. So, I'm going to go ahead and rotate those before we actually push this new one into production, but just something to
15:58
Speaker A
be thinking about when you're migrating stuff or when you're feeding in API keys directly to a chat. Just be careful of that kind of stuff. And I'm going to show you how we get our API keys set up
16:06
Speaker A
in routines because you don't want to put them straight into a GitHub repo. You're going to have to set them up in the environment variables, so I will show you guys that as well. Okay, so this point it's come back with a plan.
16:15
Speaker A
So, Nate ran a live money Alpaca trading bot called Bull on the Open Claude harness for 30 days, and now we have all these context files with strategy, with trade history, with research notes, blah blah blah. The goal of this migration is
16:26
Speaker A
to make Claude code a first-class home for this bot. So, we will set up the cron scheduling, the notifications.
16:32
Speaker A
We're getting rid of that agent mail step, so me and Solomon were having our agents trash talk each other. We're going to rotate our credentials, of course. And then it's proposing a layout for the way that the files should be set
16:41
Speaker A
up. So, you can see, it's going to put the files in here into the memory, and then we're going to be able to prompt our routines to always check the memory first and update the memory. So, this is
16:50
Speaker A
where it will really help for you guys to brainstorm with how the project should be set up. Oh, one other thing that I forgot to give it here is that I want it to use Perplexity for research.
16:58
Speaker A
So, I'm going to come down here to the bottom of the plan, and I'm going to say, "Yeah, this all looks pretty much good to go, but one thing I forgot to tell you is that we want to use Perplexity
17:06
Speaker A
for research rather than just the native Claude code web search and web fetch function. So, add in that Perplexity will be used for web search, and once again, once we set up up routine, that's when I'll give you the Perplexity API
17:17
Speaker A
key. Okay, so after this change has been made, we should be ready to start migrating over to setting up the routines. All right, so the new plan has come back. So, here's the end-to-end check. Secrets, Alpaca, memory file
17:30
Speaker A
commands, dry run, ClickUp, Perplexity, nice. We're going to go ahead and accept these changes. And you also notice that we have auto mode on. So, I think with this new update with Opus 4.7, when you auto-accept a plan, it turns on auto
17:42
Speaker A
mode, which means it lets Cloud handle permission prompts automatically. Now, you will have to be careful though because doing this is a little bit more expensive. So, if you don't want it to be auto mode, then you can just switch
17:51
Speaker A
it right off of auto mode, of course. But, um yeah, just something I wanted to point out. All right, so while all of that's still getting set up, let's talk about step three, which is guardrails.
18:00
Speaker A
So, before you start working in the trading logic, think about this kind of stuff. I obviously talked about how you could start with paper mode, and then you toggle on real trading and put in money when you feel comfortable. You
18:10
Speaker A
could do things like, "Hey, max 5% of my portfolio per position." You can have a daily loss cap. You can tell the agent not to do, like only buy three new positions per week, or no options ever, or don't do this, or always do this.
18:22
Speaker A
Because the agent is going to be autonomous, it's going to be eager, and if you don't give it guardrails, it might just kind of start to, you know, go off the rails. But like I said, even though I'm migrating a system over, I
18:31
Speaker A
know it's not going to be perfect. So, I'm going to watch every single run, and I'm going to read through the conversation history of every run, and I'm going to see if there's things that I need to tweak in the prompt, or things
18:40
Speaker A
that I need to tweak in the project settings, or the context files. And like I said, just kind of keep building the plan as we're flying it here. And then, that's where we also start to develop skills. Because right now we have skills
18:51
Speaker A
maybe for like a research skill, or for a trade skill. But we're going to make sure that we're getting them actually explicitly invoked, and we're going to be making sure that that increases the consistency, and we're going to make
19:01
Speaker A
sure that the agent is able to give us insights every day of, "Hey, here is what worked well, and here's what I noticed, and hey, here's where I think that maybe we should update these skills X, Y, and Z, you you whatever." So, a
19:11
Speaker A
combination of thinking about the guardrails and thinking about skills is how you can continuously make this thing better over time. And now that we've talked about all that, we will get to the routines and the deployment. Let's check in on our
19:23
Speaker A
guy right here. And because I turned it off auto mode, it was sitting and waiting for me to do a permission. All right, so everything has been migrated.
19:30
Speaker A
We're looking good, but we're getting a little bit to the point where I like to reset the context. So, before we move on, I'm going to say, "Hey, give me a summary of what we've done." And then I'm going to clear the context and we'll
19:39
Speaker A
get started again. All right, so here's the session summary that it gave me. Copy that.
19:44
Speaker A
Do a slash clear. Paste that in, hit enter, and now we're basically right back at the beginning with a fresh window of context. So, this is where it gets pretty cool. You can see on the left-hand side it has
19:55
Speaker A
reorganized things. We have our scripts, we have our memory files, we even have some commands in here, and it built all of that just because I told it that I was trying to migrate stuff over. It also updated this Claude.md file because
20:05
Speaker A
now we have Bull back in all of his glory, and we have our Claude.md file that is about 156 lines. So, now it's time to start planning out step five, which is the routines. So, we basically need to figure out what are the
20:17
Speaker A
different daily triggers that we actually want. And we also don't maybe want them every day because the market's only open five days a week. So, this is kind of like a baseline. This is kind of how it worked with my Bull trading
20:27
Speaker A
agent. But I'm actually just going to come into VS Code and we're just going to brainstorm once again. So, I'm going to go on plan mode and I'm just going to start asking. All right, so now that you
20:34
Speaker A
know everything about this project and you understand what we did with Open Claude, I want you to help me figure out what is the best way that we should be setting up these Claude code routines to basically simulate that exact same type
20:46
Speaker A
of environment. So, we have those cron jobs, but each one is kind of doing a bit of a different thing. You know, the pre-market one does a bit of a different job than the mid-market one. And the the
20:56
Speaker A
day close one does a bit of a different job. So, you have a better idea of all of our memory files and our skills, and you understand the structure of every time the agent wakes up and the routine
21:07
Speaker A
is triggered, they need to read the files first to, you know, kind of get it acclimated with the environment, do what they need to do, research, potentially make a trade, potentially sell something, you know, whatever it is based on their best judgment, and then
21:19
Speaker A
update all of the memory files so that next time the next agent wakes up, they understand what's going on. So, what I want you to do is help me figure out what are the right structure for these um
21:29
Speaker A
cron jobs, and most likely we only want them during the week when the market's actually open.
21:35
Speaker A
And just like that, I'm able to brain dump and Claude's going to do the heavy lifting for me and propose some ideas.
21:40
Speaker A
Okay, let's see the plan that it came up with. So, stand up five recurring Claude code schedule triggers, and we've got these different slash commands that it's going to be able to utilize. So, all five triggers will run on the weekdays
21:52
Speaker A
only except for the weekly review, which is Friday only. So, we have a pre-market, which is for research catalysts and draft trade ideas. It won't message me unless it's urgent. We have a market open, which is going to
22:02
Speaker A
execute the planned trades and set 10% trailing stops that'll go to the trade log. Only if a trade is placed will I get a notification. We have midday, which will cut minus 7% losers and tighten stops on winners, also going to
22:14
Speaker A
trade log. So, here you guys can see basically it was able to analyze our strategy and analyze what we have access to and then build me a plan. And now what I want to do is basically just have it create those prompts for me so
22:25
Speaker A
that I can go ahead and go set up those routines in Claude code. All right, so those crons look great. So, I don't need you to actually create them. What I need you to create for me is the prompts. As
22:35
Speaker A
if I was going to run one of those commands into a fresh Claude code session and I wanted it to do all the right stuff, what is the exact prompt that I would enter into that session?
22:45
Speaker A
And the one thing that you need to keep in mind here is reminding it to obviously um read the files before it does anything, and update the files at the end, and then also when it needs to use an API like Perplexity or ClickUp or
22:56
Speaker A
Alpaca, that it should be grabbing those keys from the environment variables of that environment, not inside a .env file. All right, and now with that feedback, it should be able to give us those prompts, and then we should be
23:08
Speaker A
able to just set up the routines and go ahead and test them out. Okay, so while this is writing up, there is one more thing that I wanted to show you guys that is very important. So, in the Cloud
23:16
Speaker A
Code desktop app, when you go to routines and you go to create a new one, you can see that you can create them locally or remote. So, if you create them locally like some of these I have, this just basically means that it lives
23:26
Speaker A
in your local directory. It can still talk to the internet and do all those things, but it lives in your machine essentially. And that means if you closed out of this desktop app, that local routine would not fire off. And that's
23:39
Speaker A
why these remote routines are so cool because your computer can be off, but they're still running because they run in the cloud. But what that means is when you do a remote run, you have to have a GitHub repository to have this
23:50
Speaker A
run in, which is why I have this trading routine repo set up. And so, when they run via a cloud, you know, routine, it basically clones that repo in the cloud. It spins up a copy.
24:01
Speaker A
It works out of it. It does what it needs to do, and then it basically like destroys that cloud environment. So, if you want them to run remotely and you want those files to persist every session, you just have to talk to Cloud
24:11
Speaker A
Code and say, "Hey, make sure, you know, because we're doing a routine, make sure that all of these files that it's actually updating, it's able to push back and commit back to that main actual branch, back to that main." And we just
24:22
Speaker A
got a notification from my trading bot because it was market close. But anyways, I was saying, make sure that it's able to push those changes back to the main repo. Otherwise, the next agent's not going to pick it up, and
24:34
Speaker A
then what's even the point? So, you can start local if you want, and then you can sort of graduate to the cloud if you want, but I definitely just wanted to make sure you guys understood that difference there. Okay, so that's done.
24:44
Speaker A
You can see it created this new folder right here called routines, and this is basically the prompt that we'd be feeding into each of the different routines that we make in order to make sure that Bull actually understands what
24:55
Speaker A
to do. And the last thing we need to do is actually push all of these new changes to this GitHub repo because right now here is my trading routine private repo. All that's in there is a readme and I don't think there's
25:04
Speaker A
anything in here. So, we need to get all of these files that we just created, you know, these commands, these scripts, these memory files. We can just have to get all of this into that repo so that our routine can actually access it. So,
25:14
Speaker A
all I have to do is say, "Hey, push all of these changes, commit everything to the repo." By the way, if you've never done that before, it's super super simple. You go to github.com, create an account. It's free
25:23
Speaker A
to create an account. And GitHub is really just like um it's like working on um a Microsoft Word on your computer and that's like local. And if you wanted to share it with someone, you would have to put it
25:34
Speaker A
into like the shared drive or, you know, a a Google Drive or something. It just means that you could grab a code base from a different machine because you've uploaded it somewhere on the cloud. So, that's kind of why we're doing this
25:44
Speaker A
whole thing with the routines in the cloud. So, when you get to GitHub, you come here, you create a new repository or the easiest way to do it is you just come to your Cloud Code and you say,
25:53
Speaker A
"Hey, help me turn this into a GitHub repo." And it will say, "Okay, I need to authenticate you. Can I use the CLI?" And you say, "Yes, go ahead and do that." And then it will basically open up a tab and it will say, "Hey, can you
26:03
Speaker A
sign in with your GitHub?" You sign in and now your Cloud Code just has your GitHub credentials. And whenever you need to push changes or clone a repo or whatever you need to do with GitHub, it can just take care of it because
26:15
Speaker A
GitHub's been around for a long time, so it knows it way better than you probably do. It knows it way better than I do.
26:19
Speaker A
So, when in doubt, just ask Cloud Code. All right, so if I give this puppy a refresh, we should see that we now have all of these files popped in here. We've got bull trading routine. Awesome. So, let's head over to the Cloud Desktop app
26:31
Speaker A
now and start getting set up. So, what you're going to do is you're going to click on new session and you want to open up the local projects right here of whichever thing you just set up there.
26:41
Speaker A
So, right here you can see that I'm in the folder called trading routine, which we were just working in in VS Code. And if you guys remember, in VS Code, we had these five different routine prompts.
26:50
Speaker A
And inside of each of these, they had the cron, they had the actual like steps, and then they had like any of the skills or commands that they need to run. And this is in a folder once again
26:58
Speaker A
called routines. So, before we start talking to our new project, we need to set up an actual environment for this.
27:05
Speaker A
So, if I go to new routine and I go to remote and I go over here to my um cloud environments, you can see that you can add one. And so, just add one and I'm going to pull up my trading one so you
27:14
Speaker A
guys can see. But here, this is where we set up things like our API keys and our network access. So, I called mine trading. I gave it full network and this is where I'm going to put in my API keys
27:24
Speaker A
for Alpaca and for Perplexity and for ClickUp. And then you basically just go ahead and save the changes of that environment and this is the one that you want your actual routines to be scheduled inside of. I am going to basically just talk to
27:38
Speaker A
it right here to help us get these remote routines set up. Look inside the routines folder inside of this project and help me set up all of these different scheduled routine runs. They should all have a cron job in there.
27:51
Speaker A
They should all have a prompt in there already and we will be working out of this GitHub repo and scheduling off these routines. So, let me know if you have any questions. Do not exit the planning phase until you're 95%
28:01
Speaker A
confident that you know exactly what to do and exactly what I'm looking for. So, now I'll shoot that off and it should be able to come back with a plan to actually go create all of those cron jobs for us. Okay, now you can see it's
28:11
Speaker A
coming back and asking us some questions. So, the first one is which cloud environment should they run in?
28:15
Speaker A
We're going to do trading. That's the one you guys saw me set up. We want to use Cloud Opus 4.7 and we're going to use this GitHub repo. Yes, trading routine. All right, so it's set up all of those routines for us. You see that
28:26
Speaker A
all I had to do was talk to it. It set up these crons cuz I don't know what exactly this means, but basically that means 6:00 a.m. Monday through Friday for all of these. Monday through Friday 8:30 a.m., noon, 3:00 p.m. and then this
28:36
Speaker A
one is just 4:00 p.m. on Friday. So, if I go over here to my routines and I scroll down, you can see that we have these new five routines for bull and these are all remote. If I click in this
28:46
Speaker A
one for example says every Friday at 4:00 p.m. Central, we're in the right repo. If I click into here, we should see we see this entire prompt, which is correct, and we're in the right environment, which is my trading cloud
28:57
Speaker A
environment. And then one other important thing that you have to do is inside of your actual um routine, what you want to do is go to permissions, and you want to turn on allow unrestricted branch pushes. This removes the branch
29:09
Speaker A
push restrictions, and Claude will be able to actually push to any branch, not just the Claude {slash} branches. So, turn that on for all five of these routines here. So, I'm going to turn that on for all five of these routines
29:18
Speaker A
here. So, let's just pretend that it is Friday. I'm going to do a run now to see if this is able to actually work. And when you run these, you can actually click right here, and you can watch them
29:27
Speaker A
actually work in real time. And best practice with routines is that every single time you build a new one, you should always do a run now at least a few times to make sure that they are working as expected. And exactly why we
29:37
Speaker A
test out, you can see what happened is when it tried to hit Alpaca, it wasn't able to find the API key because for some reason, once again, it thought it was going to be in a {dot} env, but as
29:45
Speaker A
you guys know, we don't have a {dot} env because we don't put that in the GitHub.
29:48
Speaker A
So, I'm coming back into this session that set up these five, and I'm just going to say, "Hey, remember, all of the API keys are going to be stored in the environment variables. So, all of the prompts must explicitly state that."
29:57
Speaker A
Okay, so the issue was they weren't spelled exactly word for word, letter for letter. So, I fixed that, and you can even see, for example, this one, they're all now coming through, but for example, in this one, I have the word
30:07
Speaker A
API right here between Alpaca and secret. So, they have to be matching one for one, otherwise it will think that they're not there. But anyways, now that that has been figured out, it's actually able to look through all of these
30:18
Speaker A
things, it's able to look through the memory, and it's going to execute our weekly review here. And there we go, just like that, the weekly review has been ran. I also told it that I fixed the Alpaca secret key, so now all of
30:28
Speaker A
that's been updated. And if you go over to my GitHub, you can see that it was able to push these actual commits to this repo. This one was just a test one that it was running on the background as
30:37
Speaker A
well, but it was able to actually give us the weekly review, and you can see it was committed by Claude, and it made changes to this actual MD file. So now, the next time it actually will be able
30:46
Speaker A
to pick it up and we have our stuff all synced up. And alongside that weekly review, you can see that in my internal automations channel, sandwiched between two YouTube notifications, we have the weekly review that the run just sent us.
30:59
Speaker A
We have our portfolio, we have versus the S&P, and we have any trades that we were making, and then, you know, some best and worst, and also it graded itself a C for the week. So, we'll see how this is able to improve. So, I just
31:11
Speaker A
spun up this test so you guys could see that we are able to talk to Alpaca right now. You can see that we're able to get the current balance. And if I go into here, we should see 9859. And back in
31:21
Speaker A
Claude Desktop, where it pulled it, 9859. And just like that, we have set up a 24/7 AI agent trade system with Opus 4.7. We've got our 6:00 a.m., our 8:30 a.m., we've got our noon, and our 3:00 p.m. And then on Fridays, we have our
31:34
Speaker A
actual weekly review as well. Now, of course, like I talked about earlier, it is on you to now keep testing, keep iterating, making sure that everything's working, and upgrading your strategy as you go. And maybe you want to add some
31:44
Speaker A
more crons in. Maybe you want to take some away. Maybe you want to add one on just like a Sunday night to do some more research to prep for the week. However, you would actually want to set up your
31:51
Speaker A
trading strategy if you were doing it manually. Now, I know you guys are thinking like I have four automations per day basically plugged in now with Claude routines, and that's going to eat away at my session limits, right? I
32:03
Speaker A
mean, yes and no. I'm definitely going to be watching it, obviously. But keep in mind, when I did this with my open Claude agent for 30 days, I was also plugged in my Claude subscription, and I was still doing my own workflows, and I
32:13
Speaker A
was never really hitting my limits. It's all about managing your context. And I'm going to have a full video dropping about that, another one coming out soon.
32:20
Speaker A
But I can tell you for certain that if I were to set up all of these crons and have the same sort of autonomy and agentic workflow-ness, and I was just doing this via API, then that would 100%
32:30
Speaker A
be way more expensive than what I've got set up here. We have now deployed, and now we just go ahead and track. And what is the hidden lesson here? The hidden lesson is that files aren't just memory, but they're essentially the agent's full
32:40
Speaker A
personality and discipline. Like with Open Claw, you set up your soul.md file and you've got your agents.md file and you got all these different files. So, it's really about how do you make sure that you orchestrate this in the right
32:50
Speaker A
way so that it can access the right ones when it needs to. So, anyways, I hope by the end of this video you guys are able to follow along and set this up. I'm going to be giving away this document
32:57
Speaker A
and it's going to have way more information in there basically about everything that we've gone over today and I'll drop that in my free school community. The link for that is down in the description. Once again, completely free. But, that is going to do it for
33:07
Speaker A
today. So, if you enjoyed the video or you learned something new, please give it a like. It helps me out a ton. And as always, I appreciate you guys making it to the end and I'll see you in the next
33:14
Speaker A
one. Thanks everyone.
Topics:Claude Opus 4.7Claude Code RoutinesAI trading agentAlpaca APIpaper tradingPerplexity APIClickUpS&P 500automationNate Herk

Get More with the SozAI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries and speaker detection. 30 minutes free.

Or transcribe another YouTube video here →