CoinNewsToday - Global Blockchain, Bitcoin, Ethereum and Altcoin News
CoinNewsToday
Trading

The Starter’s Guide to Coding Killer Crypto-Trading Bots

Learn where to start, how to approach the process, and the dos and don’ts of coding trading bots.

So you can code, got into crypto, found out about crypto-trading, and knew that—sooner or later—you would give it a shot at building a trading bot.

Trust me, you are not alone.

I don’t know of a single developer that got into crypto to whom such an idea never crossed his or her mind.

The question is what do you do with such an idea? Where do you start?

The answer depends a bit on what your motivation is.

If all you wish to do is put your skills to the test, give it a shot and see how it goes, then this guide is not for you.

If that is your motivation, you will likely choose to start trying stuff right off the bat. You will connect to your preferred exchange and start placing random orders. Then you will try to build on top of that basic functionality and maybe start working on the trading intelligence side of things.

That is fine if you wish to play it by ear and get a feel for how algorithmic trading works. However, the road of free exploration will unequivocally lead you to make all the mistakes there are to be made and wasting your time in unproductive work.

This guide is for coders who wish to succeed and make money doing automated trading.

If that is your motivation, then rest assured that you will approach this project like most other development projects: with an appropriate structure.

After all, a proper trading bot is very much like a mission-critical transactional system. It needs to be reliable, secure and stable, thus, it should be built following best practices.

Let’s start with the basics…

Use a Platform

Coding a stand-alone trading bot makes absolutely zero sense. It’d be pretty much like reinventing the wheel.

There is substantial software infrastructure required to reliably run a trading algorithm. You do not want to build that infrastructure. Coding, tuning and stabilizing such infrastructure may take years’ worth of work of a senior developer; such is the level of complexity entailed.

Your focus should be on building the algorithms that carry the trading intelligence instead. Not only is it the fun part of building trading bots, but is also what will determine if your bot will be profitable or not, all other things taken for granted.

Before diving into the trading intelligence subject, let’s briefly review the most important features of the infrastructure that a good trading automation platform should provide.

Exchange connectivity:

Exchanges expose APIs which may evolve and change over time. This is a long-term challenge if you have to maintain different connectors on your own.

Connectivity through the Internet is tricky for mission-critical applications. There are tons of issues that arise regularly that may break, delay or corrupt your interactions with the exchange, at the application level, at the network level, at the exchange’s API and internal systems levels, and everywhere in-between.

A good platform should be able to handle all sorts of connectivity issues and guarantee the integrity of transactions at all times.

Trading engine:

The placing of orders may seem like a simple problem at a glance. However, the trading engine should provide enough intelligence to track and administer orders, handle responses from the exchange and support the intelligence your trading algorithm will require in terms of order execution.

Data:

Algorithmic trading is a data-driven application. Your algorithm requires reliable data both to test the strategy and to make trading decisions. This means you will need both historic data sets and live data feeds from exchanges.

Exchanges serve raw trades or candles data in small chunks. You will want to have access to the complete market history so that you may apply statistical studies and use long-term indicators such as moving averages.

A single hole in the data set may skew results in unpredictable manners, so the processes extracting data from the exchange and building your data sets must be bullet-proof.

Strategy testing environment:

Needless to say, you should be able to seamlessly test your algorithms over the historic data set, or what we call backtesting. You will also want to be able to test the strategy forwards with live data, both without placing actual orders at the exchange—what we call paper-trading—and placing real orders with a small fraction of your capital—what we call forward-testing.

This is basic functionality that will be of great use during the strategy-tuning phase before you deploy your bots to trade live.

Now, there are more advanced platform features that may have a huge impact on the profitability of your strategies.

Such is, for instance, the ability to analyze your strategy performance not just on an aggregated backtesting report, but on a per-trade basis, directly over the charts. When you can go over the test results and visually check each of the actions your strategy is taking, then you will be able to fine-tune entries and exists in a much more precise fashion.

The visual element is a fundamental feature as it is you—the human—who will design the trading strategy. The average human is not that good at crunching cold numbers mentally, but is quite good at finding creative solutions when senses are involved.

Trading protocol:

A trading protocol implemented at the platform level is a sign of relatively deeper analysis and ambitious platform development goals.

The protocol is instrumental in the standardization of how strategies are built and described, which has multiple positive outcomes.

An immediate effect of standardized strategies is that they become portable. Portability enables collaboration of groups of traders and developers, which results in a collective intelligence stronger than that of individual members in the group.

In the long run, standards favor the growth of ecosystems and promote the development of new applications, attracted by an existing market and user base.

Go Open-Source

Going with an open-source platform is a very good idea, as you will be able to contribute to the platform development in case you ever need features that may currently not be present.

Also, you do not want to get your algorithms trapped into a corporate platform which may change its terms of service, commercial policies, business model or even deny access at any point in time.

Evaluate different platform options taking into account the relative difficulty of setting up the development environment as well as the quality of the available documentation. Those two features tend to be a good indication of how well maintained the platform may be.

Learn the Theory

There is no work-around to lack of knowledge. If you don’t know what you are doing, chances are you will waste your time and your hard-earned cash too.

That said, do not worry if you are at a beginner level… just make sure you start your education in Technical Analysis. Then you may go as deep as you are willing to go reading about Statistical Analysis, Game Theory, Risk Management, Portfolio Management, Markets Psychology, and Macroeconomics.

If you are trailing behind in the trading-knowledge department you may also want to consider partnering with a trader friend who can’t code, so that—together—you may come up with a few winner bots.

Adopt a Trading Framework

I’m sure you’ve heard the phrase “you’ve got to stick to your trading system”. Ever wondered how to come up with one in the first place?

A trading framework will help you understand and describe the trading process. It will enable you to structure your trading ideas, breaking strategies in stages, and organizing the different concepts into elements with properties that interact following certain rules and events.

As you know, automating a random or unstructured process is quite challenging, so following a trading framework is the correct approach if the end goal is automated trading.

Community

Make sure the project has a welcoming community that will help you get up and running quickly.

Some communities may be rather hesitant about helping beginners or anyone at all for that matter. Remember that trading intelligence tends to be developed in silos and most traders are somehow wary of letting their secrets in the open.

That said, other communities are most welcoming and willing to openly share knowledge and sometimes even strategies.

What’s Next?

That’s about it!

Now it’s time to get your hands dirty!

You may want to start by checking my work at the Superalgos Project: we are building a Collective Trading Intelligence with people like you.

The first step in the roadmap to build such intelligence involves democratizing access to state-of-the-art trading technology. That is why we recently pre-released the Superalgos Desktop App, an open-source client app that helps automate trading strategies.

Disclaimer: I am not a financial advisor and this is not financial advice. I share strategies and my own trading experiences as a means to disseminate knowledge. You are responsible for whatever you choose to do with the information I share.

Image from Shutterstock

Related articles