Sonnet 5 + Claude Code strategy makes 369% — Transcript
Full transcript
- 0:00The Anthropic team just released Claude
- 0:02Sonnet 5. Claude Sonnet used to be my
- 0:04favorite model of all time because it
- 0:07gave me the best quality comparing the
- 0:09results. Especially in the past where I
- 0:11would just wanted the $20 subscription
- 0:13model of Anthropic, Claude Sonnet was a
- 0:15really good deal for me. So, I'm really
- 0:17excited to try out this new version. As
- 0:19you guys know, on this channel what I
- 0:21care for is the performance of the model
- 0:24specifically for trading. I want to see
- 0:26how good of a strategy it can write for
- 0:28me and how good it is at following
- 0:30instructions to do real research for me.
- 0:33That includes running the backtest,
- 0:34doing optimization to find the best
- 0:36parameters of the strategy, and running
- 0:38Monte Carlo sessions to ensure the
- 0:40results that it finds for me aren't
- 0:41overfit. Now, before we continue, I got
- 0:43to say I am not a financial advisor and
- 0:45this video is for educational purposes
- 0:47only. So, with that out of the way,
- 0:49let's get right into it.
- 0:54So, here's a blog post by the Anthropic
- 0:56team and as you can see, here's the
- 0:59benchmark So, for agent coding, which is
- 1:01exactly what we need, it is a scoring
- 1:0363%
- 1:05which is almost 5% above Sonnet 4.6,
- 1:09which was a really good model by the
- 1:11way. Like, I've been using it until
- 1:12yesterday. And Opus 4.8, which is the
- 1:16easiest and my main driver because I
- 1:18have a max subscription plan of
- 1:20Anthropic, is still beating it. So, it
- 1:23is 69%. So, let's not forget this. And
- 1:26the same really goes for other stuff.
- 1:27So, in this one, it is just 2% below
- 1:30Opus 4.8, but it is beating Claude 4.6
- 1:34by significant margin, actually. And in
- 1:37the knowledge work, which is also
- 1:39important because we can consider this
- 1:42one for how good the model is at, for
- 1:44example, with its trading knowledge. So,
- 1:47not just following the tools or doing
- 1:49agent work for us, but it's actual
- 1:52knowledge. Like, what sort of indicators
- 1:54should it use? Or if it's not doing
- 1:56well, let's say in a range market, what
- 1:58should it do? So, that sort of thing.
- 2:00But, guys, I think the main reason that
- 2:02Anthropic didn't release the model that
- 2:04is actually beating Opus, because that's
- 2:06how they used to do it in the past, is
- 2:08because they were worried that the model
- 2:10is going to get flagged just like Claude
- 2:11Fable, so they didn't want it to get
- 2:14banned. I'm guessing that's why they are
- 2:16doing it this way, but overall, the fact
- 2:18that it's doing better than Sonnet 4.6
- 2:20is a good sign and enough for me. Now,
- 2:23as always, guys, I'm using framework for
- 2:26doing the algo trading side of things.
- 2:27So, if you haven't installed it already,
- 2:30now's a good time to do so. Here's the
- 2:32documentation where you can find
- 2:33everything that you need. And next, I'm
- 2:35going to use the Claude code inside the
- 2:37terminal, which is running inside my
- 2:39code editor. And the first step is to
- 2:41ensure the Jesse MCP has been added to
- 2:44your Claude code. For that, I'm simply
- 2:46going to copy this address from here and
- 2:48paste it here. Now, you need to be
- 2:49careful with this address. You see, it
- 2:51says using the port 9002, but for my
- 2:54project, actually running on port 9007.
- 2:57But, it doesn't matter, because I have
- 2:59already added this before, and Jesse MCP
- 3:01is connected to my Claude code. And just
- 3:03to ensure, I will simply say, "Hey, can
- 3:06you access Jesse MCP?" And yes, it says
- 3:10Jesse MCP is connected and working. Now,
- 3:12by the way, guys, the Sonnet 5 is
- 3:14available and it's been selected here.
- 3:16And if you haven't already switched to
- 3:18it, you're going to need to run {slash}
- 3:20model and then pick Sonnet, which is now
- 3:23using Sonnet 5. All right, so, to prompt
- 3:25the agent. So, I'm simply going to say,
- 3:27"Hey there, do research and find me two
- 3:29trading strategies. Each one of them
- 3:31should have a sharp ratio above one in
- 3:33the last 4 years. They should be trend
- 3:36following, include both long and short
- 3:38positions, and risk 3% of the account's
- 3:40capital per each trade. In the first
- 3:42strategy, once the position is open,
- 3:45close it using a trailing stop. In the
- 3:47second strategy, close the position at a
- 3:49specific points determined by the ATR
- 3:52indicator. You can test them on BTC,
- 3:54ETH, and SOL on the hourly timeframe.
- 3:57Every time you develop a strategy,
- 3:59validate the result using a statistical
- 4:01significance test before writing the
- 4:03full strategy. Only proceed if the
- 4:05strategy's entry rules demonstrates
- 4:07genuine statistical significance. Feel
- 4:10free to use optimization to improve the
- 4:12results. At the end, apply Monte Carlo
- 4:14simulations to ensure the results are
- 4:16not overfit. Continue until you find
- 4:18strategies that fully meet the criteria
- 4:21requested. Do not prompt me in the
- 4:23meantime. Good luck. And that's it. Now,
- 4:25because I am pasting basically a lot of
- 4:28content all at the same time, I'm seeing
- 4:29it like this. But if I hit enter, we can
- 4:32see it all being applied here.
- 4:34Everything looks good and we can just go
- 4:36and let Claude do his thing. Now, one
- 4:38thing I really liked about this model is
- 4:40that it is significantly faster. Whether
- 4:43it is actually worth it to use this
- 4:44comparing to Opus, I'm not sure at this
- 4:47point. We're going to see, I guess, but
- 4:49I do know that it is a lot faster to
- 4:50run. So, anyways, let's go and come back
- 4:52later. All right, so it's been around 1
- 4:55hour and the agent is done. So, if you
- 4:57come lower, we can see that it has been
- 5:00calling the MCP multiple times. It first
- 5:03checked and ensured that the necessary
- 5:04candles for ETH and SOL are present in
- 5:07my database and apparently a little bit
- 5:10of BTC was missing, which it re-imported
- 5:12for me. Then it wrote the strategies and
- 5:14ran them simultaneously. And then it ran
- 5:16an optimization session to improve the
- 5:19results. And then it kept doing this and
- 5:21it found that most of them are overfit
- 5:23results. But it didn't give up and
- 5:25continued doing research. Long story
- 5:27short, at this point in time, it did
- 5:29find one strategy which was way above
- 5:32the criteria that I set for the agent.
- 5:35So, it had a sharper 1.52.
- 5:37But another one was almost as good as
- 5:40what I wanted, but not quite. So, the
- 5:42agent was being lazy here, which isn't
- 5:44really great. And then the agent was
- 5:46like, "Yeah, I'm done." Like I did his
- 5:48job, but it hadn't. So, first of all, I
- 5:51asked him to give me the URL for the
- 5:53dashboard so I can check them out
- 5:54myself, but I also specifically said
- 5:56that one of them hasn't met the target
- 5:58yet. Why did you stop? So, after I was
- 6:01being hard on the agent, it did continue
- 6:03working until this point in time, which
- 6:06it did indeed reach the target that I
- 6:08needed. And it also gave me the URLs for
- 6:11the dashboard so I can check the results
- 6:13both for the backtest and the Monte
- 6:15Carlo simulation in order to ensure the
- 6:17result isn't overfit. So, let's open
- 6:19this one for the backtest first, and
- 6:21then this one for the Monte Carlo. Now,
- 6:24while that's going, I want to quickly
- 6:25remind you guys about our Telegram. It's
- 6:27the fastest way to get notified about my
- 6:29future work, whether it's a new tutorial
- 6:31or a tool that I create. Also, don't
- 6:33forget to check out our free Discord
- 6:34where more than 5,000 members like you
- 6:36and I are hanging out there and helping
- 6:38out each other with algo trading so we
- 6:40can all succeed together. The links for
- 6:42both are down in the description. So,
- 6:44look at this. This is amazing, guys.
- 6:46Like this is if we compare the results
- 6:48to the benchmark, which is like other
- 6:50assets that we were trading, but this
- 6:52isn't really a good way to compare it
- 6:54because it clearly the position sizing
- 6:56of the strategy isn't enough. We could
- 6:58increase it in order to actually give us
- 7:00better returns than the benchmarks, but
- 7:03if you consider the volatility, this one
- 7:05is clearly winning. Now, let's scroll
- 7:07down. So, in this chart, which is the
- 7:09max drawdown, and there aren't any
- 7:11benchmarks here, we can clearly see that
- 7:13this is a smooth equity curve, and it
- 7:16looks amazing. And here we can see the
- 7:18monthly returns. You see, it's green on
- 7:20most months, and it is definitely green
- 7:23every single year. But the reason these
- 7:25numbers aren't like huge is because the
- 7:27max drawdown of the strategy is only
- 7:29minus 7%. So, this is really low. So, it
- 7:32made 75%. This can easily be increased.
- 7:35It's executed 1,234
- 7:39trades, which is amazing. The win rate
- 7:41was 36%. so this is something to be
- 7:44aware of because that means
- 7:45approximately like 6 and 1/2 out of
- 7:47every 10 trades are going to be losing
- 7:49ones. So, this is perfectly normal for a
- 7:51trend following strategy because the
- 7:53wins that you have are going to be
- 7:55significantly bigger than the losses. In
- 7:57fact, if we take a look at this value
- 7:59here, which is the average win to loss
- 8:01ratio, it is 2.24. This is why even
- 8:04though the win rate is way below 50%, we
- 8:07are being profitable overall. The Sharpe
- 8:08ratio is 1. 53. So, overall, this is
- 8:11great and it is executing on three
- 8:13symbols simultaneously. So, this is also
- 8:15another reason why we're getting good
- 8:17results. And in order to beat this, so
- 8:19this is what I can do. I could just
- 8:21click on new session and go and edit the
- 8:24strategy myself and go to the position
- 8:27sizing part, which is here. So, you see
- 8:29this is the quantity of the order,
- 8:31right? So, I could easily multiply this
- 8:33by something like three, which by the
- 8:36way, guys, I don't suggest you do this
- 8:37for production because you want to be
- 8:40completely aware of how much you are
- 8:42risking. So, this isn't exactly how I
- 8:44would do it in production, but just in
- 8:46order to demonstrate this in this
- 8:49backtest, it's a good solution. So,
- 8:51let's save this, go back, and give it
- 8:53another shot. There we go. So, now you
- 8:55see in the equity curve of the
- 8:58portfolio, which is this purple one, we
- 9:00are beating all the other stuff even P&L
- 9:03wise. So, this is pretty great to see,
- 9:05but of course, when we do that, the max
- 9:07drawdown also increases. So, it isn't
- 9:10minus 7% anymore, it is minus 20%, which
- 9:12is is still way acceptable for me. But
- 9:15the yearly returns have significantly
- 9:17increased now. We even have a year with
- 9:1986%. We have another one with 67, so
- 9:22this is pretty good. And if you want to
- 9:24see some of the individual trades, we
- 9:26can click on this view chart button
- 9:28here. And here is the complete list of
- 9:30the trades that it took. So, for
- 9:31example, this one looks good, so let's
- 9:33click on it. All right, so it went short
- 9:35and then closed the same trade on the
- 9:37same candle. In this losing one, again
- 9:40the same thing happened. Here we went
- 9:42long and then close it on the same
- 9:44candle. Here, here we went short and
- 9:48then we close it here. We can also
- 9:50change this into ETH to see the trades
- 9:53that we took for ETH. So, we went short
- 9:55here and then close it here. We went
- 9:57short here and close it here. And then
- 10:01short here and close it here. So,
- 10:02overall, I actually like the results
- 10:04better for ETH. So, this looks pretty
- 10:06good. And with this new position sizing
- 10:08we are making 369%
- 10:12but this is over 4 years. Now, another
- 10:14thing is the Monte Carlo simulation that
- 10:16we have to check out, which is how we uh
- 10:19stress test the strategy to ensure the
- 10:21result isn't overfit. So, this is how
- 10:23the results would look. So, this yellow
- 10:26line here is the original backtest and
- 10:29these blue lines here are the
- 10:30simulations. So, as you can see, the
- 10:32Sharpe ratio of the original is 1.5. The
- 10:35median is 1.41 and the best 5% is two.
- 10:39So, the Sharpe ratio of the original is
- 10:41clearly way closer to the median number,
- 10:43which is a really good sign. If this
- 10:45number was closer to two, such as 1.8,
- 10:491.9 or even if it was better than two,
- 10:52so it was clearly in the best 5% that
- 10:54would have been a clear signal of the
- 10:56strategy being overfit. But now that it
- 10:58is not, this is a good sign that it most
- 11:00likely isn't overfit. And I'm
- 11:02emphasizing on the word most likely
- 11:04because you can never be 100% sure with
- 11:07over fitting, so that's just something
- 11:08to remember, which is why we want to
- 11:10find as many as strategies as possible
- 11:12and run them simultaneously so that if
- 11:15one of them, for example, isn't
- 11:16performing well, the other would cover
- 11:18us. All right, so let's go back. Next,
- 11:20let's check out this second strategy
- 11:22that we found for us. So, the backtest
- 11:24results and the Monte Carlo. Let's open
- 11:26both of them. Here's the backtest. So,
- 11:28you see this one also looks pretty good
- 11:30but during this period, which includes
- 11:32most of 2023, I don't really like these
- 11:36results. But here you could say it
- 11:37crushed everything, so at least it's not
- 11:40really losing money. So I guess if you
- 11:41run something like this, at worst it
- 11:43would be neutral and at best it crushed
- 11:45it, which is a good sign. The average
- 11:46trades per month is 15, sharp ratio is
- 11:49one, the win rate is 36%. It executed
- 11:52741
- 11:53trades. So overall it looks good and the
- 11:56monthly returns also aren't that bad.
- 11:59So, yeah. This also looks good, but I
- 12:01would say the first strategy that you
- 12:03found for us is significant better. So I
- 12:05actually rather run this one. But if you
- 12:07check out the Monte Carlo, so this one
- 12:09also looks really good. Like you see the
- 12:11original backtest is right in the middle
- 12:13of the simulations, which is a really
- 12:15good sign. The sharp is one, which is
- 12:17below the median. So, if you consider
- 12:19this fact, this one is actually beating
- 12:21the first strategy because according to
- 12:23Monte Carlo, it's even less likely to be
- 12:26overfit, which is a really good sign.
- 12:28But still considering this and fact that
- 12:30it didn't really perform well during
- 12:322023, I prefer to run the first
- 12:34strategy. But the first strategy didn't
- 12:37really perform well during the second
- 12:38half of 2022, which was a bear market.
- 12:41In the first half, I would say it was
- 12:42good. So this is also something to be
- 12:44aware of. And also in the past few
- 12:46months, like in this period, it wasn't
- 12:48doing great, which I'm not really
- 12:50surprised because the market was in a
- 12:52really bad phase with all the
- 12:54uncertainty that was in the market
- 12:56because of the war and everything. So, I
- 12:58don't really expect any trend following
- 13:00strategy to have done well during that
- 13:02period. But the fact that it did make it
- 13:04back here also gives me confidence in
- 13:06running it. Now, let's copy the code for
- 13:09this strategy and go and check it out.
- 13:11Cuz I want to see, for example, how did
- 13:13it do the exit of the strategy? So,
- 13:16first of all, these are the hyper
- 13:17parameters that the strategy defined.
- 13:19These are the DNAs that it defined,
- 13:21which is basically the result of the
- 13:23optimization. And here we can see the
- 13:25Bollinger Bands, the trend EMA, the ATR,
- 13:28and these are the entry rules of the
- 13:30strategy, which it says the closing
- 13:32price must be above the upper band of
- 13:34the Bollinger Bands, and it should also
- 13:36be above the current 20 EMA, which is
- 13:39the moving average, and it's doing the
- 13:42opposite for short positions. Here's the
- 13:44position sizing, so the entry price is
- 13:45going to be the current price, which is
- 13:47a market order. Here's the stop, and
- 13:49it's using the ATR indicator, and here's
- 13:52the position sizing, and here's where it
- 13:54submit the buy order. So, it's doing the
- 13:56opposite for short positions, and once
- 13:57the position is open, using the on open
- 13:59position event hook, it's saying if it's
- 14:02a long position, submit the stop loss,
- 14:04and we want to use the quantity of the
- 14:06current position, and this is the price,
- 14:08and then here's where it is updating the
- 14:12stop loss order. So, this one is
- 14:14actually the one that is using a
- 14:15trailing stop. So, not the one that was
- 14:19supposed to set a specific targets for
- 14:21closing the position. And if we check
- 14:23the other one, here we can see again the
- 14:26Bollinger Bands, trend EMA. So, they're
- 14:28actually pretty similar, except that in
- 14:31this one, we aren't submitting a
- 14:33trailing stop. So, you see, in the
- 14:35previous one, we were using the update
- 14:36position method, which is this function
- 14:38of Jesse, which gets called every time a
- 14:40new candle closes. So, basically,
- 14:42whenever we close any candle, we want to
- 14:45update the stop loss. That's why we call
- 14:47it a trailing stop. But in this one,
- 14:49we're not doing that. So, once the
- 14:50position opens, we submit both the stop
- 14:52loss and the take profit, and that's it.
- 14:55We wait until one of them is hit. And
- 14:57according to this, we're getting better
- 14:59results if we were trading this. And
- 15:01actually, guys, this is exactly what I
- 15:03usually get in my trading, that whenever
- 15:06I submit specific points for a stop loss
- 15:08and take profit, I get way better better
- 15:10results if I were to use a trailing
- 15:12stop. But a trailing stop is something
- 15:14that manual traders really like, and
- 15:16they think it gives them better odds,
- 15:18but I never saw the same thing in the
- 15:20algo trading. So, that's one of the
- 15:22reasons why I like backtesting because
- 15:24you will be able to debunk some of the
- 15:25myth of the trading that's out there and
- 15:28you can see the results for yourself.
- 15:30All right, so overall I liked the
- 15:31results that we found, but one thing
- 15:34isn't exactly how I wanted it. So,
- 15:35initially when I wrote that prompt, I
- 15:37expected it to find strategies that can
- 15:40get me those results on each of these
- 15:42symbols. I didn't mean it to run them
- 15:44simultaneously like in this case. So,
- 15:46this is basically a portfolio of three
- 15:49symbols. And the entire portfolio is the
- 15:52one that is giving us these results. So,
- 15:53if you were to run these individually,
- 15:56you would not have gotten such a good
- 15:57number. And I'm not saying that you
- 15:59shouldn't run multiple symbols
- 16:00simultaneously. I'm just saying that's
- 16:02not what I expected from the model.
- 16:04Probably a misunderstanding on my side.
- 16:06I should have been more specific with
- 16:07the prompt. But overall, it did a good
- 16:09job and it did it very fast. So, all in
- 16:12all, I would say this is a good model
- 16:14and I will probably use it, especially
- 16:16if a speed is something that I care for
- 16:18because according to the benchmarks,
- 16:20it's not beating Claude Opus yet. So, if
- 16:23you want the absolute best quality, this
- 16:24probably isn't the answer. But if you
- 16:26need quality and speed at the same time,
- 16:29this is a better model, especially
- 16:31because in our use case where we give
- 16:33tools to the model, so specifically the
- 16:35MCP tools, it's not just about the
- 16:37quality of the model. So, the fact that
- 16:40the model can run faster, do research
- 16:42faster, that could sometimes cause
- 16:45better results in the end, which is what
- 16:47we care about. Now, I am going to submit
- 16:49this strategy on our strategies page on
- 16:52our website. So, if you haven't checked
- 16:53it out, please do so. There are so many
- 16:55strategies here. You can sort them by
- 16:57sharp ratio and the period and stuff.
- 16:59You can also see the details of those
- 17:02strategy results for other trading
- 17:04periods, symbols, and time frames. So,
- 17:06definitely check it out. You can also
- 17:08copy the source code of these strategies
- 17:10that I just shared with you guys on our
- 17:12website. If you enjoyed the video,
- 17:14please make sure to give it a like and
- 17:15subscribe to the channel if you haven't
- 17:17already because I publish tutorials just
- 17:20like this one all the time. And at the
- 17:21end, let me know your experience with
- 17:23Cloud Code in the comments. Thank you so
- 17:25much for watching, guys. I'll see you in
- 17:27the next time.
About this transcript
This page contains the full transcript of Sonnet 5 + Claude Code strategy makes 369% by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 3,476 words across 480 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.