Optimization 2.0: faster, fasterrr! — Transcript
Full transcript
- 0:00Hey guys, Sal. I just released a new
- 0:01optimization mode and it is
- 0:03significantly faster. Not only that, it
- 0:05also gives us new options and features
- 0:07which are super handy. I've been working
- 0:08on this for months, so I cannot wait to
- 0:11show it to you. So, let's get right into
- 0:12it. So, in front of me, I have two
- 0:14terminals open. On the left side, I have
- 0:16the new version of Jessie, which has a
- 0:18new optimization mode. And on the right
- 0:19side, I have the old one. Now, I did
- 0:21this because I want to run the same
- 0:22strategy using the optimization mode so
- 0:25we can see the differences to compare
- 0:26the two together. Now, one way to
- 0:28recognize the new Jessie is using this
- 0:30new welcoming page, which will print out
- 0:32the Jesse logo really big. Now, of
- 0:33course, this is not going to affect your
- 0:35trading results, but I just thought it's
- 0:36really cool to have. But anyways, let's
- 0:38go to the Jesse dashboard. And notice
- 0:39the one with the port 9,0001 is the new
- 0:41Jesse and the one with the port 9,0002
- 0:44is the old one. So, let's generate a new
- 0:45strategy and we're going to call it
- 0:49optimization
- 0:52benchmark. I will also do the same on
- 0:54the new version of Jesse.
- 0:57Instead of writing a strategy from
- 0:59scratch, I'm going to copy the code for
- 1:01this one from our
- 1:03website. Go back to Jesse and paste it
- 1:05here. I will also do the same thing one
- 1:08more time here. Now, before I forget, we
- 1:09also need to copy the name of the
- 1:11strategy to be this new one. So, let's
- 1:14save it and also do the same one here.
- 1:17All right. So, now we need to update the
- 1:19strategies so that it should be prepared
- 1:21for running the optimization. Now, now
- 1:23instead of preparing a strategy for
- 1:24optimization manually, I'm going to do
- 1:26the lazy way. So, I will just copy it
- 1:29and open JGPT and I will say this one.
- 1:32Prepare my strategy for optimization and
- 1:34I will paste it right here. All right.
- 1:36So, it gave me this one. Let's copy it.
- 1:37Go here and paste it
- 1:40here. All right. So, notice that now
- 1:42instead of hard coding the values for
- 1:44the period of this SMA and this one, we
- 1:46are using the HP which stands for
- 1:48hyperparameters. And here it has defined
- 1:51the hyperparameters function for us
- 1:53which has these two values with the type
- 1:56of int the minimum value being 100 and
- 1:58here being 10 the max being 300 and 100
- 2:01and here are the default values which
- 2:03are the ones that we had hardcoded in
- 2:05the previous strategy code. Now by the
- 2:07way in this one we are only trying to
- 2:10optimize two integer values but we also
- 2:12have support for float values and in
- 2:14fact with the new optimization mode we
- 2:16also have support for categorical type.
- 2:17Now, if you don't know what that is,
- 2:19that's fine. I will show it to you in
- 2:20the end of the video. All right. So,
- 2:21let's pick the optimization mode from
- 2:23within the dashboard. So, again, this is
- 2:25the new dashboard. And the way I know
- 2:27this is because in the previous one,
- 2:29let's actually open it. We only had one
- 2:31duration, but with the new one, we have
- 2:33durations for training period and the
- 2:35testing period. Now, in the previous
- 2:37version, the training and testing
- 2:38periods were being generated behind the
- 2:40scenes for you. So, you only had control
- 2:42over the total duration of the
- 2:44optimization run. But with the new one,
- 2:46you can specify whichever period you
- 2:49want for training and for testing.
- 2:50Another difference is that you can also
- 2:52specify the CPU course to use right from
- 2:54here instead of from the settings page
- 2:56which was how we used it in the past. So
- 2:59in fact, let's update this one to be
- 3:01another number such as 12. And I will
- 3:03leave all the other options to be as
- 3:05they are. All right. So let's also pick
- 3:07this strategy. It is simply called
- 3:09optimization benchmark. And I'm going to
- 3:11choose the 4 hours as a time frame. the
- 3:14route is correct. As for the duration, I
- 3:17will pick until the end of 2024 and I
- 3:21will leave the number of trades as 50. I
- 3:23will also turn on the fast
- 3:25mode. All right, this looks good. Now,
- 3:27let's also go to the new one and pick
- 3:30the
- 3:31same strategy. I will change the time
- 3:34frame to 4
- 3:36hours. We don't need any data routes.
- 3:39As for training period, I will pick 2024
- 3:43until the end of it. But for my testing
- 3:46period, actually just to keep them the
- 3:48same, I want to make sure the testing
- 3:50period of the new dashboard is the one
- 3:52we had for the previous one. So in the
- 3:54previous one, we were using 85% of the
- 3:57data for training and 15% for testing.
- 4:00So approximately that makes this like
- 4:03two months less. So again, let's make
- 4:06sure this one is correct.
- 4:11And this one should also be turn 24
- 4:14since the beginning and until the end of
- 4:17it which in other words would be the
- 4:19beginning of 2025. As for optimal number
- 4:21of trays I will pick the same number 50
- 4:24and as for the CPU course we are using
- 4:28it is set to 12. The fast mode is
- 4:30already on. All right. So first I'm
- 4:32going to run the optimization using the
- 4:33previous version. So let's click on the
- 4:35start
- 4:36button. All right. All right. So, I'm
- 4:37getting this error because I implemented
- 4:40the hobby parameters method on the
- 4:43strategy of the new optimization mode,
- 4:44but I forgot to do the same for the
- 4:46previous one. So, let's also open this
- 4:48one and paste it
- 4:49here. Go back and run it again. All
- 4:52right. So, it began working. And as you
- 4:54can see in the previous version, we had
- 4:56to run the optimization in two phases.
- 4:59The first phase which this one is in
- 5:01right now, we had to generate the
- 5:04initial population and then use that
- 5:06initial population to evolve it and find
- 5:09good parameters. But with the new one,
- 5:11that's not the case. We just begin
- 5:12optimization and begin evolving
- 5:14immediately. And this is because the
- 5:16algorithm behind them. The previous
- 5:17version was written by me and it was
- 5:19using the genetic algorithm. But the new
- 5:21version is using the Optuna library and
- 5:23their algorithms which have been
- 5:26optimized through the years and they
- 5:28work really fast and really good. All
- 5:29right, so it's been about 45 minutes
- 5:31since I started this and we are at
- 5:34nearly 80% and we cannot see the sharp
- 5:37ratio in the previous dashboard, but we
- 5:39can see the training and testing P&L and
- 5:42the total number of trades and the win
- 5:44rate. All right, so let's cancel this
- 5:45one and go to the new dashboard. And
- 5:48again, notice that everything is the
- 5:50same. So, and using again 12 cores of
- 5:53CPU. Let's run this. All right. So,
- 5:56first of all, it's going so fast that I
- 5:59don't think it's going to take more than
- 6:00just a few minutes. It's been 23 seconds
- 6:02and we're already at 34%. We also have
- 6:05this chart here which shows us the
- 6:07objective progress. We also have the
- 6:09ability to change the metrics value
- 6:10here. By default, it is set to whatever
- 6:12you choose in the settings for the
- 6:15fitness function. Now, by default, it is
- 6:17set to sharp and that's the value here.
- 6:20But I could change it into other things
- 6:21such as calma ratio, omega or even the
- 6:24piano. Also, while this is going, we can
- 6:27see here that in the new table, we have
- 6:30the ability to click on this to get more
- 6:32info. So, we can see the parameters, the
- 6:34translated values of it. We can copy the
- 6:37DNA from here. We can also see the full
- 6:39list of the metrics for both the
- 6:41training and the testing period, which
- 6:43allows us to compare all the values that
- 6:45we actually care about. All right, so
- 6:46it's been 59 seconds and we are at 92%.
- 6:49So that one took nearly an hour, but
- 6:52this one finished in about 1 minute. So
- 6:55that's how much faster this new
- 6:56optimization mode is. And you don't even
- 6:58have to copy the DNA, go to the back
- 7:00test, paste it there, just so you can
- 7:02see the translated values or the other
- 7:04metrics. You can simply click on this
- 7:06button and see all the metrics that you
- 7:08actually care about. And again, you can
- 7:09also see the parameters. Now, if you
- 7:11like the values, just like before, copy
- 7:13the DNA value from here. go to the
- 7:15strategy and add a
- 7:17function called DNA which simply returns
- 7:22this string value. Now notice that the
- 7:24new DNAs are a bit longer than the
- 7:26previous ones, but that's perfectly
- 7:28fine. And also in case you're wondering
- 7:30whether you have to update your existing
- 7:32strategies to work with the new one,
- 7:34well, you don't. I made sure that if you
- 7:36enter a DNA with the previous format, it
- 7:38will continue to work so that you guys
- 7:40don't have to update your strategies
- 7:42immediately. But if you use the new
- 7:43optimization mode and get a DNA with the
- 7:45new format, this one will also work. The
- 7:47reason the new optimization mode is so
- 7:49much faster is because we are using
- 7:50first the optuna library which is this
- 7:53one. And second, for doing
- 7:55multipprocessing, we are using the ray
- 7:57library which is super optimized. But
- 8:00there's a caveat. The ray library at the
- 8:03moment of recording this video is not
- 8:04supported on Python 3.13 which is the
- 8:07latest version of Python that we support
- 8:09Jesse on. So if you want to use the new
- 8:11optimization mode, make sure your Python
- 8:13version is nothing more than 3.12. All
- 8:15right. So now that you can see how much
- 8:17faster the new optimization mode is,
- 8:19let's continue so that I can show you
- 8:21the new options that it supports. So one
- 8:23thing is that previously we had the
- 8:26minimum and the maximum values for let's
- 8:28say an integer type that we wanted to
- 8:30optimize. But with the new version, we
- 8:32also have another option called step.
- 8:39So for example we can specify 10 and now
- 8:42it will not try for example the number
- 8:44101 102 it will only increase by 10. So
- 8:49for example 110 120 etc. This by the way
- 8:53was one of the most requested features
- 8:54of JC for the optimization mode. The
- 8:57other thing that's new is the support
- 8:59for categorical type. Now let me show
- 9:01you what that is and how you can use it.
- 9:03So for example here in this strategy we
- 9:06are using the SMA indicator. So what if
- 9:08I wasn't sure whether to use SMA or EMA?
- 9:12I could simply come here and say this MA
- 9:15standing for moving average equals
- 9:19HP MA type. Sorry, this should be
- 9:24self.Hp. All right. And I'm going to say
- 9:27if MA equals SMA, then return this. If
- 9:31it equals EMA, then return this. Now, we
- 9:34don't need all the rest. Now, this one
- 9:36is good practice. So maybe I just keep
- 9:38it here, but you don't need it. All
- 9:39right. So if the MA equals SMA, we're
- 9:42going to return TA. SMA, but if it
- 9:45equals EMA, we will return TA. EMA. So
- 9:48let's copy this one. Come down to the
- 9:51hyperparameters. Now here now I have the
- 9:54option to define a new parameter called
- 9:57MA type. And the type of it well, it's
- 10:00not CR, it should be
- 10:03categorical. And the options are SMA,
- 10:06EMA. Now, they could be as many as you
- 10:08like, of course, but we only care about
- 10:10SMA and EMA. And we also define a
- 10:13default value, which is SMA. All right.
- 10:15So, now let's go back to
- 10:18Jesse, pause, and start a new session.
- 10:21And start it
- 10:25again. All right. So, let's click on the
- 10:27info button. And now, if you check out
- 10:30the parameters, you can see we also have
- 10:32the MA type. And for example with these
- 10:34results we are using the EMA. But if I
- 10:36check another one for this one is also
- 10:40EMA. This one is also
- 10:45EMA. This one for example is SMA. You
- 10:48see? So with this new type, you can use
- 10:50the optimization mode to choose the
- 10:52right indicator for your strategy. Now
- 10:54this can be super helpful and I'm going
- 10:56to leave it to you to come up with all
- 10:58sorts of ideas that you can use it with.
- 10:59All right, so let's pause this one.
- 11:01Again, notice how fast it is going. It's
- 11:03crazy. So, we also have other options.
- 11:05For example, how many trials you want to
- 11:08run per each hyperparameter. Well, that
- 11:10one is now a settings. Now, go to the
- 11:12settings page to the optimization tab.
- 11:14And here you can modify the number of
- 11:16trials you want to run per each
- 11:18hyperparameter. So, for example, if you
- 11:20run optimization and you see that it
- 11:22hasn't yet found a good enough parameter
- 11:24for you, you can come here and increase
- 11:26this number. Or for example, if you
- 11:28found that it has already found a good
- 11:30number and it is just working too hard
- 11:32or maybe overfitting your strategy, you
- 11:35can come here and lower this number. Or
- 11:36if you don't care about it, just simply
- 11:38use the default option. As you just saw,
- 11:40the new optimization mode is
- 11:42significantly faster, which allows us to
- 11:44run the optimization mode whenever we
- 11:46want. We don't have to wait for hours or
- 11:48days for it to finish. Instead, it's
- 11:50going to finish in a few minutes or
- 11:52hours at the maximum. Now, I think this
- 11:54changes everything and how we tackle our
- 11:56strategies altogether. I'm super excited
- 11:58to see what you guys build with it. So,
- 12:00make sure to post a comment and let me
- 12:01know about it. Thank you guys for
- 12:02watching and I'll see you in the next
- 12:04one.
- 12:09[Music]
- 12:10[Applause]
- 12:12[Music]
About this transcript
This page contains the full transcript of Optimization 2.0: faster, fasterrr! by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 2,362 words across 327 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.