N
NatiStream
Transcript
Hiển thị

Building an AI Trading Agent with Claude Opus 4.7

The speaker introduces the concept of building a 24/7 AI trading agent using Claude Code routines and Opus 4.7. He explains that he beat the S&P by about 8% in a 30-day challenge using Opus 4.6, and now aims to improve with Opus 4.7. The agent will use Alpaca API, Perplexity API, and ClickUp for notifications. The mental model and memory architecture are emphasized as crucial for the trading strategy.

So, Claude Opus 4.6 is finally here, and it got me thinking because as I was scrolling down and I started looking at the benchmarks, I noticed right here we have a genetic financial analysis, and we have about a 4% jump from Opus 4.6.

And about a week ago, I dropped this video where me and Salmon 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 by about 8% as you can see right here.

This green line is my chart, and this gray line is the S&P. So, if you guys want to check out this full video, I will link that right up here. So, 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. So, 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.6 inside of Claude Code? We're not even going to touch open Claude or Hermes agent. We're going to just do this with Claude Code.

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 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, and 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. So, 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? 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. 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 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 just such a short amount of time. So, what is the tech stack? We're going to be using Claude Code routines. That's kind of our scheduler. For the AI model, we're going to use Opus 4.7. For the skills, we're going to be using just kind of like 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 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 cuz I 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 that we need for this video? The first one is going to be Alpaca. So, go to alpaca.markets.

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 more. But anyways, you're going to sign up right here, and you'll click on trading API. Now, once you get in there, you will have basically a paper trading

account, and right here you can see I've got a paper trading account with 100K. 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.

And then they're both the same as far as the credentials. You basically scroll down, and on the right-hand side you have your API keys right here. You get an endpoint, and you get a key, but you also need like a secret key. So, you have 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 to go away, and you'll only be able to see the key, but you need both of them.

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 down and find ClickUp API, and then I would just copy this token right here.

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 key. If I went down to right here, API keys, I could make a new one or copy an old one. But basically, the way it works is every platform has typically API keys. You just have to

find them in the settings somewhere. If you can't find them, just 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. And now that you know how to get these keys, just hold on to them. We're going to actually plug them in later in the video. And then the final piece of the puzzle is going to be the Claude desktop

app. You can see here you can have Claude chat, you can have Claude Code work, or you can be in Claude 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 agent, waking up at 6:00, 8:30, um noon, 3:00 p.m. And then on certain days, like on Fridays, he's doing a weekly review.

So, this is the way I currently have mine set up, and we're able to manage everything right from here inside of the Claude desktop app because of this whole routine feature. So, all you need to do to use the Claude desktop app is just type in Claude desktop app download, and you should be able to install it right here. You go to the downloads page, and then you just have to choose the Claude

desktop for your operating system. And then the only other thing you need to do 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 Claude Code inside of something that looks like this, which is the VS Code IDE, and then we use Claude Code extension inside of it. It's not

mandatory, but that is where I typically prefer to use Claude Code because I can see all of my files over here. So, if you 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 Claude Code account. So, that is pretty much the tech stack that we're going to be using today to get all of this set

up, and let's get back to the video. Okay, so before we get into the actual step-by-step kind of build, we are going to need to talk about the mental model.

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.

1 / 6