How to decide to buy cryptocurrency using Python?

Oğuz Kırbıyık
2 min readMay 25, 2022

--

In the first step, I defined a few rules. We see the buying frequency of a crypto currency that we choose according to these rules.

In the image above, we see the buying status of bitcoin with the indicator I created, as well as the open, the close, the volume position etc. values of bitcoin in the last 24 hours.

The rules I define as catalysts are as follows:

  1. Select last 24 hours data from Binance
  2. RSI ≥20 && RSI ≤80. However, it should be RSI≥50 for buying signal
  3. MACD ≥ 0
  4. SMA(50) > SMA(200)
  5. Close Value > SMA(50) && Close Value > SMA(200)

First of all, we may not know the meaning of some terms. I am sharing the links.

What is RSI?

What is MACD?

What is SMA?

Can be used in other indicators. However, I used these 3 indicators while creating the algoritm.

Install Libraries

Then we have to install some libraries:

pip install pandas
pip install numpy
pip install python-binance
pip install ta

The Code

Now we start to code.

At what times is it possible to receive cyrptocurrency with the signal class

With the decide function, we define the rule we defive above as df[‘Buy’]. If df[‘Buy’] = 1, the cyrptocurrency can buy.

The class Order is defined,and we can call the class in the main.

If you run the code with jupyter notebook, you can generate the result as in the image below via pandas dataframe.

You can visit my github page for the complete code.

--

--

Oğuz Kırbıyık

Python 🐍 + Data Science 🚀 I have been developing software in the field of bot software and finance. https://github.com/oguzkdev