I am not qualified to offer investment, legal, or any other advice, nor am I trying to do so. This is a programming tutorial aimed at teaching you how to build a trading bot for learning purposes. Any decisions, investments, or risks you take as a result of building a trading bot are your responsibility.

I cannot be held responsible for any decisions you make as a result of reading this tutorial. Remember: Bots can lose a lot of money, so you should be careful.

Quite regularly, we all come across some variation of this article: “10 Projects You Should Build as a Programmer”.

And most times that list includes a Trading Bot.

So, since I think trading bots are great projects, I thought I’d take some time to teach you how to build one.

However, rather than giving you all the code line by line, I decided it would be best to go through all the concepts you should be familiar with to take on this project.

After all, the whole point is that you code it yourself.

Hence, this article will go through everything you need to know and have to build a trading bot (from the exchange to a simple trading strategy), as well as the basic architecture, concepts, and design of a simple bot.

And the great thing is: I’ll be using pseudocode, so you can follow this tutorial in the language of your choice.

As such, you can feel comfortable and focus on the actual programming, rather than figuring out all the setup for yourself.

So let’s go!

Step 1: Pick a Weapon

The first step in this tutorial is just selecting a language to use. This is entirely up to you.

Some languages like Python could be helpful if you want to later expand your bot to use Machine Learning, for example, but the main goal here is that you pick a language you’re comfortable with.

Step 2: Pick a Battleground

An often overlooked step in trading bot tutorials is the selection of the exchange.

For a trading bot to work, you need to have access to an exchange where you can trade assets. This is just as important as knowing how to program.

So, for this step, you need to decide what assets you will be trading (e.g. stocks, currencies, cryptocurrencies), and where you will be trading.

Regarding the asset, I would strongly suggest cryptocurrencies. The reason for this is not that I’m a blockchain/crypto advocate (full disclosure), but simply because cryptocurrency markets operate 24/7 i.e. all day, every day.

Most “traditional” assets can only be traded during certain times, and often only on weekdays. Stock markets, for instance, are generally open sometime between 9AM-4PM and do not operate on weekends. FOREX (foreign currency exchange) markets can go on for 24h, but are also usually closed during the weekend.

As such, it is easier and nicer to have your bot running 24/7, which is what crypto markets allow for. Additionally, cryptocurrencies are known to be very volatile, which means that a) you can lose a lot of money, but b) they are a great way to learn and test trading strategies.you can lose a lot of money, but b) they are a great way to learn and test trading strategies.

Since we’ve covered the asset class, let’s now go over the two requirements for picking an exchange for your trading bot.

  1. You must be legally allowed to trade on the exchange and the assets it offers. Some countries don’t allow cryptocurrency trading, for instance.
  2. The exchange must have a Public API available. One cannot build a bot without an endpoint to send requests to.

With the two requirements above fulfilled, you may also wish to consider things like the fees charged by the exchange, if it is well-rated or well-known, and how good the API docs are.

Last but not least, I would also recommend checking the daily volume of trades on the exchange. Exchanges with very low volumes tend to lag behind in price movements, as well as make it harder for limit orders to be filled (more on this terminology later).

If you decide to go with cryptocurrencies as your asset class, here’s a useful list of the top exchanges, their volumes, and various other important pieces of information to help you choose.

#programming #python #technology #data science

A Step-By-Step Guide to Building a Trading Bot in Any Programming Language
47.05 GEEK