I Coded A Trading Bot And Gave It $1000 To Trade!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay here's a challenge can I write a program that trades stocks for me and how much money can I make in a week [Music] all right so that's the idea for what we're gonna do today I have no idea no clue actually how to actually get this to work but we're gonna try it we're gonna see how it goes hopefully it'll work now let's go [Music] [Music] [Music] [Music] all right so today's Monday and that means that it's time to test this thing out and see what it will do in the wild the last week or so I've been spending pretty much like what you just saw like coding this thing out trying to build it and been running into just a ton of different limitations and different problems that I didn't expect like pretty much everything that I do on this channel I thought this is going to be a lot simpler but it turns out to be a lot more difficult a lot of the strategies in like trading and different things like that is a lot more complicated than I kind of thought it was going to be which is really naive of me to think that it's going to be super simple but that's kind of how I work but I've been able to now back test it against a couple previous days and it seems to be making money consistently so it seems like it's good enough to actually run so today since it's Monday we're gonna start and we're gonna run this for five days and we're gonna see how much money can we make so let's go day one okay so I figured I would just kind of explain to you how this script works and how I was able to make this do what it does so the first thing that I had to do is I had to find some sort of API that I could use to get the data for different stocks so the pricing of them essentially for different times during the day and the second thing was I had to find some sort of way to find relevant stocks to actually look at because there's like millions of stocks that you could look at and I can't look at all of them and it's not relevant to look at all of them so I needed to find some sort of way to actually find relevant stocks to look at and the third one probably the biggest one was trying to find some sort of strategy for how to trade essentially so when to buy and when to sell different stocks so coming up with the strategy there and the first one finding the API what I used was something called alpha Vantage which I found a lot of people recommending and I used the free version which means that I was limited to just five API calls and minute that means that I kind of had to decide I had to figure out a way to find just a couple different stocks to focus on each day because I couldn't make that many calls so I decided to just focus on five stocks per day and essentially what I use is Yahoo Finance com I used to lean him to do some web scraping on there and essentially find the stocks that have changed the most during that day and then I find the five ones at the top and then those are the ones that I'm going to be checking throughout the rest of this the run of that script and so that's kind of how I find the stocks that I'm actually going to focus on and then the last thing is going to be the strategy so when to buy and when to sell and since I can only do five API calls every minute that means that I kind of decided to do one call for each of the stocks that I'm focusing on every minute so that means that I get the price of each stock every minute updating and so that's kind of what I had to work with and the strategy that I used was something that I found on this website and there'll be a link to this website in the description as well in case you want to look at this too but essentially what this was was that what they're using as an indicator is when the stocks move above the previous average high as far as I understood it so as you can see here here it has a high up here somewhere and here it has one that's pretty close to this one Oh as you can hopefully tell by now I'm not an expert at this at all so I'm not trying to teach you this I would recommend trying to learn all this stuff from somewhere else I probably should have focused a little bit more on actually learning this properly before I got started but yeah so when I buy or when I sell is based on this particular diagram so this is what I used okay so that's kind of how this script works and now what we're gonna do is we're gonna invest $1,000 today and we're gonna leave it for five days each day it's gonna divide the money in five and then essentially it won't invest more than a fifth of the money in any of the stocks at anytime and then at the end of the day we'll see how much we have and then the next day it will do the same thing alright so let's run the first date you know what actually while ago here I just want to mention that today's video is sponsored by kite kite is an auto completion engine for python that integrates with a ton of different text editors like atom visual studio code sublime vim and pie chart feature number one ranked completions kites completions are sorted by relevance instead of popularity or alphabet or anything else and they use machine learning to determine what would be the most relevant suggestion at this time and that's how they're able to come up with better suggestions than any other system that I've used feature number two line of code completions and that means that it's able to actually complete full lines of code for you feature number three intelligence snippets using their machine learning they're able to actually suggest placeholder values for when you're calling different functions and lastly feature number four which is called Co pilot and co-pilot allows you to no longer have to Google Python documentation because co-pilot allows you to see the documentation right within your text editor or ID so I definitely recommend that you download kite and give it a try there will be a link in the description alright so that is day one done and this is what we ended up with four point seven dollars so I created a JSON file here where we essentially save every time we purchase a stock we save it here and this then lets me see kind of what what stocks did I buy today and what stocks did I sell and do I own any stocks currently so right now at the end of the day here we don't own any stocks which is good with that means that we sold everything before the stock market closed though if we take a look at this first one here for instance we can see that we bought this at eighty seven point five dollars and we sold it at ninety one point seven dollars so if we just do some math here then we can see that we made about a five percent profit on that particular sale or that was the particular stock and as we can see we bought that several times during that day the highest that we sold it at was ninety seven dollars so we could have if the script would have been ideal it would have just bought it once and then sold it at its highest but I'm still pretty happy with this if we take a look at the second buy I bought it at $92 and the second time it sold it at ninety-four so we still made a profit last one I bought at 95 sold at 97 so we only made profits today which is really good as long as I'm like not loosing money on the script I'm going to be pretty happy now I'm thinking that we're just gonna run this script for the next couple days and then we'll see at the end how much money I made or lost and we'll break it down day by day to kind of see what's happened each day all right so let's do that now [Music] all right so this is day five and we've now ran this script for five days and it wasn't as exciting of a result as I would have hoped as you saw the first day we made four point seven dollars so with a thousand dollar budget we made four point seven dollars which is okay that was the profit that we made that day and then on day two we made $18 point six seven cents which was quite an increase from the four point seven dollars the day before so I was really happy with that result and again there was like no losses I didn't sell anything at a loss actually which kind of makes me a little bit skeptical but I believe that probably was the result as far as I could tell there wasn't any problems or anything like that so it seemed like it was working and then on day three we came in at one thousand twenty three point oh six four dollars which is kind of where this interesting story sort of ends because day three day four and a-five all ended up with the same result so we got one thousand twenty three point zero dollars so essentially since so essentially during these five days we made twenty three dollars which is a pretty good profit but the last three days we didn't make any profit or any loss probably because the stocks that we were picking didn't actually change enough for the script to trigger to buy or they didn't change in the way that my strategy was set up so didn't end up buying anything on those days but at the end of the week we ended up with a two percent increase in profits but compounding that over time over like a year or something like that that would end up being a lot of money and that would be a pretty huge increase if it kept increasing by two percent each week or each five days all right so I'm gonna be honest and say that this I hope this was going to be a little bit more extreme like more extreme than just a two percent increase I was hoping like maybe 50% or like a hundred percent or maybe even a decrease in 100 percent or something like that just anything a little bit more exciting than 2% but I'm not gonna lie like this is what happened and again like pretty much all my videos I'm really happy with the results that I is that like really self-indulgence it'll be like I'm super happy with what I just created I feel like that kind of is but I am really happy with what I just made and I thought it was a really fun build as well and this might be something that I want to like keep working on and keep tweaking in the future so I might make another video in the future on this topic but that's pretty much it for this one and before you go I just want to mention that I've created something called clean code Friday which is where I send out a short email once every week so every Friday that contains a couple of the things that I found throughout the week that I think are interesting and I that I think you might enjoy so this would be things like books I'm reading articles I've read topics that I'm diving into apps that I've found throughout the week productivity tips coding tips and tricks and really just anything that I think you might enjoy so if you want to sign up to that you can go to Cal Tech comm slash clean code and you can sign up for it there there's also a link to that in the description but yeah that's it for this one I hope you enjoyed it and I hope I'll see you next one [Music] you [Music]
Info
Channel: Kalle Hallden
Views: 2,782,991
Rating: undefined out of 5
Keywords: Automation, coding, programming, finance, python programming, python trading bot, python trading algorithms, python automation, python trading, forex python trading, build python trading bot, python trading bot tutorial, 3commas trading bot, crypto trading bot, bitcoin trading bot, watch me build a trading bot, forex trading, trading bots for beginners, programming trading bot, programming trading algorithms, algorithmic trading python, python programming for stock trading
Id: -MHhA-Y3DSk
Channel Id: undefined
Length: 13min 46sec (826 seconds)
Published: Fri Dec 06 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.