Opus 4.8 + Claude Code + MCP = King of Algo Trading! — Transcript
Full transcript
- 0:00In this video, I'm going to show you how
- 0:01to use Claude Opus for 4.8, which has
- 0:04just been released for algo trading in
- 0:06Python. This model is supposed to be the
- 0:09best one that the money can buy at the
- 0:10moment and is supposedly the king. And
- 0:13we're going to use it to write trading
- 0:14strategies, to backtest them, to iterate
- 0:16over them until it improves the results.
- 0:19And not only that, we will also ask the
- 0:21agent to ensure that the entry rules of
- 0:23the strategy that it has wrote for us
- 0:25has some statistical meaning and that
- 0:28they are not pure noise or some lucky
- 0:30results. And in the end, I will also go
- 0:32through my process of running the Monte
- 0:34Carlo simulation in order to decide
- 0:37whether or not the results that I'm
- 0:38getting is good enough for running it
- 0:41live. And before we continue, I got to
- 0:43say I'm not a financial advisor and this
- 0:45video is for educational only. All
- 0:47right, I'm super psyched, so let's get
- 0:49right into it.
- 0:52Now, one question that you need to
- 0:53answer is how you're going to get access
- 0:55to Opus 4.8, because this is one of the
- 0:57most expensive models at the moment and
- 1:00it is not affordable just for everybody.
- 1:02However, my favorite way of using it is
- 1:04through the Claude Code subscription,
- 1:06which give us generous limits. However,
- 1:08we do need to talk about like which plan
- 1:10you need to get. And realistically, if
- 1:12you want to use Claude Opus and not hit
- 1:14the limits like right away, you're going
- 1:16to need the max plan. Now, there are two
- 1:18max plans, $100 and $200. I am on the
- 1:21$100 plan and I couldn't be happier
- 1:24about it. I have never hit the limits
- 1:26and it is perfect. But if this isn't
- 1:28affordable for you, yes, you can go with
- 1:30the pro plan, but chances are that you
- 1:32will hit the limits. Now, there are
- 1:33multiple ways to use Claude Code. One is
- 1:35to use their desktop app and the other
- 1:37is to use it via the terminal. And I'm
- 1:39using the terminal one because I find it
- 1:41to be a little bit faster. So, first
- 1:43things first, we're going to use the
- 1:44Jesse framework for the algo trading
- 1:46part, which will also expose an MCP,
- 1:48which we can use to connect to Claude
- 1:50Code. And the way I'm going to run
- 1:51Claude Code is via the terminal. Before
- 1:53I do that, we're going to have to use
- 1:55the MCP which Jesse exposes. So, if I
- 1:57open my terminal and simply run Jesse
- 2:00run, it's going to start the Jesse
- 2:01dashboard. And here's the address for
- 2:03the dashboard itself and here's the
- 2:04address for the MCP. So, this is going
- 2:06to be the one that I'm going to use.
- 2:07Now, if you check out the documentation
- 2:08for Jesse's MCP under the connect in
- 2:11cloud code, you can see this is the sole
- 2:14command that we're going to have to run.
- 2:16So, inside my terminal, I'm going to
- 2:17have to paste this command. And if you
- 2:18remember, for me, this port was a little
- 2:20bit different because I had changed it
- 2:22inside the .env file of my project. So,
- 2:25it's 9,000. So, it's going to be like
- 2:26this. I've already done this, so I don't
- 2:28have to do it again. And that's it,
- 2:29guys. Now, I am ready to run the cloud
- 2:31code inside the terminal, which is
- 2:33inside the directory which I have Jesse
- 2:35installed. Next, I'm going to ensure
- 2:37that I have selected the Opus 4.0 as the
- 2:40model for this session. Now, before we
- 2:42continue, I want to ensure that the
- 2:44agent is going to follow the agent.md
- 2:47file of my project, which is basically
- 2:49telling the model how to behave. Now,
- 2:51this file is shipped with every Jesse
- 2:53project, and whenever you update your
- 2:55Jesse, it will also update this file
- 2:56automatically. So, you do not need to
- 2:58worry about this much. We can just close
- 3:00it. And here, I'm going to simply attach
- 3:02it to my current session. Next, I'm
- 3:04going to simply say, "Write a trend
- 3:05following a strategy for 2024 on the
- 3:08BTC/USDT
- 3:10market. Once you write the strategy, run
- 3:13execute a rule validation test to ensure
- 3:16the entry rule of the strategy has
- 3:18statistical significance and isn't
- 3:20random noise. If it failed, tell me
- 3:22about it and then continue iterating
- 3:24over the entry rules until you get it
- 3:26right. Once it does pass the test, run a
- 3:28backtest on it and show me the results."
- 3:29So, here's the thing, guys. I'm not
- 3:31asking the agent to do everything all at
- 3:33once. I could simply tell it to continue
- 3:36iterating over until the backtest also
- 3:38looks great on that period. But, I'm not
- 3:40going to do that because I want to show
- 3:41you how you can utilize this agent thing
- 3:44to develop your own strategies
- 3:45step-by-step. So, even if you, for
- 3:47example, don't really know what a
- 3:48backtest is, or if you're not getting
- 3:50good results in the backtest and you're
- 3:52wondering what to do next, we can still
- 3:54use this thing. All right, let's hit
- 3:55enter and see what it does. All right,
- 3:56so it decided to create a Donchian
- 3:59breakout strategy plus the EMA for the
- 4:02trend and it's saying that the long
- 4:03entry is going to be whenever the candle
- 4:05closes above the prior breakout period
- 4:08high and the close is bigger than the
- 4:10current trend period using the EMA. It's
- 4:13creating the significance test. It's run
- 4:14it and it says that it's passed. So, the
- 4:16P value is almost zero, so it is
- 4:18definitely less than this value which is
- 4:20our threshold, which means that the
- 4:22entry rule does indeed have statistical
- 4:24significance. And here's what I meant
- 4:26earlier. Even if you do not know how to
- 4:28read the results of a significance test,
- 4:31you can read the guidelines that the
- 4:32agent wrote for you. So, for instance,
- 4:34it's telling me that the Donchian
- 4:36breakout plus EMA trend entry is not
- 4:38random noise. It beats every one of the
- 4:412,000 random entry variants. So, because
- 4:44it did this, we can conclude that the
- 4:46entry rule of the strategy was not
- 4:48random noise. Now, if you do not
- 4:50understand how this test works, that's
- 4:51okay. I'm going to create a video about
- 4:53it in the future, but for now, what's
- 4:55important is you learn how to use it and
- 4:58the fact that even if you do not know
- 5:00that, the agent is able to do it for you
- 5:02is absolutely amazing. Next, you can see
- 5:04that the model did the position sizing
- 5:06of the strategy because you see so far
- 5:08it only had to written the entry rule of
- 5:10the strategy. It's only after this,
- 5:12after ensuring the entry rule is not
- 5:15pure noise and it does have some edge,
- 5:17that's when it decided to continue to
- 5:19write the position sizing and the exit
- 5:21rules of the strategy. Next, it is
- 5:23creating the back test for BTC on the
- 5:2630-minute time frame for the full year
- 5:28of 2024. It is running the back test. It
- 5:30keeps checking the results and then it
- 5:32says the results already and here we
- 5:35should be able to read the results. Now,
- 5:36by the way, it is also writing a report
- 5:39inside this file. So, even if you want
- 5:41to see what exactly the model did later
- 5:43and you lost access to these logs, you
- 5:45can absolutely do that. All right, so
- 5:47here is the results for that rule
- 5:49significance test again, and here's the
- 5:51full backtest results. So, we can see
- 5:53the net profit is absolutely negative.
- 5:55The total trades is a huge number, 208,
- 5:58and the average win to loss ratio is
- 6:002.20, which is typical in a
- 6:03trend-following strategy. All right, so
- 6:04the results are negative so far. So,
- 6:06let's see if we can ask the model to
- 6:08improve it. It's also giving me its
- 6:10honest takeaway, which is really nice.
- 6:12And this is actually an an important
- 6:13thing, which is strategies in trade has
- 6:16an edge, it doesn't mean that the
- 6:17strategy is going to print money. In
- 6:19this case, for example, the strategy is
- 6:21actually losing money because the
- 6:22strategy is executing too many trades.
- 6:25Now, this is a classic thing in
- 6:26strategies, and whenever this happens,
- 6:28usually I add a couple of filters in
- 6:30order to improve the results and, you
- 6:32know, take the less amount of trades and
- 6:34pay less amount of trading fees. Now, in
- 6:36the end, it's actually asking me if I
- 6:37want to iterate the full strategy in
- 6:40order to improve the results. And that's
- 6:41exactly what I want to do, so I'm going
- 6:43to ask the model to do that. Please
- 6:44iterate over the results three more
- 6:46times and try to improve it, and then
- 6:48compare the results and show them to me
- 6:50to see which one it looks better. And
- 6:51whenever you do, first run a
- 6:53significance test to ensure that new
- 6:55iteration not pure noise, and it does
- 6:57have an edge before continuing to the
- 6:59backtest. All right, so while this is
- 7:00going, let's take a look at here. So,
- 7:02the strategies folder, we can see a new
- 7:05strategy I've been created called BTC
- 7:07Trend 30 minutes, and inside it we have
- 7:08this init file, which is where I define
- 7:11the properties of the strategy. You can
- 7:13see how it defined the Donchian Channel,
- 7:15trend EMA, the ATR. Here are the entry
- 7:18rules of the strategy. So, for example,
- 7:19for the short long, it's simply saying,
- 7:21"I'm going to go long whenever the
- 7:23closing price is above the prior high,"
- 7:25which it is using the Donchian Channel
- 7:27again, "and the current closing price is
- 7:29above the current trend EMA value." For
- 7:32a short entry, it's doing the opposite.
- 7:34And here we can see how it's doing the
- 7:36position sizing. So, it's simply saying
- 7:38that for the entry, I want to use the
- 7:39current price, which is a market order.
- 7:41For the stop, it's using the current
- 7:43entry minus the current ATR multiplied
- 7:46by a stop ATR multiplier. So, let's see
- 7:48what this value is. Okay, so by default
- 7:50it is set to two. And next for the
- 7:52quantity, it is using the risk to
- 7:53quantity utility function of Jesse. It's
- 7:55passing the current available margin,
- 7:57the risk percentage, which it has set to
- 7:592%, and the entry, the stop price, which
- 8:02we calculated here, and then it is
- 8:04setting the fee price. So, this is
- 8:05absolutely correct. Then it is
- 8:06submitting the buy order using the
- 8:08quantity and the entry, and it is also
- 8:10submitting the stop loss here. Now, it
- 8:12did not need to define this since we are
- 8:13using a market order, so there's not
- 8:15going to be any cancellation for the
- 8:17entry. And then the update position
- 8:19function, which is what we execute
- 8:20whenever a new candle closes while we
- 8:23have an open position. So, it's saying
- 8:25that if it's a long position, the exit
- 8:27price is going to be the Donchian
- 8:29Channel's lower band, and if the closing
- 8:31price is below that, then we want to
- 8:33liquidate the current position. And for
- 8:34a short position, obviously it's doing
- 8:36the opposite. That's it. So, this is
- 8:37pretty simple a strategy, and I would
- 8:39say a classic one. All right, let's take
- 8:41a look at what the agent did so far. So,
- 8:44it looks like it defined three variants,
- 8:46so it's calling them V2, V3, and V4.
- 8:48Next, it is also comparing the results
- 8:50of their RST test, which again is a rule
- 8:53significance test, and all of them are
- 8:55passing. Now, by the way, if you take a
- 8:57look at this value here, you can see the
- 8:59analyzed return of them are different,
- 9:01but I wouldn't necessarily say that like
- 9:04one is better than the other because of
- 9:06this. Okay, so all that I need to see
- 9:08with the RST test is whether or not the
- 9:10strategy's entry has some edge, so I can
- 9:12continue to define the exit rules of the
- 9:15strategy. That's it. Because if it tells
- 9:17me that it doesn't, it could just mean
- 9:19that my entry rules are just some lucky
- 9:21guess. So, for example, if I have a
- 9:23strategy that always goes long, of
- 9:25course during a bull run it's going to
- 9:26make me money, but it doesn't mean that
- 9:29it does actually have some predictive
- 9:31power. All right, it finished the
- 9:32results, and here's again the table for
- 9:34the RST test, and here's the table for
- 9:37the backtest results. And we can see
- 9:39this comparing the V1 of the strategy,
- 9:41V2, V3, and V4. So, four different
- 9:43variants. It's telling me which one
- 9:45looks better. So, the variant three is
- 9:47actually profitable. It has a sharp
- 9:49ratio of 2.11, which is absolutely
- 9:51amazing. The max drawdown is only minus
- 9:5417%, which is great. The number of
- 9:56trades is 86, which actually makes a lot
- 9:58of sense. The win rate is low, which
- 9:59makes sense for a trend following
- 10:00strategy, especially if the average win
- 10:03to loss ratio number is high. Which we
- 10:05can see here, it is near four. So, of
- 10:07course, this makes sense. And here's
- 10:09another cool thing that was added to
- 10:10Jesse's MCP recently. After it is done,
- 10:13it will also print out the URL to the
- 10:15dashboard. So, for example, for the V3,
- 10:17I can click on this URL, and it will
- 10:19open the dashboard of Jesse, so I can
- 10:22look at some charts. So, for example,
- 10:24here's the equity curve. Here's a log
- 10:25scale version of it, and here is the
- 10:27five worst drawdown periods of the same
- 10:30strat. And here is the monthly returns
- 10:31of the strategy. So, as you can see,
- 10:33even though it is doing absolutely
- 10:35awesome in three months, in some other
- 10:37months, it's actually negative, which is
- 10:39a typical thing with a trend following
- 10:40strategy. You can see the agent is also
- 10:42writing some summaries of like what the
- 10:45strategy's intro rules are about, what
- 10:47it's doing, and things like that. And if
- 10:49I want to, I can also click on this and
- 10:51view the interactive charts. So, for
- 10:53example, I can take a look at the trades
- 10:56that we took. So, for example, in this
- 10:57one, if I click here, it will take me to
- 10:59when the position was opened and when it
- 11:01was closed. So, as you can see, yes,
- 11:03this was a clear uptrend moment. And it
- 11:05makes sense that in these one, it's just
- 11:07losing money because this is a ranging
- 11:08period. Let's take a look at another
- 11:10one. So, this one, for example, it went
- 11:12long here, and it closed it here. Let's
- 11:15take a look at the losing one, such as
- 11:16this one. So, you see, it opened it
- 11:19here, but it closed it here. And by the
- 11:21way, because it opened at the closing
- 11:23price of this candle and at the closing
- 11:25price of this one, so that's why we
- 11:27actually lost money. Because if we had
- 11:29entered it here and closed it here, it
- 11:31would have been a tie, or maybe a small
- 11:33win. All right, so back to the terminal.
- 11:35So, it's telling me that the V3 actually
- 11:37wins. It has the highest net profit and
- 11:39the best risk-adjusted metrics such as
- 11:41the sharp ratio. So, it basically
- 11:43concluded everything that I just said.
- 11:44So, even if you do not know how to read
- 11:47a sharp ratio, the agent does. Now, by
- 11:49the way, the strategy that it wrote
- 11:51actually looks really good. So, I'm
- 11:53happy with the results of the Opus 4.8
- 11:55model so far. And it's also telling me
- 11:57what fixed it results. So, what actually
- 11:59fixed it is that the entry was never the
- 12:02problem. So, the RC proved it every
- 12:04time. We won blood out from shorts in a
- 12:07bull year. A two-tight exit plus fee
- 12:09drag. Removing shorts and widening the
- 12:11exit flipped from this value into a
- 12:14positive one. A slower candle breakout
- 12:16added the rest. However, as you probably
- 12:18know, we cannot trust the results of the
- 12:20backtest just yet and go to live trading
- 12:23with it. We also need to run a Monte
- 12:25Carlo test at the very least, of course,
- 12:27to make sure the results of the strategy
- 12:29is not overfit. And in fact, that's what
- 12:31the agent is also telling me. So, one
- 12:33honest caveat. 2024 was a strong
- 12:35uptrend, which flatters a long-only
- 12:37trend follower. Want me to Monte Carlo
- 12:39V3 overfit check and validated out of
- 12:42sample on 2023 and 2025 before you start
- 12:45these numbers. Now, we could ask the
- 12:47model to also run the Monte Carlo, and
- 12:49that's exactly what I did, but there was
- 12:51a problem with it. So, I'm going to try
- 12:53running it manually on the dashboard of
- 12:55Jesse. So, here's the exchange that I've
- 12:56chosen, the BTC USDT route, and let's
- 13:00change this into 30 minutes. I have
- 13:02chosen the BTC trend 30 minute V3
- 13:04strategy, which is what the agent made
- 13:06for us, and I have picked the entire
- 13:082024. Now, we are ready to start the
- 13:11Monte Carlo test. So, the Monte Carlo
- 13:13trades is over. So, this one is always
- 13:16really fast, and what it basically gives
- 13:18us is what would have happened if the
- 13:20order at which we took the trades were
- 13:22different. So, for example, if instead
- 13:24of beginning with the winning trades, if
- 13:26we had with losing ones. Like, if that
- 13:28was the case, what would have been the
- 13:30max drawdown of the strategy? And in
- 13:32that case, were we prepared for it? So,
- 13:34basically, this is for the position
- 13:36sizing of the strategy. And it's telling
- 13:38me that in the worst 5%, my max drawdown
- 13:41would have been minus 23%. But, in the
- 13:43original backtest, it was only minus
- 13:4517%. We could have also been luckier,
- 13:47like in the best 5%, and in that case,
- 13:50it would have been minus 8.5%.
- 13:52But, the thing that I really want to
- 13:53know is the Monte Carlo candles, which
- 13:55is where we execute a Monte Carlo
- 13:57simulation by using synthetic data,
- 13:59which has been created based on the
- 14:02original data of the market. So, this
- 14:04one is basically like a stress test for
- 14:07the strategy in order to see how robust
- 14:10it is, which also tells us whether or
- 14:11not it is overfit or not. So, as you can
- 14:14see, this one's taking longer, which
- 14:15makes perfect sense. Now, while that's
- 14:17going, I want to quickly remind you guys
- 14:19about our Telegram. It's the fastest way
- 14:21to get notified about my future work,
- 14:23whether it's a new tutorial or that I
- 14:25create. Also, don't forget to check out
- 14:27our free Discord, where more than 5,000
- 14:29members like you and I are hanging out
- 14:31there and helping out each other with
- 14:32algo trading, so we can all succeed
- 14:34together. The links for both are down in
- 14:36the description. All right, the candles
- 14:37Monte Carlo is over. Here, we can see
- 14:40the chart. The yellow line is the
- 14:42original backtest, and these blue lines
- 14:44are the simulations. Now, the fact that
- 14:46the original backtest lines is almost in
- 14:48the middle is a good sign. If we take a
- 14:50look at the results table, we can see
- 14:52that the original backtest sharp ratio
- 14:55was 2.48, while the best 5% was 3.41.
- 14:58And the fact that this one's lower than
- 15:00this is a good sign. So, I wouldn't say
- 15:02the results are overfit. However, the
- 15:05median number is 1.87, and this one is
- 15:09lower than the one for the original
- 15:11backtest. So, the original backtest
- 15:13results is somewhere between these two
- 15:15numbers. So, again, I wouldn't say it's
- 15:17overfit, but I wouldn't say it is like
- 15:19super robust, either. So, that's it,
- 15:21guys. This is how I personally read the
- 15:23Monte Carlo results in order to take a
- 15:26guess at whether or not the results of
- 15:29the strategy are going to be as good in
- 15:31the live trading as what I'm seeing in
- 15:33the back test. However, let's go to the
- 15:36history because I want to show you the
- 15:38results of the week three in 2024. And
- 15:42also, I'm going to add two more. So,
- 15:45this one being in 2023. Let's ensure the
- 15:49fast mode is on. I don't need the
- 15:51interactive chart anymore.
- 15:53All right, so let's run this. And I'm
- 15:55going to run another one this time for
- 15:572025. So, let's run it. There we go. So,
- 16:00here's the result for 2023. And as you
- 16:03can see, again it is profitable. So,
- 16:05it's making 62%. All right, so let's go
- 16:08to 2025. The strategy is falling apart
- 16:10if we are not in a clear uptrend. This
- 16:13by itself could be enough reason to not
- 16:16jump into trading this strategy live
- 16:18yet. I would personally say that it is
- 16:20not ready for production and it needs
- 16:23further work because even if you are not
- 16:25in a clear uptrend, I would prefer the
- 16:27strategy not to at least lose a lot of
- 16:29money in that period. Or of course, we
- 16:30could also develop a short only strategy
- 16:33to run besides this one to make up for
- 16:35the losses of this one. Now, I am going
- 16:37to submit the result of the strategy to
- 16:40our strategies page where you can see
- 16:42and browse other strategies that I've
- 16:44developed before. If you click on them,
- 16:46you can see the results of their metrics
- 16:48on different periods and symbols or time
- 16:50frames. So, feel free to check out that
- 16:52page as well. And that's it, guys. I
- 16:54hope you enjoyed this video and the
- 16:55experiment that we just did. And don't
- 16:57forget that the whole point of this was
- 16:59not to give you one strategy. It was to
- 17:01give you a tool which can save you
- 17:03countless hours when developing and
- 17:06evaluating your own strategies. All
- 17:08right, let's pick the winner from the
- 17:09previous video. The winner is as always
- 17:11solid. Thank you so much for your
- 17:12comment. Please reach out to me so I can
- 17:14send you your bank tokens. Thank you so
- 17:16much for watching. I'll see you in the
- 17:17next one.
- 17:22>> [music]
About this transcript
This page contains the full transcript of Opus 4.8 + Claude Code + MCP = King of Algo Trading! by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 3,720 words across 506 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.