Stop! Can I have your attention for a moment?

Do you want to change your life? Join me on my 50-Day Life Transformation Challenge. Get involved! It won't cost you anything except a few bad habits.

Program a crypto trading bot

BTC to USDT Chart: Buy here sell here

I want to develop a crypto trading bot that automatically buys and (hopefully) sells cryptocurrencies for a profit. In this series of articles, I document how I go about it and whether it can even work.

I bought my first 5 Bitcoins about 10 years ago: 5 of them at a shockingly ridiculous price. I don't remember the total amount, but it certainly wasn't more than 10 euros. The story could be beautiful if I hadn't sold those things a few years ago for just under 600 €. Crazy: 600 € for some virtual numbers in a digital wallet. But the joy of that didn't last long, because shortly after my sale, the Bitcoin price climbed to around 8,000 €. So if I had waited a few weeks, I would have had a whole 40,000 € in my pocket instead of 600 €.

But it got even more blatant: at the current Bitcoin rate of around 39,000 €, it would have already been 195,000 €. Phew! No matter: one should not mourn bad decisions and a return is a return.

At this point a warning: I am not a professional trader. This is a hobby project to learn more about cryptocurrencies, programming and machine learning. Here all sorts of things can go wrong which can mean especially certainly also a total loss of the invested money.

What is actually a trading bot?

And what exactly is crypto trading? That's easy: Crypto trading is trading cryptocurrencies, i.e. Bitcoin, Etherum, Monero, etc. There are now countless crypto-currencies and Bitcoin is only the best known here. You can trade Euros for Bitcoins, Bitcoins for Monero, Modero for Euros, Ethereum for Bitcoin, Bitcoin to US dollars and so on.

And a crypto trading bot is a robot that does this automatically. But it's not a classic robot at all: it's actually just a program that runs on a computer or server.

And a crypto trading bot is a robot that does this automatically.

How can you make profits with it?

The theory is simple: I want to buy bitcoins at a cheap price, then wait until they rise in price to sell them at a higher price. The difference is then my profit.

An example:

Currently, Bitcoin is trading at around 42,500 €. So I have to pay 42,500 € to get one Bitcoin. Quite a lot of money for such an experiment. Fortunately, the Bitcoin is divisible: it has 8 decimal places. So if I want to invest 100 €, I will get exactly 0.00235294 Bitcoin or BTC for short.

Like other currencies, bitcoin is subject to more or less strong fluctuations. Within seconds, a new price is determined, which is then either higher or lower than it was just a few seconds before.

BTC to USDT price: buy cheap and sell expensive
Price history BTC/UDST: The white lines show when I should buy Bitcoins. The yellow ones show when I should sell them.

Now if the Bitcoin price rises to 42,750 € I can sell my 0.00235294 BTC for 100.59 €. A profit of 59 cents.

Quite sobering, isn't it? Yes.... But: suppose the trading happens automatically? And on a minute-by-minute basis? And this is where the trading robot comes in. And the fact that these price fluctuations happen every second.

What does it take?

1. a trading venue

In order to be able to buy and sell cryptos at all, you first need access to a crypto trading venue. I'll keep it short at this point: I chose According to Wikipedia, it's the largest crypto trading venue in the world. Whether measured by active traders or revenue, I don't know. Probably both apply.

Much more important than size is something else: Binance has an API (API = Advanced Programming Interface). This is an interface through which you can access the crypto marketplace to automatically buy or sell Bitcoins.

Binance has an API (Advanced Programming Interface).

2. A Strategy

Buy at cheap rates and resell at higher ones. Actually quite simple, yet not so easy to implement. How do I know if this is the lowest price right now? Maybe it will rise again soon and I will be annoyed that I did not buy earlier? Or the other way around: I buy and the price falls even further afterwards - that would also be annoying.

So how do I know if the price is about to rise or fall?

Quite simply, I don't. And it's not relevant to me either. I want to take advantage of short-term price jumps, and they happen almost unpredictably. So for now, my strategy is pretty simple:

BTC USDT Chart Ticker
Real-time Bitcoin price change.

I first determine the current price and then place a buy order and a sell order each 0.5% away from the price.

Example: Suppose the BTC price is at €38,000. I then place a sell order at €38,190 and a buy order at €37,811. Placing an order means that I tell my trading desk (Binance) that I want to sell Bitcoins when the price rises above €38,190 and buy some when the price falls below €37,811.

Now I keep an eye on the price: if it rises or falls only slightly, without triggering an order, I pull the orders if necessary.

This absolutely simple strategy (I don't even know if one can speak of strategy at all), should now be done for me in the first step by a program.

My goals in this project

  1. Learn more about cryptocurrencies
  2. Operate a crypto bot that trades on its own
  3. Implement and test an initial strategy
  4. Take lessons learned from testing and improve the strategy
  5. Develop a machine learning system that autonomously switches between multiple strategies

This post is part of a series. The next part will be about setting up a trading bot and implementing the first strategy


Subscribe to my Newsletter

Join a growing community of friendly readers. From time to time I share my thoughts about rational thinking, productivity and life.