Building a Basic Crypto Trading Bot in Python
Applying technical analysis to build a trading bot in 3 simple steps with ~125 lines of code

Cryptocurrency is a digital asset or a digital form of money that is built on the blockchain technology. Similar to stock exchanges there are crypto exchanges through which the cryptocurrency can be traded.
In this article we will build a simple bot framework that will automate the cryptocurrency trading by using some of the popularly used technical indicators like relative strength index (RSI) and MACD.
Though this article focuses on cryptocurrency, similar approach can be applied on other trading instruments (stocks, forex etc) as well. Couple of reasons for using crypto in this article, the cryptocurrency market operates 24/7 and hence the bot can be kept running. Also, the cryptocurrencies are normally very volatile, which makes it an ideal candidate to try out the trading algorithms.
DISCLAIMER: The goal of this article is to share some of the learnings on building a basic bot framework to perform algorithmic trading. This article is a programming tutorial only and is not intended to be any kind of investment advice.
BUILDING A TRADING BOT — 3 STEP PROCESS
STEP 1: Connect to an exchange to fetch the live data
STEP 2: Apply a trading algorithm on the data
STEP 3: Execute the trade

There are two instances where we need to interact with the exchange. Firstly, to fetch the data and run the trading algorithm on it. Secondly, to place the buy/sell orders to trade the assets.
In this article there are two different packages used to interact with the exchanges. The ccxt package is used to fetch the data from the exchange. The trading algorithm is run on this data and when a trade order has to be placed I have used the APIs provided by an exchange with which I have a trading account (WazirX).
In case you have an account in any of the other exchanges that provide public APIs to fetch the data and also to place orders, then the same can be used.
STEP 1: Fetch the live data
CCXT (CryptoCurrency eXchange Trading Library) is a library to connect and trade with cryptocurrency exchanges and payment processing services worldwide.
We will be using this library and the Binance exchange to fetch the price data of the cryptos. Any other exchange or api can also be used for this purpose.
Refer here to view the latest manual on ccxt which has the details on the interfaces that it provides.









