Crypto Trading
Guide on writing a trading bot in 2022
So you have decided to start riding the waves of the candle chart.
In this article, I will guide you on a high level towards setting up a good trading bot.
How does an exchange work
Learn how an exchange works and how to learn the candle charts. This is one of the important skills to learn because this is your foundation. We are talking about trading, but what is a trade, and what does it mean to have a position on the market, for example?
Here are a couple of exchange terms
- Entering a position means that you are going to buy
- Exiting a position means that you are going to sell
- Having a position in that market means that you have bought a cryptocurrency or a stock
- A trade means that you have bought a cryptocurrency or a stock in the past and have sold it
Second, learn about Technical Analysis, or TA for short. Think about RSI, SMA, EMA, MACD, and VWAP. These are all metrics that you may want to dive into to learn how to calculate these and how the formulas are created.
Having this knowledge makes coding the formulas later on easier.
The coding language
A lot of trading bots are written in python, but that does not mean you have to. I wrote mine in TypeScript (compiles to JavaScript) and it works fine. Choose the language you are most comfortable with. Otherwise, you will hit the limit of your knowledge with AI python.
Choosing an exchange
I choose Binance, but I’m slowly adding on other exchanges to cover more pairs or have other pairs running with a different type of risk setting.
Choose the exchange you already have or the one that you like the most. Also, keep in mind that they need to have proper documentation about their API.
The bot
The bot should consist of a couple of mechanisms. Each of these should be as isolated as possible to ensure no crazy side effects.
Have a mechanism that handles
- Order Creation (buy and sell)
- Follow the order progress (the larger the order the longer it takes to be filled, and you don’t want to create multiple orders at the same time, right)
- Your wallet values (AI BTC and USDT)
- Send notifications (optional but nice)
- Refresh the ticker price
- Refresh/re-calculate the Technical Analysis markers
And the most important mechanism, the core, uses all the data from these other mechanisms and then determines whether to buy or sell.
Wrapping it up
Please also note that there are risks involved with trading, and you can lose money if it’s not set up right. This is a high-level guide, and you have you figure out how to tie this together.
Have fun, learn and take the time, You won’t create this overnight.
This is harder than it looks, trust me.
—
If you liked this article, don't forget to clap for it and leave a comment on how you would create a crypto bot and follow for more crypto trading content.
The exchanges I use have perfect rest API documentation (Affiliate links)