The Crypto Trading Bot Guide

@ AnthonytXie Anthony Xie Founder of HodlBot

Simply put, a trading bot is a set of instructions that execute trades automatically without the need for human intervention.

A trading bot has a few major components regardless of language & framework used.

Backtesting

Running an algorithmic trading strategy blind is the best way to lose all your money. To see if your strategy works, you must backtest it against historical market data.

Collecting this high-quality, tick-by-tick data is usually done by tapping into exchange APIs. CCXT is a great library that enables you to interface with a bunch of exchanges in the same manner.

In order to simulate a realistic backtest, you should take into consideration latency, slippage, and trading fees.

Usually, you can retrieve historical price data, but you cannot retrieve historical order books. Therefore some of the data can only be collected on a forward-going basis. This makes high-quality, historical data a scarce and valuable resource.

Strategy Implementation

The code that implements the strategy actually makes up a tiny fraction of the whole project. But, it is where you would specify the logic & calculations which determines when to trade, and in what quantities.

Once you’ve created a strategy, you should backtest it in order to evaluate its performance. Typically, only strategies that are very profitable make it out the backtesting phase because so much can go wrong in the real world. Be careful here of overfitting your strategy to historical data.

The universe of possible strategies is infinite. Some strategies try to predict mean-regressing activity, others may predict momentum in a certain direction. Others try to run currency arbitrage, or act as market makers.

Execution

Once your strategy is determined, the next step is order execution. Consider this a bridge between your strategy and the exchange you are trading on. This code turns your strategy into API requests that the exchange can understand.

Some bots will have a paper trading feature, which will allow you to simulate your strategy in real-time with fake money.

Job Scheduler

Lastly, you want to let your bot run autonomously. Leaving your computer on all day is not a good option. You want to spin up a server and set-up a job scheduler to execute live strategies automatically.

Why Use Trading Bots?

Save Time

Calculating trades and executing them by hand is time-consuming and tedious work. The most difficult part is coming up with a strategy. Once you’ve done that, there’s no need to waste hours cranking repetitive work. Bots can do it for you.

Efficient Execution

Bots are much more efficient at placing orders than humans. You may be able to place one trade at a time by hand, but instantly be able to place fifty with a bot.

There are a lot of strategies that are simply not possible to do by hand. Manual calculation and execution would take too long and cause the opportunity to be missed.

Consistent Strategy

It’s very difficult to follow a consistent strategy by hand. Emotions often get the best of us, and we make changes to the plan on the fly.

Algorithmic trading takes the emotion out of trading and can consistently execute the same strategy over time.

Types of Crypto Trading Bots

Unless you’re a developer with a lot of time on your hands, you probably don’t want to program your own trading bot. Luckily there are tons of free & paid options available. I will be going over the 4 main types of crypto trading bots and provide examples for each.

1. Arbitrage Bots

When you buy an asset in one market and simultaneously sell it in another market at a higher price, that’s called arbitrage.

There are two different ways to arbitrage cryptocurrencies. The first is by finding prices mismatches through different trading pairs on a single exchange. The other is by locating price differences across multiple exchanges.

Here are a few trading bots that feature arbitrage strategies.

Blackbird

Blackbird Bitcoin Arbitrage is a C++ trading system that does automatic long/short arbitrage between Bitcoin exchanges. To run it, you’ll need to clone the repo and follow the installation instructions.

Requires Coding: Yes

Price: Free

Features:

Unlike other Bitcoin arbitrage systems, Blackbird doesn’t sell but actually short sells Bitcoin on the short exchange. This feature offers two important advantages:

The strategy is always market-neutral: the Bitcoin market’s moves (up or down) don’t impact the strategy returns. The strategy doesn’t need to transfer funds (USD or BTC) between Bitcoin exchanges. The buy/sell and sell/buy trading activities are done in parallel on two different exchanges, independently. There’s no need to deal with transfer latency issues.

Triangular Arbitrage

This is a Github project that detects triangular arbitrage opportunities within Binance. To use it, you need to clone the repo and follow the straight-forward installation steps.

Although it does not execute the trades automatically, it will show you the top potential arbitrage triplets.

Requires Coding: Very little

Price: Free

Features:

Identify top potential arbitrage triplets sorted by profitability

Show steps to get execute a successful arbitrage trade

2. Market Making Bots

Market making is a strategy where the trader simultaneously places both buy and sell orders in an attempt to profit from the bid-ask spread. Market makers stand ready to both buy and sell from other traders, thus providing liquidity to the market.

If let’s say, BTC is trading at $17,000 a pop, you create a buy order for $16,999 and a sell order for $17,001. When both orders get filled you earn $2, the spread, for providing liquidity to other traders.

Tribeca

Tribeca is a free Github project. It features a full-featured web client, backtesting, and integrations with multiple cryptocurrency exchanges. To use it, you’ll need to clone the repo and set up your environment.

Requires Coding: Yes, for set-up

Price: Free

Features:

Supports a large number of currency pairs across multiple exchanges

Customizable quotes through web UI

Automatically halts trading in directional markets to mitigate losses

Low latency on modern hardware

HaasBot

Haasbot is a cryptocurrency bot based on out Rotterdam, that has been around since 2015. It boasts a large variety of trading options with market making being one of them.

It’s built for non-technical traders and has a user-friendly UI. Haasbot runs on the cloud so there are no downloads necessary.

Requires Coding: No

Price: 0.32 BTC a year ($1,148)

Features:

Run 10 Concurrent HaasBots

Access to 20 Indicators

Multiple trading strategies

All major exchanges supported

3. Portfolio Automation Bots

Rather than active trading, portfolio automation bots help users create, obtain, and maintain their desired portfolio. This is my favourite category of trading bots because it’s something any investor can use. These bots are not necessarily trying to beat the market, but instead just helping users automate as much of the boring stuff as possible like portfolio rebalancing.

For example, one of the portfolios you can create with HodlBot is an index comprised of the top 20 coins by square root market cap. When the market fluctuates, portfolio allocations will drift away from targets. To maintain its course, HodlBot automatically rebalances your portfolio by selling out-performing assets in favour of purchasing under-performing ones.

HodlBot

HodlBot dashboard

Requires Coding: No

Price: Free for Accounts under $500. $10/month for accounts over $500.

Features:

Well-researched cryptocurrency market indices.

Backtesting tool with accurate and detailed historical data

Advanced portfolio customization options

Automated rebalancing with customizable time intervals

Supports dollar cost averaging

Portfolio tracker

4. Technical Trading Bots

Technical trading bots trade on indicators & signals. They try to predict future price movements and use these predictions to make profit. These are by far the most popular and most widely used bots on the market.

Profit Trailer

Profit trailer features a wide range of active strategies & technical indicators. The strategies are divided into three categories: bear markets, bull markets, and neutral markets. To run profit trailer you need to download it and run it on your machine.

Requires Coding: No

Price: Basic is $30/month. Pro is $45 a month.

Features:

Paper Trading

16 Strategies based on technical indicators

Multiple bots

Multiple exchange integrations

3commas

Similar to Profit Trailer. The biggest difference is that 3commas has a web-based interface so you don’t need to download anything to use it.

Requires Coding: No

Price: Basic is $25/month but has a very restricted feature set. Pro is $84/month.

Features:

Sets up intelligent profit taking & stop loss targets

Multiple strategies based on technical indicators

Supports most popular exchanges

Cryptohopper

Crypto hopper is also a web-based tool that uses technical indicators to automatically execute trades.

The biggest difference here is that you can use Cryptohopper to subscribe to external signals posted by technical analysts. Once you’re subscribed to external signals you can choose to be alerted, or automatically execute trades.

Requires Coding: No

Price: $19/month for basic (limited feature set). $49 and $99 per month for the higher tiers.

Features:

Multiple trading strategies based on technical indicators

Subscribe to external signals

Multiple exchange integrations

What most trading bots promise you:

What they actually deliver:

Most trading bots claim to make their users profits, but instead, they’re making money for themselves.

In any financial market, it is very difficult to come up with a strategy that out-performs the market over a long period of time. Any strategies that can probably do so, are scarce, desirable, and valuable.

That’s why it doesn’t make any economic sense for trading bots to sell legitimately performant strategies to their users.

Legitimate trading bots don’t claim to be the be-all and end-all. At best, bots are another tool to help you create, test, and automate your trading strategy. At the end of the day, the human element is still very important.

Don’t let these trading bots sell you on a pipe dream!

In order to use a trading bot, a user needs to provide access to their private API keys. This information is very sensitive. If it falls into the wrong hands, it could compromise the user’s account.

Careful risk mitigation is important. Here are things you can do to lower your risk.

Only use a trusted exchange with a solid track record of defending against attacks

You want to select an exchange that has a past record of defending against attacks and putting the user first.

Plug into sketchy, low-volume exchanges at your own risk.

Always disable withdrawal access

Usually, there are 3 distinct levels of API permissions:

Read — the ability to get data about holdings, trade history, and the market.

the ability to get data about holdings, trade history, and the market. Trade — the ability to execute trades

— the ability to execute trades Withdrawal — the ability to withdraw funds

Make sure to disable withdrawal access. In case your API keys are compromised, you want to limit the power a bad actor has over your funds.

Disable trade permissions after you’re done your trades

If you are very security conscious, it’s a good idea to manually disable and re-enable trade access when you want to execute your trades. Obviously, this is not going to work for bots that run 24/7. But let’s say you’re running a portfolio automation bot and it rebalances once every month. You can set yourself a reminder to toggle permissions on the rebalance date.

Why do I care about trading bots so much?

I quit my job recently to start HodlBot.

HodlBot is a tool that helps investors diversify their portfolios and automate their trading strategies.

I’m currently indexing the entire cryptocurrency market via the HODL30, a portfolio that is comprised of the top 30 coins by market cap.

If you don’t want to index, you can also create a custom portfolio and let HodlBot rebalance it for you.

To get started all you need is a

Binance Account $50 in any cryptocurrency

If you want to know how HodlBot indexes the market and completes rebalancing, check out the blog I wrote here.

Originally published at blog.hodlbot.io on February 10, 2019.

Tags