How To Use OpenAI to build a Trading Bot (ChatGPT ai)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'm going to show you how to use open AI to build trading Bots so open AI just released their chat gpt3 and I've been playing around with it for the last couple weeks and it's actually pretty good at coding so in order to build trading Bots you usually have to code them but don't worry you don't have to be like a super genius or anything in order to code especially now that we have ai to help us out now I want to go ahead and show you exactly how to use openai to build these trading bots so you can automate your strategy now we'll go ahead and do a simple example in this video just to start out light but I have much more in-depth trading Bots inside of uh boot camp I put together there's a link for that below but I want to really focus on giving you as much value as possible in this video here so we're going to go ahead and show you exactly step by step if you have like a strategy say it's to buy when it crosses the 20 moving average or sell when the price is going down and crosses the 40 moving average or sell when it bounces up to the view off whatever it might be I'm sure you have a good strategy in mind and I just want to be here to encourage you that even if you don't know how to code you can figure this out because trading is not easy and coding is just another skill just like trading so what I want to go ahead and do is show you the power of open Ai and gbt3 to help you on your coding journey in order to really algorithmic trade and it's going to be fun so what I'm going to do here is first try to explain a strategy just a simple strategy that we can build let's say with python and ccxt build a strategy that buys Bitcoin when the price is over let's say is over the 20 SMA and then sell Bitcoin sell when the price drops under the the 40 SMA so let's say is over the 20th of May then hold then hold for five days and then sell when the price is under the 40 SMA so this is like the 40 SMA the red right here it's actually the 41 but close enough so we want to buy when the price goes above this green line which is the 20 SMA and then we want to hold for five days and then when the price comes under the the 40 SMA which we're going to give it five days here to get over it once it goes under it then we will sell so we would have to look at the daily I'm looking at the 15 minute right now and you can see price recently went over the 20 SMA but then we give it four five full days in order to go back under or to go over the 41 estimate and from there if it drops back down we would sell so that's the strategy and let's see which app GPT can give us so let's go ahead and make this a little easier to read and let's go ahead and see what chat gpt3 can do from open AI so with python and ccxt build a strategy that buys Bitcoin when the price is over the 20 SMA and I'm gonna just make it a little easier simple moving average then hold the Bitcoin for a minimum of five days then sell when the price drops under the 40 SMA so I'm telling it to use Python code with python code with python and ccxt ccxt is essentially how we connect to the exchange then we want to build a strategy that buys Bitcoin when the price is over the 20 SMA and let's see what how it works see if it does anything good for me and I'm going to pull up my code here just so I can test it all I'm going to import my don't share config import don't share config I'm going to import ccxt oh it's using bit from fin okay I want to try this again you can see it's writing code though this is amazing so you can see it actually created the SMA it checks the sma-20 wow this is amazing so it goes ahead and says price Exchange gets the ticker price here which is correct let's see if we can make this a little bigger for you okay that's a little bigger you can see it gets the price retrieve the current price it calculates the 20 SMA using a rolling window of 20 so it says SMA 20 grabs the rolling window and gets the mean which is perfect now if the price is over the 20 SMA it creates the order exchange create Market order and then we hold for five days you can use a timer or date comparison looks like it didn't build that part but then it says if price is under the 40 SMA then we sell okay so I want to change a couple things so I'm gonna I'm gonna say hey um change the above code in order to work with themex using ccxt because that is what I want to do let's see if it changes it for us so import ccxc import pandas's PD exchange ccxt.themax okay this is great and then we're going to test this out so let's go ahead and pull in some of this code and just test it out with chat GPT and see how this goes it also looks like it's not building out the timer part so I'd be interested to see how it would want to implement that but let's go ahead and test some of this code just to see how powerful it is I'm pretty amazed because a lot of this will just take you know I would say maybe you take an hour or something to create by hand and we just did it in like a few seconds now it did miss one part which is holding for five days but I think if we work on this with it and keep asking more questions like hey how would I build a function to hold for five days I think we could actually do it so while the first run I wouldn't say it's perfect but we can definitely get some good value out of this let's go ahead and import these two lines so exchange equals ccxt dot femex you know it forgot to put in the keys so I need to add the keys here and let's go ahead and do that just really quickly so to add my keys pretty easy to do I'm going to go ahead and just copy paste from my other one you can see what it did is it initialized ccxt.themax perfectly but then it just didn't add this part because it probably doesn't have well it obviously doesn't have my API keys and I just set it up through a don't share config so I don't share it on YouTube but essentially you could put your keys in like that without this part and your secret in like that as well and you should be connected to the exchange so that's pretty good it was able to look up the documentation for getting the keys I could probably say what is the function or how can you show me how to connect to ccxt with can you edit the code can you edit the code above in order to use my key and Secret to connect to The Exchange to Phoenix let's see if it goes ahead and gives me an example certainly to use your API key in secret you build a Constructor and this is how you do it so import ccxt API okay this is how they're doing it and this is exactly what I did as well as you can see here I just made that edit and this is what's cool about it you can keep talking to it and it just made an edit and now it's going to redo the whole code so as you can see my highlighted part is here and this is exactly what they did now you can't see this part because I had to hide it into another file called don't share config but the thing that I want to do next is like can you write out this part of code you add this part of code that you missed above and then what did it say it said hold for at least five days let's see how smart this is hold for at least certainly here's an example of how you can modify the code to hold the BTC for five days okay look at this and now they import time so I'm going to import that one as well this is pretty amazing because it's like talking to an engineer right so first time through there like hey you could do it this way but I actually didn't write the code second time through I asked them to to figure out the key situation and look at this look at my API key like I've done this in the past by hand it goes and looks at the docs and figures out how to do that so this is quite impressive and then look at this right here it went ahead and now updated the ex the the function to say hold for five days so off the top like my first description here it didn't do it perfectly but then after I talked to it a little bit and added some feedback it went ahead and built a pretty solid algorithm now is this an algo that's gonna be profitable probably not but it's a really great example of how chat GPT and open AI you know these are this is pretty amazing as a developer like now I can throw an idea into the open Ai and it can kind of like guide me along the way is it perfect well we we're still yet to see if this works but let's just keep on moving here and I think it's saving a lot of time so let's paste that in so as you can see we have all of this set up already import pandas as PD I've already imported time scroll down here because this is more of an updated one let's make sure this is the same let's go ahead and print the SMA print just to kind of test it now this is like the first official test we're seeing if the SMA is correct and this also a print Let's do an F string here and say this is the symbol current price and then put in the price here and SMA 20 and we'll put in the SMA 20. I feel like this is a pretty solid test because you know especially if you're new to algo trade-in this would take a little bit of time to figure out you probably have to Google it and I think that's one of the best use cases thus far with open Ai and chat gpt3 is it it just helps you with Googling and it writes out the code for you so you could Google and go to stack Overflow and figure out all this stuff but now you don't have to do that you just get an idea back like instead of having to like piece together 12 different tabs on Google right and try to figure out which is which and what works best for this scenario now open AI allows you to just type in what you need and then it gives you an answer so that's going to be a game changer in my opinion so let's go ahead and see if this works this is the first test we're giving it using pretty much all the code you know with a couple of tweaks just bringing in my API keys and whatnot using all the code that has been suggested by open Ai and the first test is can it show us the symbol can it show us the current price and can it show us the SMA of 20. you know what let's go ahead and run it I could even said hey show me that okay so look at this it says the symbol does not exist cmix does not have market symbol BTC USD so the above I'm just going to paste this in and see what happens and now I'm just just testing with you if you mix does not have the marker symbol BTC USD please correct that in the above code let's see what happens here I know what the the market symbol is but let's see if open-air add us so the way I look at this is I don't think immediately it's gonna remove like remove the need for developers like you and I or maybe just I and if you're learning this you eventually but I think as a developer this is going to speed things up a lot and obviously I'm just showing you the front end right now which is chat gbt3 but you can use the open AI apis in order to try a bunch of different stuff let's see if it has the usdt because that's essentially what it said it says hey I'm changing the USD to usdt let's see if that works okay there we go so this is BTC usdt current price is this the SMA 20 is this hmm maybe because there's not enough data and that's right because this just gets the price so while the code looks pretty good I don't know because you can't really get a rolling window of the mean you can't get a mean off of One price so let's say instead of just calculating price for one period in the above code use a panda's data frame to get open high low close volume data so it's easier to create the SMA 20. and 40. okay so look at that the code looks good but is it actually good I don't know thus far like I've had to tell it a couple of things that being said it does give me some good ideas at least so certainly to use a panda's data frame to retrieve open high low close volume data from Phoenix and calculate the 20 and 47 moving averages you can use the following code so let's go ahead and see if they use the code the way I would do it the way I would do it is I would get a data frame and fill it up with all the data right and instead they went ahead the AI went ahead and said hey we're just getting the current price but then you can't make the SMA off of just the current price right you need like multiple prices you need the price for the last 20 periods and I can already see here like okay this is great that they they got the last 20 periods but edit the above code to get the last 200 periods of data instead of the last 20 periods so thus far it looks like we have to work together right so is open AI going to make it possible for you to not know how to code maybe but you have to be able to at least know the high levels of coding right so like for example I knew there that hey you can't make a uh a SMA because SMA is the rolling average you can't do that off of One Price period you need at least 20 price periods so I asked it to do that and it did it it said hey open high low close volume data it's here but it only made it for 20 periods so I'm just gonna say hey edit the above code to get the last 200 periods instead of the last 20 periods and I could probably just do that myself really quickly because it seems like it writes out all of the code over and over again which is that the best thing to do I don't know I feel like they're going to cut me off at some point and not let me use this because I feel like I'm using a lot of credits but whatever I'm gonna run it and see if it changes this all I need this to be changed to is 200 instead of 20. now because that's like 200 lines of data opposed to 20 lines of data so my 40 SMA is going to work much better because right here it won't get an SMA for the 40 because there's only 20 lines of data so I'm just gonna have it run again and they'll probably eventually cut me off because this is a lot of different code I'm running but you know thus far my analysis is you know it's super helpful probably for things that you don't understand right now I I know how to do this and look at that I just got a network error so it looks like I'm just pushing it too hard so let's go ahead and regenerate response only one message at a time please allow any other responses to complete before sending so maybe Maybe This Is the End of my use of chat gbt I'm gonna hit refresh actually I'm going to take all this code before I hit refresh just in case because this this is pretty good code and I can use it let's go ahead and now hit refresh let's go back here regenerate response okay maybe that's all it took perfect I've heard that the cost of running open Ai and chat gbt are really mind-boggling that's at least what the founder Sam says so I can imagine when I run harder things like this not just like some I don't know I wonder if this takes more credits than you know generating like a paper or something but now it's gonna update it for the 200 periods and I'm gonna run its next test here off of this now we know this test right here didn't work because it just got one price instead of open high low close volume now that's one thing about this is if you're not an experienced coder like it might be tricky because you you wouldn't realize why didn't this work now I've written so many Bots and I've taught this so many times that I know that it it wouldn't work because there's only one price and you need 20 total prices to get the mean but if you're new to this it might be different let's call this Exchange since it's doing that and let's run another test on this after we make these updates so I'm going to delete these two lines and we'll go ahead and try this out so let's start here it says set the symbol and then it gets open high low close volume data looks like it gets the limit of 200 now which is great it sets the data frame which looks awesome to me I mean first look and then it gets the rolling me so let's go ahead and pull in all of this here and run it so retrieve open high low close volume data that looks good to me goes to the exchange fetches the symbol the time frame the limit and then it converts that data to a panda's data frame one of my favorite parts of this is that even when it does something wrong it gives you the English steps right so like for the case of initializing The Exchange the first time we did this it didn't put in my keys but at least it told me the first step right so it's in my opinion you're much better than Google at this point I'm sure Google has something equally if not better than this but at this point it's like a good way to it's like a a pair programmer somebody to help you out while you're programming in my opinion so I'm liking it a lot and we'll keep testing this out so we got the Open high low data and then we get the mean of the close and then the current price what is the current price well I guess we don't have the current price anymore but one other thing I could do is print data frame and this data frame is going to print out the data frame so let's put that above this one so we can see that at the bottom and let's just test it out see how it did okay this is great I think well it says this is BTC and this is SMA 20 and then 999 hmm and Anne print the SMA 20 and it says SMA 20 is this okay this is better all right let's look at the data frame this is tricky because this shows the last lesson I only want to see the last and store the SMA store the SMA 20. in above code store the SMA store only the last SMA 20. and SMA 40. most recent last most recent as a variable to use in the buying decisions instead of a price series so what's happening here and this is why I'm asking to rewrite it is because the SMA 20 is actually grabbing the whole row of SMA 20s for the last 200 that's why the first 20 are any ends because you can't make an SMA 20 off 20 periods of Nan so you can see this is like it writes good code I guess kind of but you have to be able to tweak it so I'm gonna keep playing with this because I think there there's definitely something behind this and if you didn't know how to get the last SMA 20 look at this I know how to do it but you can see last SMA 20 now so if I go ahead and put in this last and I just type it in here store the last SMA most recent 20 as a variable so you just do sma 20. ilock negative one and then this would be last SMA 20. and if we want to take a look at the data frame as well I'm going to open this to be a little bigger because you'll be able to see that it did create the pandas data frame here but I don't see the SMA 20 on the pandas data frame interesting so SMA 20 is DF close of rolling 20. so you can see here and also also add also add the SMA 20 and 40 to the Main data frame so let's run it again one piece of feedback I would have is instead of having to run all this again maybe it stores it and it could just spit it out and when you it spits it out it just adds the new function right instead of having to go like dot dot dot like symbol about symbol it's a little slow and I think it could be better now I'm also going to start using or I'm going to start testing around copilot a little bit now that's based off of Open AI I don't know if it's the most updated model but um that should be pretty cool a little AI to help write code as well okay and there you go so it says add the SMA to the main data frame and then it adds the other one here as well so let's go ahead and do that I'm gonna copy this so let's just take all of this right here and now it's going to add it to the data frame which is nice so is this faster than coding by myself it depends like if you're an amazing coder and you know all of this by heart maybe not but if you still don't know everything by heart which I certainly don't remember everything in my heart well it could be good so I'm gonna paste this in calculate the SMA 20 on a rolling window of 20. okay it got that from the data frame and it's a DF close and then it made the last SMA 20 the ilock function in pandas the last the the last row and then it created the column which it pretty much had but it was hidden now it's here I don't think that's going to work though I think it needs brackets around it um and then it gets the SMA 40 closed rolling mean which looks good and it gets the last SMA 40 and then it creates the pandas data frame as well but I think it needs brackets around it but we'll see so while this is pretty dope you know it does need a human oversight still so if you're worried that uh open AI is going to take development jobs right away I don't think that's true but hey you know next version you know in the future I think it will be able to code much much better and it's going to take developers like you and I to uh tweak this and we can build on top of it right so I'm already building some stuff and to make this a more improved model and I'll make sure that everybody inside of the boot camp gets access to anything that comes out essentially I'm just trying to make that like the family of I will Traders here as you know I just I just I record what I need to build in the day so I'm typically not just making YouTube videos I just record what I need to actually create that day and I need to get better with open Ai and see where the holes are because we're building something that will allow open AI to be even better and really be able to code with you or for you so that's pretty exciting so my guess here is it's not going to print out the DF because this is going to be an error but maybe not okay so it didn't that was not an error I've just had that happen a few times that's awesome that it's working so 16824 is the last SMA 40 which is awesome and SMA 20 is the last last one so it looks like it's doing well now so with a little intervention I think this can code pretty well let's go ahead and um I guess continue that rebuilt I should just keep going okay maybe I'll just rebuild it all the way this time but I think we have the code up here um now I'm gonna let it run it out and then what we'll do is I'll hit continue I'll say continue keep writing that code because we have gotten the smas correctly we've gotten the last ones we've got the 40 and the 20 and then remember our rule for building this I should write this somewhere so we can all see it this is what we're building with python and ccic build a strategy that buys Bitcoin I should have said in Phoenix build a strategy that buys Bitcoin when the price is over the 20 SMA then hold for five days then sell when the price drops under the 40 SMA now I know it might not go over the 40 SMA but we're giving it five days to do so and I'll just say keep going because you can see it stopped here and that's a little weird thing I don't know why it does that maybe it's just trying to conserve credits or something here is so it says certainly here is the rest of the modified code that uses the last most recent 20 and 40 smas to make a decision about whether to buy or sell Bitcoin so you'll need to define the amount of BTC to buy and the price at which to buy it at okay so we did exchange I create Order symbol Market by amount DF close dot ilock one so we're buying at the last close it looks like interesting I guess I didn't instruct us to do anything else so this is kind of cool right because even when I don't instruct you to do stuff it probably uses all the data on the internet to to decide what is the best I'm not quite sure how the model was trained but you know this is a pretty pretty solid it's all a ways to do things so let's go ahead and say I think this is the next part right here so let's copy that and then we need to copy this as well amount we don't have the amount I'll make this so you can see it better amount so we need to pick the amount let's just do one for now put that up here equals one okay and then this start time hmm hold the BTC for five days trying to figure out how does this line up so it says hold the BTC for five days okay I don't know where we want this though I'd say that's a little bit confusing because if it's if the clothes is bigger than the last SMA then we're going to buy okay I see how it goes and then after it buys it holds for five days so it's just gonna go in a holding pattern for five days and just Loop that's an interesting way to do this but I guess it works and then after the five days it checks again and what's it check well so we go through this while loop and it's just going to keep sleeping for a minute and then if the close is now under the 40 SMA I feel like this needs to be shifted over so like that not this though and then boom this right here is the algorithm I'm pretty sure I mean essentially it says if the clothes the current close is bigger than the last SMA 20 create a buy order it's got to do Market buy order I would change that I usually do limit orders but it's cool to see that it wrote all this code and then after it creates creates the order since it's a market order it knows it's in automatically and then it says start time this is the start time and then while start time time that time while current time so time.time is now minus start time is under I'm assuming this is five days sleep for a minute so it just loops loops loops until it's that and then if if the close is under the for esma then it will create a order to sell it now I would say we only want to do this alter the above code alter the above code in order to only enter a position if we are not already in a position otherwise otherwise do not enter another position so I just like to explain it like there are five um do not enter another position so only have one open position at a time sometimes I Reit iterate it um let's see how it does because right now essentially if I had this all Loop then it would go ahead and continue to open new orders so while open AI is pretty smart and can write code you have to be very very specific and kind of know what to look for so if you don't know how to code yet I would recommend just learning because it's not that hard I didn't go to school for it I didn't go name boot camps or anything like that I just learned on the internet and now I'm just coding every single day new Algos new tweaks to my Algos and I try to put all the code inside The Bootcamp and that's all accessed below and then in Discord as well so you get access to the Discord which is pretty neat as well but 2023 is going to be the year of machine learning and AI for algo trading for the crew that's that's with me so I don't know how long I will be sharing this information and sharing my tweaks that are on top of open AI this is just kind of a sample right because this is what this is what open AI has launched with chat gbt3 but I think this is just a start because it clearly needs some tweaking and I'm working on tweaking this model to to make it work much much better so if DF close if not in position if DF close Market by I think we gotta say keep going okay I like this implementation better keep going here's the rest of the code so this one looks better because it says if D is close is bigger than this and then if not in position and it says in position equals false but how does it get the imposition so I'm going to say in the above code in the above code check to see if in the above code have the have the in position variable check the exchange to see if we are already in a position so this is pretty like interesting right because it looks like really good code and if you don't know how to code it's like oh my God it just built me a a bot instantly and like if you even like as a coder I look over this I'm like holy smokes this built a perfect trading bot for me but in reality look at this we've had to tweak it multiple times it says imposition equals false but then how does it determine if we're in position it sets a flag to imposition is false but I don't think that you know that's not the way to do it you have to check to actually see if there is a position so now I'm telling it to to fetch balance that's pretty much I didn't say that which is cool I said check to see if there's imposition and set that as a variable and now it says fetch balance will do that that's awesome but it took a little bit of um Intuition or Knowledge from my side and in order to kind of tweak it so I've seen a lot of Twitter posts and whatnot like oh my God open AI can code for you and I think it can to an extent it can help you code give you ideas but you gotta work with it like it's the way I look at it it's like a super expert coder but also a junior coder at the same time so it's like expert as it knows everything and it can find anything but it's almost Junior and decision making of like how do I figure this out so but with some like some massaging it can do it so you can see now it's creating a balance BTC free and is that the way to do it then if open position is true check to see if you have a non-zero balance unless I keep going because it looks like it cuts it off what I love about this though is you can see the holes really easily and open AI is pretty it's open AI like we can use the apis in order to build on top of what they've built thus far to make this something that you can just put in a strategy and it actually spits out the entire code and I think it just needs to be trained a little more with more algorithms so you know I'm working on that and that's going to be pretty interesting like I said I'll I'll make sure that everybody knows when that is released um that's in the Discord and the boot camp all that good stuff there's links for all that below so the code use the we'll use the fetch Valance method of the ccxt library to retrieve your account balance and check if you have a non-zero balance of Bitcoin if you do it will set the imposition flag to true indicating that you are currently in position if the current price is above the 20 SMA and you are not currently in position it will buy Bitcoin and hold it for at least five days if the price then drops below the 40 SMA it will sell the BTC and set the in position flag to false it says keep in mind this is just a basic example and I agree with that you know it it takes a little bit of looking through here so let's go ahead and implement this one instead check to see if current price is below yes it may and you can see here it kind of just like gives up on this line here that's funny I'm gonna take this though in position from here all the way down to here and I'm gonna delete this part here delete add and now let's look at it so balance equals fetch balance okay exchange.fetch balance and if balance BTC free that means that there is BTC that we have on our account if it's over zero that means we're in position so this looks way better so in position equals true so it sets that to imposition is true but initially it says that the false just to initialize a variable and this is where I think a lot of the learning comes in for me at least is it it gives us what it actually it's trying to do and then you know with your own skills you can tweak it or ask it to change a little bit for you which is super nice because um if you are learning at least it gives you a skeleton right but as you can see throughout this video it's not quite perfect and I've spent some time trying to build this and I would say it probably saves save some time at this point but as I've mentioned multiple times before like I still think you need to know how to code right now my goal is to build something that allows you to just put in the strategy like I did above and then it spits out a perfect a perfect set of code now that's that's pretty ambitious project that I am working on so that should be you know probably here this year or well I guess it's the end of this year 2023 and like I mentioned I I just I like to code with you and show you what I'm doing each day show you where my mind's going because I don't know everything and if one word or idea helps you think of something that changes the game forever when it comes to I'll go trading that's so worth it to me because I'm still getting work done I'm just working with you and if you do appreciate that just let me know below you know or or hit the like button I always just signals to me that hey just keep building on on YouTube instead of coding by yourself because either way I'm spending multiple hours a day building new algorithms or update my old ones and this is some interesting technology that I just really wanted to share with you I'm sure you've seen it already all over YouTube or Twitter but there are some holes to it and I just want to make those holes pretty apparent because you've watched me build algorithms by hand if you've been around on the channel for a while now and now you can see me using chat gbt and see that it's not quite perfect yet in an ideal world it would be able to just write the exact code for me maybe it's my fault though I didn't give it good enough instructions if you want me to make another video of giving it even better instructions to see if they can spit it out perfectly I've already started working on some templates that have helped improve this so like template instructions right of how exactly to put in your your trading strategy so it gets even closer it's not a hundred percent yet but like I said I'm constantly researching and trying to build on top of open Ai and my guess is that Google has something probably even better up their sleeves [Music] I read a quick fact the other day that Facebook and Google have like 80 percent of the market when it comes to machine learning engineers and phds so that's what's going to move this industry forward not necessarily that you need a PhD by any means to do this but if they're just hiring everybody up there's got to be a few really smart people in that group so that's going to be interesting I just want to be ahead of the the game though with all this machine learning AI stuff you know as open Ai and other companies release their models you can always build on top of the model so in the dream world and it will come true someday for for me is I'm going to be able to put in text just like I showed you here but instead of having to tweak all these things it's going to spit out a perfect trading strategy that works without any edits and that's where I'm going so if you want to be part of the crew you know jump in the Discord there's a link for the the camp below I'll show you absolutely everything I know about training algorithms and how to code them so you can either code them by yourself or code them with chat gbt because you can see it does help me do some things and and it's especially nice for things you do not know how to do like for I kind of know how to build this spot I've built it multiple times on this channel but you can see it at least writes the code for me it takes some time and for things I don't know how to do I would have to Google it so I can make some more videos on open Ai and chat gbt it's pretty interesting to me let's go ahead and try to finish this up though so I just pasted in all this and it says now it actually gets us a real in position and it says it's true if DF close dot ilock negative one over the SMA if not it then it would go ahead and start to consider to enter but then it would say if it is and you are currently not in position then bison BTC you will need to define the amount of BTC to buy in the price at which to buy it at okay so symbol Market we're doing a market order so there is no price we need to buy that I wonder what this is so create order amount price params it's interesting because it it has it set as a market order but then it also passes in a price so is that going to work I don't know I don't know about that I'll have to test that one but then it sets into position to True which is correct because it did a market order so you automatically get into position and now it's going to hold for five days so start time time out of time and then it says while timeout time time dot time is minus start time is less than five days it's just going to continuously Loop for 60 60 seconds which is one minute and that's pretty cool I mean for me that's a different way than I would implement it so that's one of the huge powers of open Ai and using chat gbt in trading because it makes you look at things differently just like I hope these videos help you come up with different ideas for your brilliant ideas you already have because I have a different perspective than you do and you have different perspectives of me chat gbt is like a third person or even more like you know it has more knowledge than both of us combined it's just about being able to ask the right questions the same thing for Google right Google has all way more knowledge than you and I combined but it's hard to ask the right question and if you ask the right question the information is going to be there but with Google you have to sift through all of these results and with open AI at least it just gives you an answer and you can always be like hey I want a different one so this is a pretty cool way to implement that is just going to make the order it's going to be a market order and then it's going to sit for five days and then it's going to check if the data data frame close ilock negative one is which is pretty much the price is less than the last SMA 40 then it creates a sell order so what I would need to do in order to actually get this functional is I would have to call this a bot so like say death bot like this and as you can see like this is another thing that you know I I also got really excited when I saw it write code but without being able to know how without knowing how to code it's it's going to take some change tweaks and changes so like you're gonna you're kind of gonna need to know at least the basis gotta go now this is weird that this didn't get pushed with it but so if this needs to be sent over as well it's weird how when you indent it doesn't always indent correctly and that's like for me when I was first getting started indentation was tricky as well so you know my overall summary of this is essentially Chad gbt is like a an expert Noob coder expert as it has all the information needed but it's also a noob in the fact that you have to like really massage it and to get the right answers and so now I put it into a function and now I can say hey let's Loop this function forever and that will allow me to run the spot 24 7 365. so how do I Loop forever well let's go ahead here and say Loop bought forever and that should be fine because remember when we enter it just chills for five days you know if you have this up on a server or a computer it's just chilling for five days after it enters and then it's gonna check this so loot bot forever we have to hit schedule dot every let's just do 15 seconds and Dot seconds dot do and Bot and then we have to import schedule import schedule and I might want to import that at the top but then we'll say while true we want to try schedule and we put a try block there just in case like internet goes out or something I don't want to have to rerun this because for example if the internet goes out or you can something happens I can just say print maybe internet problem air sleeping 30 and re trying so I'll copy and paste that a few times I want to go ahead and see if I can get this to run but I'm not going to spend too much more time debugging it you can see that if I run this every 15 seconds let's just run it once for one second now and let's go ahead and go to my femax well let's see if it runs first VMAX contract let's go to BTC oh it looks like my Market maker is in there already so that's interesting is it up a little bit I don't really want to run it on my account because I have another bot running but you know this is this is interesting I think it's going to work but as you saw I had to massage it quite a bit so if you want me to do a part two and build more in-depth Bots using chat gbt please do let me know open the eye it seems to be pretty neat but I think this concludes the how to use openai to build trading Buffs using chat gbt3 pretty awesome software but like I mentioned you got to massage it a bit and I'm Gonna Keep training on top of their model which is the open AI codex model and hopefully we can get to the point where you can just put in this and it outputs a perfect version of this instead of having to uh play around with it so thanks for watching I'll see you in the next video or inside of the boot camp where I give you all my code all my strategies and all that good stuff so see you there
Info
Channel: Moon Dev
Views: 174,069
Rating: undefined out of 5
Keywords: algorithmic trading, algo, trading, quant, data science, how to, code, python, trading algo, trade algo, hedge fund, ccxt, backtrader, back testing, pandas, numpy, how to trade, how to algo trade, course, bitcoin, crypto, nft, openai, chat, gpt-3, a.i., finance, ai trade bot, machine learning trading, machine learning
Id: QLYmpGlZpG0
Channel Id: undefined
Length: 59min 1sec (3541 seconds)
Published: Tue Dec 27 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.