I built a stock trading bot and gave it $11,000 to invest here's how much money I made I've always been a long-term Buy and Hold investor but it seems like everyone nowadays is making big money off of technical analysis and automated trading and I figured I know how to code so I should at least give this style of investing a chance so I'm going to try to use generative AI to beat the market and no I'm not just going to use chat GPT and ask it to invest I'll be building an algorithm that trades based
on patterns in the stock chart and I'll recognize these patterns PS using the latest Tools in generative AI yeah AI can read stock charts now sorry Jim Kramer at least that's my plan but I've never seen anybody do this before so I don't even know if it's Poss if I'm going to have any hope I need to use the most advanced AI model available today Google's Gemini Pro Vision model so you haven't heard of Gemini well allow me to explain Gemini is the latest of Google's generative AI tools these are tools like chat G BT
that can understand language but not just spoken language they can understand music they can understand code the latest models can even watch a video and tell you what it's about I know and as with any new technology there's been a ton of hype around what these new models should be used for right now the answer seems to be everything just give me some generative AI with a side of buzzword please but since newer is always better right I plan to use Gemini's ability to recognize images to have it read stock charts and tell me if
I should invest in the stock or not and then I'll put $1,000 into whatever stocks it tells me to this is a dumb idea my first job is to see if an AI can even understand a stock chart so to figure this out we're going to go to Google's maker Suite so let's start out by just seeing if we can recognize an image what does this image show and let's run it this image shows a buganvilia plantan vilia I'm going going to assume that that's correct because I'm not really totally up on my boty okay
let's go a little bit harder let's try to give it an actual ual picture of a stock chart I just grabbed a screenshot of Apple's stock price we're going to run this through okay we got something so it knows this image shows the stock price of Apple but it went a little farther it says the stock price has been increasing over the past year from 125 in January 2023 to 168 in October 2023 so it's not only telling that this is a stock chart but it's grabbing the 125 from my little hover here and it's
getting the current price as well as the date that's pretty crazy let's try something even one step farther so I found this stock chart that has these grid lines on it it shows the name of the company and it shows the price on the right hand side so I'm going to run this and the AI needs to identify what company this is if the stock price is going up or down and I'm going to throw in one tricky question when did the stock price see the most rapid drop which is kind of a vague question
I I want to see how it answers so it says the chart is for snow stock the minimum stock price shown is 186 yeah pretty close and the biggest drop in the stock price is $3.75 huh so I thought that this was going to be a lot harder and I was going to make a joke about how the AI would need a lot of work but it seems to have just gotten it off the bat like what the heck that was like way too easy to do this guy had no clue what was in store
for them first I needed to find an easier way to get stock chart images than just screenshotting them from Google after a few hours testing out different sites I ended up finding a site that had an unsecured URL with parameters I could just adjust in my code so I took that I loaded up my Robin Hood account with $1,000 for the AI to invest I then had to start setting up the wireframe and importing all the packages that I would be using in my actual code and with an AI that can read stock charts and
all the stock charts I could want in my fingertips I was ready to go and start making infinite money but wait wait wait wait wait what am I doing with all these charts there's a whole world of day traders that just trade using the number so why don't I just do that well firstly because it's more fun and secondly I don't plan to read any numbers off the charts I just plan to look at patterns in the image to see if the stock is going to go up and based on my internet research I should
be able to make thousands without knowing any advanced mathematics like entry-level calculus by so by so but after researching for the better part of two days watching everyday trading and pattern trading videos I could find I realized there might be a flaw in my plan even if this algorithm makes money it doesn't necessarily mean anything cuz anyone who invests long enough in the market will make money so we need to raise the competition so while my bot is trading this week I'm going to be comparing its performance to my handpicked portfolio of stocks that I
assembled using fundamental analysis you know the long boring process of figuring out what a company actually does and if they'll be worth more in the future than they are today let's see who wins the tried and truee investing method of people like War Buffett or the most powerful AI ever known to man but first I need to actually build the bot wait I thought this was supposed to be easy so coding a stock trading bot takes a lot of you know code and since showing code is like YouTube Kryptonite I put together a whiteboard presentation
to explain in three easy steps exactly how I'm going to do this and I also got a bigger whiteboard so I don't have to keep on crouching down step one I need to pick stock chart patterns that the AI can recognize that will reliably make me money picking which stock patterns I would use only took took me around half a day because I was watching this over an hour long video and reading all these different articles and I ended up finding this gu chart on LinkedIn that basically simplified down to 16 different stock chart patterns
that I could look for so I found the patterns that I want to use now I just need to teach the AI to recognize these patterns reliably and to make it simple I'm just going to focus on six of the patterns in this chart that look the most visually distinct from a distance cuz honestly when it comes to training an AI it's like trying trying to train a half blind 3-year-old hey how should I teach the AI to learn stocks but why do you want to make an AI well I want to trade stocks but
why do you want to trade stocks to get Hood Rich like all the big Traders I see online but why do you want to be rich I don't know maybe it's a deep-seated insecurity for my childhood and I feel like I need to make more to try to live up to expectations that were set when I was younger that I'm never going to be able to reach but why step two I need to teach the AI to recognize the patterns and then make stock trades based on them basically this is just the process of building
the bot and getting it to do everything that I want it to do luckily I had no issues getting this to work this doesn't make any sense 280 how do you know there's a bumblebee in the photo there's a whole different API that does the exact same thing okay so it wasn't so easy it took around a week now I already had the AI able to read a stock chart but now I needed to get it to recognize these patterns I set up a Jupiter notebook just to test this out success I can talk to
the AI now I just need to get it to recognize a stock stock chart okay the model's behaving really weirdly right now basically I'm giving it the exact same image in Google maker Suite as I am in my code and yet the code is giving totally different answers like here for example it says the stock price is decreasing from the start of the chart to the end but it's clearly going up but it also gets some things right like it says the stock chart starts at 9:30 but the answers I'm getting don't match up at
all with what the stock chart looks like I don't really know what's going on so I'm probably going to sign up for like a course or tutorial and try to figure this out my camera turned off it was going so long back to it so I think I figured out the issue with my code the issue is the model isn't actually getting the image it's just trying to understand what the image would show from the URL which is why it's giving me such random results basically I was trying to give an image to the AI
and I thought I could just give it a link to the image but it turned out the AI was trying to read the text in the link and guess the answer to my question instead of actually looking at the image so now I just need to teach the AI to actually recognize the patterns and I'm going to do this with two techniques few shot prompting and classification and I'm not going to bore you with the specifics on how I do that but the point is I need to find examples of these six patterns that I
can show to the AI so that it knows what to look for so I could show this whole process or I could just use the power of editing to skip to when it's done it's been 3 days I feel like I lost some of my soul somewhere in the code I don't know why I thought this would just work but took me hours just to find examples of each stock chart pattern and then I ran into issues storing that many images then more issues with the prompt being too long for the model to process ultimately
I managed to get all the examples in place and run it against a real stock chart so I think I have everything set up successfully so now I'm just going to run it and see if it's able to recognize this pattern and yes I am recording this on vacation because this thing takes forever to get to work let's see bullish flag that's right it got this one right so it seems like it's kind of working but it keeps saying there's a bullish flag even sometimes when there isn't one so there's still clearly something I need
to change nothing a few hours of research and some Chain of Thought prompting couldn't fix I'm telling you AI is a three-year-old you literally say think through this step by step first you have a stock chart then you read the pattern in the chart it's crazy how could this ever be a real investor [Music] who oh it worked all right so now is the time to tell you there are basically two buckets of patterns continuations and reversals a continuation just means the stock price will keep going in the direction that it was before and a
reversal means it will flip so a bullish continuation means the stock price is going up and we expect it to keep on going up meanwhile a bullish reversal means the stock price was going down we expect it to flip and start going up and each of the six patterns I showed before fall into one of these two buckets so now I just need to put those parts together and I should be able to tell if a stock price will go up or down just by looking looking at it price while all this was happening I
was hard at work building my handpicked stock portfolio I've already researched all the stocks so I didn't really have to do anything I only make like one or two trades a month which you can see on fintech Circle this is my private stock group that's basically like patreon but actually valuable and even though I don't make a lot of Trades when I do I always post them on their first so I got back to work on the box after fixing a few last bugs my script started working and since my handpick stock portfolio was set
I was ready for step three profit or to to be more accurate we'll let the algorithm run for one week and compare how much money it makes versus $11,000 invested in my handpicked stock portfolio so here are the ground rules I decided to let the AI pick between 10 different stocks to make sure it didn't just pick anything and I'm going to let it run for one week and see how much money it makes compared to the 10 stocks I can pick that I think will do the best over the next week let's see who
wins all the power of Google and the latest technological advances in AI or one guy following some old-fashioned investing advice it's Monday morning day one and I'm going to get my first set of stock recommendations from my stockbot I've got the Robin Hood app open and let's see what stocks it recommends for me to buy today so first let me run this for Tesla it says this is a bullish flag and since a bullish flag is a continuation pattern that means the AI thinks the stock price is going to continue to go up so let's
go ahead and buy some Tesla I'm also running this around midday on Monday and let's see what it predicts for the rest of the day let's do the next one here's nvidia's stock price bullish flag also recommends Nvidia here's an interesting one this Stock's actually going down bearish wedge is a continuation pattern so it thinks Apple will keep going down today let's try Microsoft says it's a bullish flag okay so Microsoft a yes let's try Meta Meta is a bullish flag let's try Exxon Mobile Exon Mobile is a bullish flag despite being down for the
day okay okay let's do Walmart bearish bullish bearish wedge double top which means we do not want to invest in Disney at this time so my $1,000 350 of that is now actively trading so now the most advanced AI in the world has access over $350 worth of my portfolio that money's in the market let's check back in tonight now it's time to compare how my stockbot has done against my portfolio in day one the end of day one finished strong for team human my handpick stock portfolio was up 2.96% or just under $30 while
the bot was up $3 seems like an early win well I was getting lucky one of my stocks increased 20% after reporting they were profitable for the first time so the bot has a chance to catch up on day two my Robin Hood accounts up to $19 I didn't end up selling any of the stocks overnight like I know a lot of day Traders do cuz I only do what the bot tells me to do and it didn't tell me to sell so let's check now what stocks I'm supposed to buy on day two on
day two the bot changed up its strategy of buying everything and got a little more creative it started out hot out of the gates deciding to sell GE right before GE star price went up then the bot broke for a few hours so I lost around half the day debugging code but ultimately the bot picked five out of the 10 stocks to buy sold four of the stocks and left forward as it was meanwhile I didn't make any trades in my handpick stock portfolio since there wasn't any news on the companies here were the totals
at the end of day two day three I made my first trade in my handpicked stock portfolio buying shares in the Brazilian fintech stock new bank meanwhile over the next few days the bot was starting to make some pretty confusing moves buying a stock then selling it then buying more of it it looked random but somehow the bot was catching up day four came and went and I was neck and neck with the bot going into the final day as long as nothing crazy happened it seemed like the bot wouldn't be able to beat me
by too much on day five I put in the bot's final trades and waited to see what would happen so I originally started this challenge with the idea that I could make some fast money using the bot and it kind of worked if we add up the earnings of the bot bought over the past 5 days it made [Music] $62.65 78 during the last week so I guess the bot technically won but also while I've been editing this video over the past week I tried to keep investing using the bot but it was always in
the back of my mind did the stock price go up by $1 did it drop by 2% honestly I'd rather have the Peace of Mind of not having to trade every day than to keep on making a few dollars using the stock trading bot I wonder how much money I spent running the bot anyway let's see how much money I paid to Google Gemini just to run this AI well if you like this video maybe you'll like this next one and let me know in the comments if you want to see a sequel I think
I know how to make this a lot better