hello world it's SJ and open aai just released 01 preview which is the smartest AI in the world I decided to give it access to my coinbase account and ask it to make trades to see how much money it could make in 24 hours and you can see the logs of it trading right here with my Live coinbase account worth $21,000 at the time of this video and it's placing trades every minute based on what it thinks are going to be the optimal trades to make in this case it's going to be let's see eth ethusd it bought $5 worth of ethusd and it's going to continually place these trades based on the market conditions economic indicators and anything else that it finds fit and I'm going to show you exactly how to build this trading bot yourself in this video from scratch and you could see these small trades that it's making with my Live coinbase account in the account itself here's all the transactions that's really amazing and it's using chat gp01 preview open a latest and greatest AI model which I love to use I've been hitting the limit on it so I've been creating other accounts so that I don't hit the limit great it's amazing it reasons it uses Chain of Thought reasoning and reinforcement learning to make better predictions about what its output's going to be and it's all about system two thinking rather than system one which means taking your time before you give us an output so in this case it's going to be what's the best trade to make right that's the best output that we're looking for and the three tools that we're going to be using in this video are first of of all cursor the latest and greatest code editor out there which is basically visual studio jam-packed with AI specifically we're going to be using open a01 to create code generate code for us without us having to code and then we just accept that code whatever it says to accept we'll accept it and we'll build our entire app just through prompting alone which is awesome and we're going to be using our coinbase API account to place those trades with our actual Live account and once we have this script we're going to deploy it to AWS that's right we're not using repet or any other easy Heroku tutorial we're going right to the source with AWS so buckle up I'm going to set the timer for 10 minutes and I want to see if I can build this strategy for us in 10 minutes and I want to compare it to GPT 40 so we're going to compare Chad gp01 preview to GPT 40 and see which one makes more money in 24 hours all right so let's get started with this I built this strategy using my app tra GPT but we're going to build this from scratch for the sake of this video using python so let's get started by opening up cursor and once I'm in cursor I'm going to open up a new folder and this folder I'm going to call it test day and inside of test day I'm going to open up this new folder called teste and I'm going to use cursor's latest feature called composer which lets us build class files from scratch so I'm going to create a new class file called trading strategy. that I'll reference in the composer window so I'll open up the composer window by typing in command I and then I'll ask it to develop this trading strategy please develop me a simple trading strategy for cryptocurrencies that outputs an optimal portfolio allocation amount like 50% Bitcoin 50% ethereum based on and and just let's just have it do that for us and the great thing about cursor as opposed to just having Visual Studio code in one window and then clawed in another window is that it makes these code edits in line so we can see it with the green and the red which is great so I'll apply those changes and then automatically I'm going to try to run this code with Python 3 trading strategy. and the first thing it's going to do is it's going to probably uh error on us it didn't so it gave us exactly what we wanted we wanted this allocation so let's see now how it's giving us this allocation so it is giving this this this allocation please explain let me ask it to please explain why it allocated that amount and it's going to give us an explanation for it based on individual volatility and okay that's great what else can we do here this this works it's going to change every so often probably so let's now make a second file and this second file is going to be called trade executor dop and what trade executor will do it's going to take the output of trading strategy and then actually Place those trades with coinbase based on the output of this trading strategy so this one is based off of some simple strategy involving historical price data and then optimizing the portfolio based on volatility so it's Computing a specific volatility index to make these trades so that's what we're going to do we're going to build a second file we'll ask composer to do that please now create a second pyth file called trade executor dopy that will execute the trading strategy py and print the results so that's the first thing we want to do just to make sure that the wiring is there and then we're going to add to that trade executor dopy so you can see that it's already created that second file for us here trade executor dopie we'll hit accept all and then we'll run now trade executor dopy okay great it's doing exactly what we wanted it to do it's printing those outputs so now we're going to say great based on that let's now Place trades with coinbase so we'll say thank you now let's update trade executor dopy to based on the outputs of the trading strategy let's have it Place trades on my coinbase account using my USD balance and it will either buy or sell crypto to gain that portfolio allocation so now I'm going to give an example so let's say at first it says Bitcoin 60% and eth 40% it will then make trades to allocate that portfolio but let's say the next time it says Bitcoin 70% and eth 30% it will sell 10% eth and buy 10% more Bitcoin so that the portfolio is rebalanced does that make sense please execute those changes now this should be enough for us to update the trade executor dopy with the coinbase trade execution logic including buys sells based on what that trade strategy has told us to so we can see three functions that it's created get the portfolio value execute those trades and then execute that strategy so we'll hit accept all and we'll we run it we'll hit run trade executor dopy no module name coinbase so I'm going to say please give me an optimal requirements.
txt file to install any dependencies that I need create that file okay it's created that requirements. txt file I'll hit accept I will now install my dependencies by saying pip install uh requirements. txt that will install coinbase and any other dependencies that I would need and then I'll run that updated trade executor dopy which contains the coinbase trade execution logic by typing in Python 3 trade executor dopy and what I want to see is a specific error here which tells us that we don't have the right uh coinbase credentials that's right missing API key so I'll give it that error and it's going to say hey here's what you did wrong with the error make sure you've obtained the API key and the API secret that's the issue right so we're going to get that API key and we're going to get that API secret we're going to accept All by adding those in so I have an API key right here that I'm going to paste in and I have have a secret here that I'm going to paste in and now that I have them I'm going to run this code on a you know comment out execute trade for now to make sure that uh this is going to work and we'll try it out here's the output I'll give it back to it to try to fix it okay it's going to make some changes here which I'll accept blindly now it says there's no module named coinbase uh Pro python so it's going to probably update the requirements.
txt file to include that and it's going to update the trade executor accordingly with those changes now we'll try it no module named coinbase Pro because I need to install the updated requirements. txt here's the error okay we have an updated requirements at txt we install it accept all the changes excellent so now we have a working strategy using our coinbase code and it is going to make these trades so now it's able to place trades it's basing that off of the logic of the web and now we can deploy the strategy right it's two python files that's it and requirements. txt file that is our trading bot and if we want to improve it with 01 which we're about to do we're going to use this prompt so this prompt is going to be please now Implement chat gpt1 to base on current market conditions upgrade the trading strategy dopy to be optimal or leave it alone if the market conditions don't require changing it that's it it's going to every time this this code runs it's going to run CH gpt1 uh via the completion API and then it's going to just check should I be updating this trading strategy if not don't do anything if yes update the code so that the inputs that it uses are different maybe it's going to use a different set of apis maybe it might use a different set of indicators maybe it might choose different assets it's going to dynamically allocate uh those trades so let's accept all of these changes that it's made it's created a strategy Optimizer using the openai API key so it created its own class file just for uh Omni so right now it's using GPT 3.
5 Turbo which we'll just set to 01 preview and we tell it you are an expert cryptocurrency trading strategy analyst please provide specific recommendations for improvements if necessary we give it the current trading strategy we look at the current market data we get that from the Y Yahoo finance API and we input our openai API key here so let me input my key here exactly where it [Music] says and now we can run this code okay it's using an older version of open AI so we need to fix that got to use the latest version this actually always happens with AI always use the old version of the openai API for some weird reason okay okay now here's the output and we can see the output of omni here where it's making improvements based on the markting conditions it's saying okay Bitcoin has experienced this it might be beneficial to consider updating the trading strategy y y yada so it's using 01e preview to update those trades dynamically so now that we have these these scripts we have trading strategy. trade executor dopy and strategy Optimizer dopy we're going to deploy this as a Cron job to AWS which means it's going to run this script at set intervals in this case every minute so let's do that let's go to AWS we'll create a new instance by saying launch instance and we'll call this a coinbase test and this coinbase test instance is called going to uh use T2 micro we can keep it small and 8 gigs is fine we'll launch it with one click and we'll use my existing Amazon key pair and that is basically a PM file that you get when you create your AWS account to start off with and it's just downloaded locally and we can see this new instance here coinbase test and I'm going to say here's my instance summary I'm going to use these details to connect in a new window so I'll open a new cursor window and I'll say open with SSH and I'm going to add a new SSH host so what should my new SSH host be and I'm going to give it these details and it's going to tell me exactly how to connect via cursor it's going to say use the public IP address I'm going to use that public IP use my SSH config host added connected now that we've connected to our Amazon ec2 instance we can run this as a Cron job so please show me the command to run this strategy as a Cron job every minute so we just need to create this Cron job and we'll say CR tab e we'll type in this path to this trading strategy we'll save it and that's it and now it's going to run every minute of every day it's going to Output the results to trading log. txt and we can monitor it in real time so that's it for this simple demo code uh it gets better over time it improves the trading strategy let's come back in 24 hours and see how my Trader gpt1 preview strategy did all right looks like it actually lost $238 over the past 24 hours and uh the GPT 40 strategy actually errored out so 01 preview was able to fix its own code successfully and reliably whereas GPT 40 it saw that the market conditions were not as good and it tried to fix the code but the code errored so 4 made 0 and uh 01 preview lost $238 which is actually good news because it was able to work if you want to deploy these trading strategies yourself but you don't want to go through all the hassle you can just use my app Trader gp.