5 Steps For Creating An Algorithmic Trading Bot

Milan from Amplify Trading walks through building an algorithmic trading bot in five steps: building a custom platform for data and backtesting, developing a proprietary trading edge beyond public strategies, converting your strategy to pseudocode, testing it against baselines like buy-and-hold, and connecting it to live trading via exchange APIs.
Chapters
Hello and welcome to the Amplify Trading YouTube channel. My name is Milan and I'm a technology analyst here at Amplify Trading. So before we get into this video, if you're interested in more tech in finance or anything to do with markets in general from the rest of the Amplify Trading team, please do like and subscribe this video down below and hit that bell icon to stay notified when we post our latest content. Without further ado, let's get straight into it. Creating an algorithmic trading bot is not all about the bot itself. I think there's a huge misconception in the industry and in general about the knowledge that's required to create a bot. It's not all about the strategy, it's about creating a platform, a package that's able to backtest, live trade, and anything else you really want to do with the bot in the future. It's about creating this unique environment for you to work in and be able to successfully develop and create any further algorithmic trading strategies you want to in the future, and easily maintain and understand what is going on with your bot. So the first thing I believe you should focus on is the idea of creating a platform for receiving data from an exchange or data source of your choice, and then using this data and storing it in a way that would allow you to backtest in the future. So this can be done in one of two ways. You can either use an existing API and create your own platform around it and then link to this API and fetch data. And this is when you can connect to different sources such as CQG, Binance, for example, for Bitcoin and other relating, uh, cryptocurrencies. And you also have Interactive Brokers as well if you're interested in trading stocks. Those are just 3 to name, but there are plenty, hundreds of thousands of APIs actually available online. The second option is actually to use a pre-existing connection format. So this is when there's already platforms out there that are designed to do backtesting and connect to exchanges and generally create an environment for you to create the strategies a lot easier. And this is stuff like Backtrader and Zipline for Python. And these platforms I do think are great. They're definitely easy ways to get started into trading. The problem I've always found when using these platforms is it's not yours. If there's a feature that you want to add, you might struggle adding this feature in the future since the platform is obviously already created for you and works in a way that the original developers designed. So I always create my platforms from scratch whenever I am designing an algorithmic trading bot. So the second step is, once you have this environment set up for backtesting and fetching data for you and storing it in a safe place for you to use in the future, you need to focus on researching and understanding the strategy that you want to implement. So when it comes to researching a strategy that works for you, this is the hard part, I guess. You're on your own here, uh, and any strategy that you find online, I, I genuinely find it doesn't work. You know, when a strategy is released to the public, it becomes ineffective, um, and a lot of algorithmic traders may copy this, and as a result, it's less viable in the market, um, that we might be currently experiencing. And likewise, as the market develops and changes over time, the strategy just stays the same, so it might not be designed for the current market conditions, and it would just be a waste of time, I found, using other people's strategies. So, so do focus on creating your own one here. One of the key things here will be to create your own edge and outperform others who are algorithmic trading. Creating your own edge is a lot harder than it sounds, you know. You need to find something that works for you and gives you that advantage maybe over other traders. So this could be in the form of specific timeframes or multi-timeframe comparisons for trades, machine learning to understand the best positions to get in and scale your position size depending on the trade and parameters being fulfilled. You also have the option for artificial intelligence. So maybe you can make a bot that relies on AI to scan tweets and news feeds to make a, I don't know, social score, for example. And from this social score, you determine how likely are you to get long or short on this position. And these are just some ideas I think you need to start thinking about is what is your edge in markets and what will get your algorithm outperforming others? So the third step here is a simple sounding one, but it's far from it. It's converting your strategy into pseudocode. And the reason we change our strategy to pseudocode is to understand, is our strategy viable for the platform we've created. And what pseudocode is, is essentially a way of writing instructions, you know, like a recipe or cooking book that you might have. So you can lay out if something happens, do this, when X occurs, do this. It's just a way of writing in English the instructions that your algorithm needs to think through. It's kind of like writing your thought process down of why am I doing this? How do I get there? What do I want to do? How do I react? Et cetera, et cetera. So that's what pseudocode is. And I think that this is the key step here. You need to be able to convert this strategy that you've developed and believe in into a way that the computer can understand. One thing to know when you're writing pseudocode is don't believe that nothing is impossible. Anything that you can do manually or a task that you can complete can be automated eventually. And this is where you need that right skill set and the people potentially on your team to understand what is it that you want to take from reality into, into code or pseudocode. In this example, you have that understanding of technology to know, is what I'm asking for out of my scope, or am I going to need to, to reduce what I'm asking for? Do I need to make— is it achievable? That's the question we're trying to answer here. Is this feature that I'm implementing achievable? For me personally, adding an AI robot that scans tweets and determines the social score is currently unachievable. I think that's beyond my skill set, and that's definitely something that I think a few traders or anyone who's new to algorithmic trading might agree with. It's something that would be a nice feature to add in the future, but for now I'm gonna focus on other things. So yeah, I'm not saying this is the easy part of the process. You're essentially taking human reactions, thoughts, and the processes that we think in our head naturally and maybe on the fly and writing them down in a way that a computer could potentially understand. You're basically mapping the intentions you have in your mind to the paper, and that's why pseudocode writing, I think, is very important. Know what you want before you start coding. It is always making life a lot easier for me anyways. So step number 4, once you have this platform and this idea, you now need to bring it all together. You need to bring that pseudocode back together with your platform to create the strategy and implement it. This implementation and testing process, I guess, is the one that takes ages. This is why algorithmic trading might take a few years, or, or, you know, however long to actually develop a fully working system. It's not as easy as it may seem, and after these steps, you can finally now start making strategies and testing them out. This loop, I guess, of implementing strategies, developing new strategies, etc., etc., is the one I think a lot of traders get stuck in. Some get out and some never do, unfortunately, get out of this loop. And when you get to this stage, you need to be able to understand how do you benchmark what you're doing. You need to be able to take these results or outcomes that you achieve and evaluate them in a sense that you can actually see, is this algorithmic trading strategy I've created created viable for me? Is it, is it going to provide a future or whatever it is you're trying to achieve once we release it on the live markets or a paper trading account, for example? You need to compare this strategy to different models, and these models can be some things such as buying and holding, um, the assets that you're looking at, all the way to comparing the assets against the S&P or any other benchmark indices that you would potentially invest the same amount of cash in. And if you're outperforming the S&P or generally buying and holding the stock or assets that you're trading, then you're clearly doing a good job in this algorithm. Because the last thing you want to do is create an algorithm that has the potential for way more risk, I guess. A lot more work is needed in the maintenance and looking after the algorithm compared to just buying and holding some assets. And you don't really want it to be underperforming the ability, I guess, of just buying and holding these assets. What's the point of returning, say, 5% from the algorithm when buying and holding something can return 7%? It's kind of a waste of time and energy, you know. It's a lot easier just to buy the asset itself. Finally, after all of this, you have step number 5, which is connecting your algorithmic trading bots or platform to a paper trading or live account. And if you've created this platform in a way where you know, steps are taken, and then finally there's a result. It either goes into a position or not. You're going to have the ability to then simply replace this temporary area where it tells you that it's gone into a position with a live trading account. Use the APIs that I mentioned earlier to essentially place the orders for you onto the exchange. And that's all. Those are the 5 steps, I think, that briefly cover how to create an algorithmic trading bot. The process sounds so short and simple when I, when I lay it out like this, but it's actually a process that could span over 2 or 3 years. I've seen, um, with some algorithmic traders. If your strategy performs perfectly fine on a paper trading account, for example, you might then move it on to a live trading account, and this is when there are even more issues that occur. You have to then take into consideration slippage, commissions, and order execution times. A strategy that works on paper trading when you don't have to take into consideration all these things might actually fail on the live market, because the live market obviously behaves a lot differently. You have to worry about getting filled and not filled, and these are some things that I guess you have to also consider during this whole process. But let's just say all of that works, you've now finally created an algorithmic trading robot, and it does everything that you've initially wanted it to do. This is when you can start thinking of those other improvements I was talking about. Machine learning, for example, to increase and decrease the scale the sizes of your positions. I want to enter a position here using 10 contracts, and then the machine learning could potentially learn over time that actually a trade like this is actually very successful. I want to actually enter with 20 positions. And, and doing this simple machine learning process, I guess, um, compared to other machine learning processes, is that you can actually increase your profits without actually changing much of your strategy. Likewise, you can implement an AI I already mentioned about a social score, potentially an index indicator or whatever it is that looks at the, you know, tweets or news feeds to determine on the scale how likely is sentiment towards the, to the long side. Are we bullish or bearish? And that's what we can potentially develop here with this algorithmic trading bot. There are countless opportunities and ideas that haven't even been thought of yet. For how to improve your algorithmic trading bot. And that's the great thing about this, is once you've created this platform and you're able to implement all of these strategies on a basic level, you can then begin expanding over time with these additional features that can help increase your success rate and likewise increase the profits that you're turning over. So thank you everyone for watching this video all about algorithmic trading and, and a quick overview of how the algorithmic trading process might work for someone who doesn't understand Is it as simple as just writing up a strategy and releasing it straight on the market? If you're interested in algorithmic trading and learn more and understanding more about the process, um, from us here at Amplify, we do offer an algorithmic trading simulation. This algorithmic trading simulation takes place over a day, and it's a session where in the morning you'll learn the basics of Python. You'll be able to, to code some Python and get used to the idea of debugging and things like this. And in the afternoon we'll take you on a run through our simulation platform. And in this platform you essentially will be given some instructions, some steps. You'll go from importing data like we discussed today in step 1, all the way to the point of benchmarking against the S&P or against your assets that you've bought, like buy and holding the strategy. So if you're interested in this idea of algorithmic trading and getting to know more about it and potentially taking part in the simulation where you are going through the steps 1 to 5 that we discussed today, please do reach out to us at info@amplifytrading.com or message me directly on LinkedIn, uh, and I'll pass you forward to some of my colleagues who'll be able to help you out in getting involved in this simulation. So that's all there is for today. Thank you very much for watching this video. I hope I taught you something, uh, about algorithmic trading. And please do like and subscribe if you haven't already if you want to stay up to date with more tech and finance or markets-related videos. As always, everyone, stay safe and hope you have a great summer.
More from Anthony

Inside the Biggest Banking Stories You Need to Know This Week (Anthropic, Diageo, Private Credit)

Inside the Biggest M&A Deals You Need to Know This Week (UniCredit, GameStop, eBay, Eli Lilly)

AI Breakthrough or Hype? Anthropic’s Claude Mythos, Tim Cook Steps Down & LIV Golf Collapse







