How To Build A Crypto Trading Bot

This time I decided to pick up a trendy topic, where I believe I will be able to add a different angle through my expertise and provide a basic guide on how to set up a bot if you are just starting. Since the crypto prices surge more and more, people get lured into understanding more about how the distributed ledger works and consequently their interest in programming languages. Algorithms were strictly reserved for the institutional traders a few years back, but due to technology advancement, faster internet connectivity and availability of open-source projects this strategy is easily accessible to individual traders today.

One of the easiest and hassle-free options is simply to use a third party’s plug-and-play algo. Multiple firms offer their automated trading strategies online, which one can directly connect to a crypto exchange account. It requires no technical skills and can implemented immediately.

For fellas with no programming skills, but enough trading knowledge there are platforms providing the interface with input capability. After choosing all the trading rules, the platform will process it and generate it in a code form, which can be connected to the crypto exchange.

If one wishes to have unlimited flexibility, to do their own custom rules and back testing the only solution is to program the bot from scratch. For conventional market traders familiar with MT4/MT5 and MQL4/MQL5 a bot can be directly set up in the platform, but coming with lots of imitations, so I would suggest that only if let’s say you have a volume based trading strategy on BTC which you want to automate. JavaScript is also a very popular language with community support, but harder if starting from scratch. Regardless of previous experience programming in any language, I would recommend using Python, which is very user-friendly and one can utilize the multiple automated trading libraries. Here we have huge open-source bots available, which we can use as a foundation, or build our own code with the ultimate freedom to be creative.

Step 1: Picking the exchange, API and trading instruments

You need to make sure that the exchange you will be trading at has a public API (I would recommend using FIX, which is faster than REST, more scalable and used for pro trading in conventional markets as well) and build your code according to it and not the other way around. Additionally, choosing your investment products range by checking on their daily volumes and volatility.

Step 2: Choosing where to host your bot

The crypto markets are open 24/7, so ideally you will be running the bot non stop. Running it on a computer for testing purposes is possible, but if you want to scale it up and optimize, it is better to rely on a cloud service such as Azure, AWS or Google. A short note: Google Colab allows you program, execute and host online which is a simple solution for beginner traders, if you want to test and gain better understanding without the need of downloading python and all the libraries.

Step 3: The Strategy

Here the sky’s the limit, based on your risk profile you can scan through multiple strategies, the most famous are arbitrage, mean reversion, trend following, standard deviation, reversion etc. I personally prefer technical analysis based strategies for more well established cryptos like BTC and ETH, since they are also highly customizable.

Step 4: Back testing

The back testing is the most crucial part of creating a successful trading algorithm, starting with collecting data on the pairs that will be traded and formatting it. Splitting the data into two samples for training and testing 70:30 will help back test the strategy on the 70% of the data and then use the 30% as a forward looking data set. You may download a data set to excel or directly connect your code to an API and download real time. Generally speaking, algorithms achieving 50% + accuracy are considered successful, so if your algorithm scores anywhere above it should work well enough with the proper risk management tools in place. One other way to evaluate it is to compare it to a benchmark of a buy and hold strategy – for example, if we bought BTC in January and hold until June would have generated a 40% return, then that will be the minimum expected return of the algorithm to proceed with deploying it.

Step 5: The Code

Importing the data; An easy way to import the data is through Binance API, especially if this is the platform that you will be using for the trading as well. Defining the logic; Depending on the strategy chosen identifying the buy and sell signals.

Portfolio size: Fetching your existing portfolio to the algorithm to be able to calculate the positions size and risk.

Risk measures/Stop Loss based on the strategy, you may add a cut-off level at which the algo will close all trades, partial take profit if multiple positions are opened etc.

Buy/Sell order size based on the portfolio size and the risk parameters. Freqtrade: https://github.com/freqtrade/freqtrade

Freqtrade is a free and open source crypto trading bot written in Python. It is designed to support all major exchanges and be controlled via Telegram. It contains backtesting, plotting and money management tools as well as strategy optimization by machine earning.

Pycryptobot: https://github.com/whittlem/pycryptobot

This bot is based on technical signals generated by the EMA12 and MACD indicators.

Crypto Trading Bot by JPStrydom https://github.com/JPStrydom/Crypto-Trading-Bot

This bot can be used to autonomously trade and monitor over 250 crypto currencies on Bittrex. Users can configure their own custom trading parameters which will control when the bot buys and sells. .

http://genesislat.com/

As a Co-Founder & Investment Director of Genesis Capital LATAM, Paula is actively managing the Capital Markets Fund with a focus on delivering steady returns with limited risk exposure, while overseeing the existing PE investments Paula leads the decision making on FinTech and Digital Initiatives. As a serial entrepreneur, Paula takes place in the World Business Angels Forum (WBAF) Global Startup Committee in addition to representing WBAF in the United Arab Emirates, which as organization aims to ease access to finance and know-how for businesses from startup to scale up. In 2018, Paula co-founded a UAE/KSA Fintech startup in the Shariah Capital Markets space, seeking to lead the industry initiative of standardization and automation. Prior to entering the FinTech space, she had structured both conventional and Islamic cross-asset instruments in a top tier UAE bank, introducing innovation and exotic structures to the Shariah space. Previous achievements in trading and research spread across MENA and Frontier Markets. She holds a B.A. in International Finance from Istanbul, Turkey, an MSc diploma in Financial Engineering with a concentration in automated trading systems from the USA, and a current Ph.D. candidate in the derivatives field.