Create AI Agent Trading Bots (Stock, Options, Crypto) β
Let's build with Zapier and AI (100+ videos)π
2025-02-08
Transcript β
[00:00] and there we go we have successfully set up an AI agent that will automatically trade on our behalf we could be sleeping we could be cooking food doesn't matter is trading looking pretty good let's build an AI agent that's going to be able to trade stocks on our behalf your next question might be is Corbin why is there a bunch of politicians behind you is because this AI agent we're going to train on us politicians trading data and trade off that the best part though is that this is going to require no code all automatic and let AI do the heavy lifting of the actual trade and on top
[00:31] of that you're going to be able to laser in this AI agent to trade on whatever you care about so if you're like Corbin I don't really care how us politicians trade then that's fine you're going to be able to see how you can laser this in for whatever you think is relevant for a trade sound good let's jump in welcome back y'all in today's video we're going to be creating a algo trading bot that trades on our behalf and the reason I have that little alpaca behind me is because this is what's going to give the AI agent the ability to trade stocks so instead of you sitting at your computer like Corbin I have to hit buy and sell
[01:03] no no no we're going to let the robots do that and the best part is I'm going to show you how to do this with no code all automatic using zap your agents I've done tons of videos on zap your agents so you can check them out I'll leave a couple in the description that shows you how to do web parsing I believe another one there will show you how to automatically respond to emails but one thing as I was playing around with this that this can do which is awesome is basically be a trading bot so before we dive any deeper this video is sponsored by zapier and this is part of my ongoing series with zapier we keep jumping in calls and we're like yo what's really cool what do you want to do and I'm like
[01:33] you know what let's show them how to create a trading bot that could be used on Wall Street sound good let's jump in last side note this video is kind of inspired by Nancy Pelosi stock trading because like there's like a whole Community behind this you might not know this but there is like a ton of websites and Community around just Nancy Pelosi as a politician not all the politicians which I'll show you how to do in this video but in theory if you just want to track Nancy Pelosi stock trades you can with the method I'm about to show you in this video enough talking let's do it first thing we need to do is sign up with an account on alpaca I'll leave
[02:04] this in the description down below sign up for free so here we go once we are logged in this is going to be a paper account obviously to trade real money you'll just essentially create a real account connect Bacon account etc for now though all we care about is seeing how we set this up so let's get our API key it does look like we'll need to enable an authenticator so we'll do that activate if you don't have an authenticator app just go to your app store type in authenticator app you'll be able to download one for free so now that we're logged in here we're going to generate a new key for the account obviously you would generate the new key for the Live account when you're ready to go I got my key right here so I'm going to go and copy I don't know if I'm
[02:35] going to blur that out in editing I might not but if it's right there you can go ahead and try to use it it probably won't work so once we have that though we're going to come back to zapier go ahead and go to the ABS section on our sidebar here we're going to look for alpaca it's the first result but we can just go ahead and search it anyways Alpa go in here I'm going to delete this old one because this is like as you can see a year ago so we're going to do a new connection here add connection and there we go it's actually really nice here so we can go and just hit paper allow we are connected this part right here is fundamental as this is the part that's going to allow us to
[03:05] actually trade the stock or sell the stock what's really cool about a pack of two you can do this with crypto you can even do this with option contracts as well if you like that want to be a little risky sometimes you got to be risky I do like options now that we set that up let's set up our AI agent yes our money maker our really good time maker let's go ahead and call this agent algo Trader start from scratch one thing I love about zapier agents that is really hard to access throughout the entire Market is its ability to web scrape any page so traditionally if we
[03:36] were to do the logic I'm about to show you right now we would have needed like an RSS feed in order to identify when new data is available but what you'll notice is typically RSS feeds aren't really that readily available now I did a whole other video showing how to create a trading bot that's based off stock news just like General RSS feeds but this one we're going to make a little bit fun and we're going to trade based off US representatives so here is what're we're going to do we're going to go to do run Behavior here create behavior let's start off Untitled Behavior we're going to say this us rep
[04:07] trade call it that nice instead of on demand because we want this to work whether we're asleep away from our computer or maybe just in the Bahamas on a beach just drinking a peanut colada we're going to do scheduled and the way we can do it is we can do every day time of day we'll do on Market open so for me it's around 8:30 a.m. for you would be whatever your time zone is also This Is Us markets now because the markets aren't open on the weekends we don't care so we're going to do trigger on weekends no nice so here's the situation as I drink this amazing Houston blend of
[04:39] coffee nice little cinnamon in it so we're going to build this step by step and while we're building this we're going to be testing it here is step one here is a website link of the recent trades made by US representatives what I want you to do is find the most recent trade and output the stock ticker in US Representative website link and then provide the relevant data here the way I got that website link is I simply just went to this page and as you can see this shows most recent trades and then I come up here and copy the underlying link here past over this method can be applied to any website any context
[05:11] anything you care about follow the same step so let's first off see if this even works we should be expecting an output here of french hill and CVS start instructions and test I want to point out as well in reality the only thing we really care about is the stock ticker to make the trade I also included the US representative's name because that gives you more context of maybe things you care about maybe there's certain US representatives that you don't care about their trade so just ignore that and you'll see how we can ignore certain things depending on the flow past this there you go successfully passed stage
[05:42] one here where I identified french hill in CVS as the most recent trade and obviously with the stock market and how the stock market Works timing is very important that can make the difference between a trade you make 100% on and a trade you make like 12% on that's why I like options okay let's do this because I don't really care about the US Representative if you do put it there I going just do stock ticker and then next step would be this what I'm about to show you right here is going to work and when I did it I was like this is awesome
[06:14] like you can apply this to anything based on the result check if it is a previously traded stock here how do we do that Corbin watch this we're going to use an action called storage and the first thing we need to do is we need to see if this was already previously set right to do that we are going to do get value what is storage how do we leverage this I want you to think of storage as this is like our little notebook of like okay I already traded CVS two weeks ago therefore I don't necessarily want to do another trade with CVS for XYZ reason
[06:44] this kind of logic can be applied elsewhere but the idea is this set a specific value we're going to store data towards a key right so we're going to say us politics trade and what happens is that we'll create an array here when I say array this is like data point 1 data point 2 data point 3 the first data point that will be put here will just be the ticker this will make more sense as we get going here but as you can see if no search results are found we're going to do this set specific value for this field and we're just going to Mark as successful because if no search results
[07:16] are found that means that we haven't traded this stock before which means that we're greenlighted for the next stage here watch this so that's getting the value we're checking it but that means that if we haven't traded this stock before and we haven't stored it in in that key before let's go and set it then so we're going to do another action here we'll do storage again this storage block is like extremely underplayed with zapier like a lot of people don't even realize it exists trust me you can really create some cool automations with this I'm might to have to do a whole separate video on it but for now we're
[07:46] going to do get value so we're not setting the value or sorry we're going to set the value because we already did get value in the previous step here we're going to do set value here and one thing I want to point out is you're going to say based on the result check if the previously stocks traded here in if it's there then exit out of all actions because we just want to leave the trade like we don't want to actually trade it we've already traded it before let's just leave the situation if it doesn't exist in this storage let's go ahead and set this ticker here and this is where're going to be setting our value what's very important here is that we're going to be setting it towards the same key us politics trade this has to
[08:17] be spelled exactly like that so we're going to say set specific value boom and then we can just let the agent handle the actual value is going to put in the field because that's going to be a variable depending on the ticker that is found with in this flow save so this makes more sense here I'm going to add one extra line here just so we can see Clarity of all this like this all this working together right here's the situation and here's what we're going to expect right here if this is a new ticker that we set say yes new ticker and the ticker name if it's an old ticker that we've already set say we traded it already therefore what we
[08:50] should see in this first runaround is going to be yes new ticker retest Behavior because we've never traded and stored that value in CVS but on this second time around it's going to say we've already traded it already this kind of logic that you're about to see right now this going to apply to a lot of stuff we should also see the thought process here from our AI agent basically being like yeah look it let me check if we've seen this ticker before like is this not awesome this is cool and then obviously it hasn't seen it yet so the next step is like okay we haven't seen it let's store the ticker then storing
[09:20] it now in testing it's going to approve whether or not this is a correct way of handling the information which obviously is because that's the ticker CVS and then we should be saying here yes new ticker and the ticker name talk about like next level people are underplaying agents right now there is so much you could do that's just cool let's keep going actually before we get going here let me show you how advanced these agents are it really gives you context of what you can do here retest Behavior CVS already exists in that data storage now therefore this is going to say we
[09:50] traded already oh yeah oh yeah we in the future now we traded already the most recent trade was CVS but this ticker was already in our storage I like it so knowing that we may have to just change our prompt here from like the most recent trade to like the second most recent actually what we'll do then is we'll just change our storage key so like let's say you're building up a bunch of tickers and after a while you're like you know what Corbin it keeps like overlapping and I'm having issues just add like a one there it's going to be a whole new storage bucket here and it's going be able to reference new trades they give it like cleaning
[10:22] the Slate now here's what's cool now that we've done that let's do some research this logic right here is malleable approach this how you want to approach it for your threshold of either buying or selling SL shorting and obviously the other stuff when it comes through option contracts and everything of that nature it's simply this though based on this stock ticker I want you to do more research whether the stock is a buy or sell from there you can add more context of like only buy it if the floats this much only buy it if it's epy is up 10% Etc based on your research give me a buy score out of 100 if it's over 70 then we'll say it's a buy and do
[10:55] and then I'm placing the action here from earlier from aaka place order so we're going to use your apal account here for the symbol we're going to let the agent generate that because it knows a CVS or whatever the ticker will be for the side I went ahead just set the specific field to buy so just knows to buy quantity you're definitely going to have to set this I just put 10 are you trading 100 are you trading a th000 your discretion and that's like stock amount how many stocks you're buying notional agent and then the type could be limit depending on your context I'm going to just say Market everything else is the agent hit save and then if it's below 70
[11:27] then do nothing let's just exit out because this is not signaling a buy based off the AI agent research watch this no coding just prompting retest Behavior algo Trader is on it loading in the website that we provided as data Capital trades.com trades checking if it's already been traded before in the past and because we cleared that storage it's not going to find it so now it's going to store it nice and it's going to start analyzing if it's a good investment this little approved situation won't pop up when we actually
[11:58] turn it on this is purely just because we're testing within this little environment so we're going to say approve for now here we go now it's going to be researching whether this would be a good buy and based off our scoring it should be over 70 in order to incur a buy and that score can be different right so maybe your threshold is 50 maybe it's 95 whatever it may be set that threshold O Okay it received a 58 out of 100 so this was not a buy I guess you saw the version of it not placing that order let's make it so it actually does place the order though just so we can get an idea so I'm going
[12:29] to go ahead and real quickly reset my storage buckets here so we can kind of go through the entire flow again and because it gave it a 58 there we're going to lower like our threshold to like if you say it's over 40 then buy and do I would not encourage that I definitely want to encourage that retest Behavior while that's running and loading here you can come to your alpaca account go to home and this is where you're going to be able to see all your trades and there we go we have successfully set up an AI agent that will automatically trade on our behalf we could be sleeping we could be cooking food doesn't matter is trading looking
[13:00] pretty good and one thing I want to point out that's going to be really cool that we're going to be able to add to this algo Trader in the future is our ability to actually watch the news or any videos on the topic of stocks crypto and the markets pretty soon here the platform of bump UPS is going to have API documentation available that's going to allow us to watch any YouTube video any news feed video any type of video and we're going to be able to analyze it and see if the trade is good or not API and bump UPS pretty soon that concludes today's video make sure you leave a like if you found value in the description down below I'm going leave my other videos on AI agents that you may be
[13:32] interested in without further Ado I'll see you in the next video algo trading bot two random videos that's my face I'll see you in the next video