Build your own AI for algo-trading with Python — Transcript
Full transcript
- 0:00Hey guys, so in this video I'm going to
- 0:02show you how to create your very own AI
- 0:04quant to help you write algo trading
- 0:06strategies with Python. With this setup,
- 0:08you'll be able to use whichever LLM
- 0:10model that you like, whether it be
- 0:12locally, such as the ones Olama provides
- 0:15for us, or the ones that are
- 0:16cloud-based, such as OpenAI or Cloud
- 0:19Sonet. Now, by the end of this video,
- 0:20you're going to have a setup that can
- 0:21help you write strategies, debug them,
- 0:24or even improve the results of it. So,
- 0:26it's going to be really cool. So, let's
- 0:27get right into it. In case you didn't
- 0:28know, recently I released the second
- 0:30generation of our own Jesse GPT. With
- 0:33the new model, you can use whichever
- 0:34model that you like, such as the Gro 3,
- 0:37GPT 4.1 or 3 Mini, or even the Deep Seek
- 0:41Chat or Cloud Sonnet 3.7. Now, if you
- 0:43want to use this one, simply sign up and
- 0:45you'll be able to use it. It has both a
- 0:47free and a premium plan. Now, of course,
- 0:49for more expensive models, you're going
- 0:50to need a premium plan. But here's the
- 0:52thing. Let's say you don't want to use
- 0:53this because of a privacy concern or
- 0:55maybe you don't like our pricing and you
- 0:57think it's too expensive. Well, that's
- 0:59when this new setup that I'm about to
- 1:00show you is going to be really helpful
- 1:02for you. We can do this setup in a
- 1:04couple of ways. You're going to need a
- 1:05software or whichever kind of
- 1:07application that allows you to use local
- 1:09models or to use the API keys of third
- 1:12party cloud providers. Now, the one that
- 1:14I use is called Jan.ai, which is pretty
- 1:16cool. It is open source and completely
- 1:18free and they provide installations for
- 1:21all the three major operating systems.
- 1:23Simply go to the download page and get
- 1:24the one right for your operating system.
- 1:26The setup is really easy, so I'm not
- 1:27going to walk you through it. Now,
- 1:28another really cool project that I found
- 1:30is called Open Web UI. It is completely
- 1:32open source and it allows you to do just
- 1:34the same thing, but I found the setup
- 1:36for this one not to be as easy as
- 1:38Jan.ai. So, I still suggest to go with
- 1:40that one. Now, once you install Jan.ai,
- 1:42I you're going to see a page like this
- 1:43which allows you to look for the model
- 1:45that you want to download. So let's say
- 1:47I want to get the llama tree model for
- 1:50example, right? I can simply look for it
- 1:52here and click the download button and
- 1:54it will be ready for me to use. It will
- 1:56even guide me to know which models I can
- 1:58run and which ones I can't. But the
- 2:00thing is you're not going to get the
- 2:01same kind of quality with local models
- 2:03that you're going to get with the edge
- 2:05cloud models such as gro or cloud set.
- 2:08So what we're going to do is to use the
- 2:10API key of these services. Now to
- 2:12generate an API key, you can use
- 2:14platforms such as Antropic or OpenAI
- 2:16directly. However, if you do that way,
- 2:19you're going to be limited only to the
- 2:20models that they offer you. But if you
- 2:22use another platform such as Open
- 2:23Router, you'll get access to all sorts
- 2:25of models. And the thing is, we have a
- 2:27new model like every week these days. So
- 2:29I think the best option is to actually
- 2:31go with this solution. So I'm going to
- 2:32show you how to do it with open router.
- 2:34Now I already have an account here. If
- 2:36you don't simply sign up, it doesn't
- 2:38even require anything. And one really
- 2:40cool thing about open router is that it
- 2:42actually allows you to charge your
- 2:44account using cryptocurrencies. Now, to
- 2:45me, that's really great because I won't
- 2:47have to give them my credit card
- 2:49information. All right. So, assuming you
- 2:50already have charge your account from
- 2:52the credits page. To create an API key,
- 2:54simply go to the keys page. And here you
- 2:56can see I've already created two API
- 2:58keys. And to create a new API key,
- 3:00simply click on this button. Give it a
- 3:02name. It could be anything you want. I'm
- 3:03going to name it YouTube test.
- 3:06And we can even specify a limit for it.
- 3:09Now I'm going to give it $1. Click on
- 3:11the create. And here's the API key that
- 3:14it has given me. Copy it. And now go to
- 3:16the Jan AI. Go to the settings page. And
- 3:19here you can see we have all sorts of
- 3:21options. Now I'm going to find the open
- 3:23router. And here I can paste my API key.
- 3:27Once you do that, you can simply add
- 3:29model. Click here. Go back to the open
- 3:31router to the models page. And here look
- 3:34up the model that you want. Now, as it
- 3:36happens, last night OpenAI released
- 3:38offer mini model. So, let's click on
- 3:40this one and copy the unique ID of that
- 3:44model. Go back to the NAI and paste it
- 3:47here. Click on add. And now, if I scroll
- 3:49down, I should be able to find it. So,
- 3:51now I should be able to find the key of
- 3:53the model that I just added. But here's
- 3:55the thing. I already have some credits
- 3:56left on my Antropic account. So, I'm
- 3:58going to use this one. Now, to start a
- 4:00new chat, go to the thread section.
- 4:03Click on the new button if you don't
- 4:05already have one. And here we can see
- 4:07the instruction section is empty. Now we
- 4:09can start chatting with it. So for
- 4:11example, I can ask it to write a golden
- 4:13cross strategy for me. Now if I press
- 4:15enter, you can see it immediately begins
- 4:18writing the code for me. But first it is
- 4:20explaining what a golden cross strategy
- 4:22is. What are the entry or the exit
- 4:24rules? And the code that it is giving
- 4:26me, it is already in Python. But this
- 4:28isn't really practical. I'm not going to
- 4:30be able to run a back test on this. And
- 4:33even if I do, it definitely won't be
- 4:35accurate. And even if it was accurate, I
- 4:37wouldn't have been able to run it live
- 4:39and actually make some money with it.
- 4:40Right now, what we need is a setup that
- 4:42can write the code using the Jesse
- 4:44framework syntax. Then we'll be able to
- 4:46run back tests, import data, optimize
- 4:49it, and even run it to live. Now, to do
- 4:51that, I'm going to use the exact
- 4:52instructions that I used to build a
- 4:54Jesse GPT on our website. Now again if
- 4:57you don't want to go through with the
- 4:58setup just sign up and use it as it is.
- 5:01You can even get it started for free.
- 5:03But again we need the instructions. Now
- 5:05where can we find it? Well I open
- 5:07sourced it on GitHub. So you can find
- 5:09the repository under our organization
- 5:12and it is called GPT instructions. You
- 5:15can also use this URL which I'm going to
- 5:16put down in the description section of
- 5:18the video. All right. So here's the
- 5:19readme file. But what I'm interested in
- 5:22is this instructions.mmd file. So click
- 5:24on it. Then click on the row so that we
- 5:27can copy and paste
- 5:29everything. Now by the way notice that
- 5:31this is a giant file. It has all sorts
- 5:34of strategy examples. It has a summary
- 5:37of the whole documentation of Jessie
- 5:38framework. So that's why it's really
- 5:41long which is also another reason why
- 5:43it's best to use a cloud version because
- 5:45if you try to use a local model with
- 5:48this much instruction at least the
- 5:50initial request is going to be really
- 5:52slow. So select all of it, copy it, and
- 5:55go back to jan.AI and paste it here. So
- 5:58now the instructions is not empty
- 6:00anymore. Now let's say I want to see the
- 6:03result of it for this exact request that
- 6:06I made here. Write me a golden cross
- 6:07strategy. So I can just go down and
- 6:09click on the retry button
- 6:11here. Now notice the strategy that it is
- 6:14writing for me this time has the exact
- 6:16syntax of the JC framework. It is
- 6:19Python. It's also much cleaner. So,
- 6:22here's a fast moving average, a slow
- 6:24one. Here are the inter rules of the
- 6:27strategy. Here's the position
- 6:30sizing.
- 6:32And here's when to liquidate the
- 6:34position. It also gave me a very short
- 6:36description of the strategy, but not too
- 6:38much. So, and that is the result of this
- 6:40instruction. I asked it to give me the
- 6:42code, nothing more, nothing less. Now,
- 6:44let's say this is good, but I wanted to
- 6:46add, let's say, the ADX indicator
- 6:48because I want to filter some bad trades
- 6:50because the thing with the trading
- 6:51strategy is that it tends to take too
- 6:53many trades and the trading fees usually
- 6:55eat our profits. So, I'm going to ask it
- 6:57to do that. If I press
- 6:59enter, all right, so it gave me the
- 7:02exact strategy, but this time it is also
- 7:05using the ADX. And inside my entry rule
- 7:09of the strategy, I can say it is
- 7:10checking to see if the trend is strong
- 7:13enough by saying whether or not the
- 7:15current ADX value is above the number
- 7:1725. Now, of course, I could also ask it
- 7:19to modify that number if I need to or
- 7:21even to prepare the strategy using the
- 7:24syntax for optimization so that we can
- 7:27find this number dynamically which would
- 7:29save us a lot of time. Now if you want
- 7:31to know what other types of things you
- 7:33can do with it, a good example is to
- 7:35look at the Jesse GPT page on our
- 7:37website here. The first one is asking it
- 7:39to write a golden cross strategy. The
- 7:41second one says prepare my strategy for
- 7:44optimization because I find the task of
- 7:47replacing some of the parameters of the
- 7:49strategy with the syntax that is
- 7:51required for Jessie sometimes to be a
- 7:53tedious task. But when I ask the AI to
- 7:55do it, it's really easy for it and it
- 7:57does it immediately. Even the smallest
- 7:59and cheapest model can take care of this
- 8:01type of task very good. I can also ask
- 8:03it to prepare my strategy for live
- 8:05trading because I want to make sure that
- 8:08the monitoring stuff are in place. I can
- 8:10also ask it to suggest other indicators
- 8:12to improve my already existing
- 8:14strategies. You get the idea. Just check
- 8:15out this page and you'll see all the
- 8:17tips and the latest stuff that I come up
- 8:19with. And if you can come up with some
- 8:21stuff that I haven't, let me know and
- 8:23maybe I add it to this page. But that's
- 8:25not all. Because all the instructions
- 8:27are here, you can easily customize it
- 8:29however you like. So let's say there's a
- 8:31syntax here that you don't like. It
- 8:33works for me, but for whatever reason,
- 8:35you want to improve it. Go nuts. Just
- 8:37maybe copy this whole file inside your
- 8:39editor of choice, such as VS Code, and
- 8:41add a section to it or modify an
- 8:44existing one. In fact, if it was really
- 8:45good, maybe submit a pull request to our
- 8:47repository, and I'll merge it so that
- 8:49the others can use it and take benefit
- 8:51from it. Another really cool thing that
- 8:52you can use this setup for is to convert
- 8:54the existing strategies on trading view
- 8:57which uses this syntax called pine
- 8:59script into python so you can back test
- 9:01it with Jesse. Now to do that we can
- 9:04simply look for now you can find them on
- 9:05the trading view website but another way
- 9:07is to simply search for it. So I'm going
- 9:10to say EMA
- 9:13strategy and there are so many of them
- 9:15but this one for example is using MACD
- 9:18and EMA. So let's click on it.
- 9:25Now you can see the result of the back
- 9:27test of trading view which by the way is
- 9:29not accurate. So never count on this.
- 9:32Trading view is great for charting but
- 9:34it is not for back testing. For back
- 9:36testing you want to use something
- 9:37accurate such as Jesse. But anyways if
- 9:40the strategy is profitable enough we can
- 9:43use this code. Just simply go here to
- 9:46source code and here it is. Now I can
- 9:49copy the entire thing. I can go back to
- 9:52Janai and create a new thread. And
- 9:54notice that the instructions are still
- 9:56here. But if they weren't, make sure to
- 9:58copy and paste them again. And I can
- 10:01simply ask it convert this
- 10:06strategy into Python code and then paste
- 10:10the whole thing. And now it's giving me
- 10:12the Python code. I can copy this whole
- 10:15thing, go to the JC framework and back
- 10:17test it with Python, which allows me to
- 10:19see the actual result of the strategy,
- 10:21not the fake ones on threading view.
- 10:23Now, by the way, they aren't really
- 10:24fake. It's just that it isn't accurate
- 10:26enough, especially in most cases, it has
- 10:29the issue of the look ahead bias, which
- 10:31in Jesse doesn't exist. All right, the
- 10:33possibilities are endless here. You can
- 10:35use everything locally on the cloud or
- 10:37use just GPT on our website. It doesn't
- 10:39really matter. I open sourced this setup
- 10:42because my goal for creating Jesse GPT
- 10:44was not to make money on top of it. I
- 10:46just wanted you guys to be able to do
- 10:47research faster and use Jesse more
- 10:50frequently. Especially for those who
- 10:52aren't even great with Python, this
- 10:54enables them to start a good trading
- 10:57today rather than months later. So, I
- 10:59hope you enjoyed this video. Thanks for
- 11:00watching and I'll see you in the next
- 11:02one.
- 11:07[Music]
- 11:08[Applause]
- 11:11[Music]
About this transcript
This page contains the full transcript of Build your own AI for algo-trading with Python by Algo-trading with Saleh, generated from the public captions YouTube serves with the video. The transcript has 2,344 words across 313 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.