A Beginner’s Guide to Crypto Trading Bots

The Ocean
The Ocean
9 min readSep 20, 2018

--

The digitization of Wall Street in the 70s created an electronic economy of millisecond-measured speed, best execution, and powerful computers. Today, the best traders in the world work in financial services with access to exclusive, multi-million dollar tools. However, the paradigm is shifting. We’re reaching new heights in algorithmic trading thanks to cryptocurrency. The accessibility of digital markets and cheaper hardware means that more individuals can execute trades programmatically than ever before.

And while it’s not for easy-going trader (some programming experience, knowledge of statistics, and mathematical models is required for best results), educational materials are widely available online and the current ecosystem of cryptocurrency exchanges provides excellent testing grounds for all types of strategies.

What is algorithmic trading?

Algorithmic trading is a type of trading that involves programmatically executing trading strategies as opposed to manual orders. In other words, traders run algorithms (a set of instructions to solve a problem) on computers to automatically buy, sell, and hold assets.

There are several benefits to algorithmic trading which primarily includes cutting costs and saving time. Several lines of code can execute trades while making simultaneous market condition checks across multiple exchanges, all while operating 24/7 around the clock.

Beginner’s Glossary

Before exploring the library of trading strategies that quants employ today, here are some terms that might be helpful to understand:

Alpha: A measure of performance, otherwise known as profit or return.

Volatility: A measure of changes in price for a given asset. Higher volatility indicates that an asset’s price can change dramatically over time; lower volatility indicates a more stable price.

Fundamental analysis: A method of calculating an asset’s value by measuring its intrinsic value, examining economic, financial, and other qualitative and quantitative factors. A fundamental analysis of ZRX might examine the token’s utility in conjunction with 0x Project’s leadership and fundraising activity.

Technical analysis: A method of calculating an asset’s price movements by examining statistics generated by market activity, i.e. past prices and volume. A technical analysis of ZRX might compare 7 day prices on graphs to predict trends in movement.

Quantitative analysis: A method that treats asset prices as random and uses mathematical and statistical analysis to find suitable models to describe this randomness. A quantitative analysis of two competing wallet tokens, SNT and ETHOS, might find that when one token goes up in price, the other goes down and vice-versa. *Most algorithmic trading strategies employ this type of analysis.

Limit order: A type of order used to buy an asset on an exchange at a set price or better. E.g. A limit order at $1.00 for 1000 ZRX can be filled by 1000 units priced at or less than $1.00.

Market order: A type of order used to buy an exchange at the prevailing market price up to a specified volume. E.g. A market order for 1000 ZRX will be immediately filled by 1000 units at the exchange’s market price. This usually means sacrificing price for guaranteed execution.

Trade signal: A trade signal, in general, is a trigger for action, either to buy or sell an asset, generated by one’s analysis.

Size: The number of units of an asset to buy or sell.

Backtesting: Testing your algorithmic strategy on old data to determine its profitability.

Overfitting: Testing and adjusting your algorithmic strategies too much on old sets of data so that it cannot fit current data.

What are the technical requirements?

Implementing a profitable algorithmic trading strategy usually follows three steps: 1) data collection, 2) selecting and creating a strategy, and 3) backtesting. This generally requires:

  • Unless you’re using pre-made trading software, some computer-programming knowledge to process data and create your strategy.
  • Access to trading platforms to place orders.
  • Access to live market data feeds for your algorithms to monitor.

It’s important to note that even though you might be lacking in coding experience, understanding the fundamentals behind automated trading is extremely valuable in itself. The reasoning and math behind prolific strategies can better inform your own trading and diversify the arsenal of trading tools at your disposal.

It all begins with data

Market data is the lifeblood of algorithmic trading. By aggregating cryptocurrency prices over time, you can identify initial patterns, backtest your strategies, and ensure that your models respond in real time. Here are a few considerations:

  • Cleaning Data: You’ll need to organize and clean data in a format that’s easy to use. Changing values from integers to floating decimals or converting data that’s in minutes or seconds to milliseconds is deceptively time-consuming.
  • Processing Data: When testing large amounts of data, your processing speed is limited to the performance of your machine. This can create unforeseen bottlenecks when it comes to testing your algorithms.
  • Too Much Data: Too many variables in your models can lead to multicollinearity, or a situation in which it becomes difficult to connect parts of your data to specific conclusions. For example, if the price of ZRX increased, I can arguably input data (from that day) related to the weather, the price of Apple stock, and the cost of gas. However, this makes assigning explanatory power to specific variables extremely difficult. Ideally, I might just want to examine the price of other tokens in relation to ZRX.

Sources & Tools: CoinMetrics Data, CoinMarketCap API, Using SQL to Analyze Crypto Performance

Selecting a strategy

There are endless opportunities for experimentation depending on your objective and risk tolerance. Here are just a few strategies from a top-down perspective:

Mean Reversion

This strategy is built on the assumption that if a price on a coin deviates from its average, it is destined to revert back to its average. This is a fair assumption to make in many markets. E.g. if the price of ZRX falls to 50 cents from its lifetime average of $1, many traders might perceive its new price as low and buy in at a large size. This brings the demand and price back up to its median level. Conversely, if the price spikes to a new high at $1.50, traders may sell in bulk and lower the market price. While this strategy may be built on the simple principle of “buy low, sell high”, having an algorithm to calculate mediums and execute trades automatically can save time, cost, and lower risk.

Mean Reversion Strategy by The Ocean

Momentum Trading

If market volatility is like a series of waves in the ocean, the momentum investor holds short-term positions and sells at the peak of the wave before it crashes. This strategy is based on the belief that prices will continue to rise above expected averages and inevitably fall. This means that entry timing (when a trader buys into a market) and exit timing (when a trader sells out of a market) is vital. Let’s say the price of ZRX is rising rapidly. A momentum strategy leads the herd of investors who are buying in, yet also sells its position before anyone else at the price peak.

Arbitrage

In a fragmented, inefficient market like cryptocurrency, prices across marketplaces can vary wildly due to geography, time, and regulations. E.g. the price of ZRX can be $1.00 on Radar Relay and $1.03 on The Ocean. Arbitrage makes a profit by buying and selling on exchanges simultaneously to make a profit on the spread. Unlike the momentum trading, this strategy is independent of market performance and is fairly low-risk. It just requires speedy buys and sells (simultaneously is ideal!) to exploit price differences before they close up. This makes arbitrage one of the simplest and most effective strategies for programmatic execution.

Arbitrage Keeper by MakerDAO

Naïve Bayes

Machine learning (ML) and artificial intelligence (AI) hold immense potential when paired with algorithmic trading. Picking the enter and exit times for a momentum strategy is extremely high-risk and prone to human error. However, by feeding information into an ML strategy, your computer can automatically pick the most optimal times for you.

A Naïve Bayes trading algorithm is a type of ML strategy that, at its core, determines the probability of an event occurring according to classification variables. E.g. if the price of Ethereum declined (the classification) for the past two days (prior probability), what is the likelihood that the price will decrease today (posterior probability)? And while quantifying likelihood is a very powerful thing, it still requires the decisive element of choosing when to execute trades. If the probability of ZRX decreasing is 60%, is that enough likelihood for you to sell your positions? In the end, you’ll have to defer to your own risk tolerance.

Naïve Bayes Classifier by muatik

Natural Language Processing (NLP)

In today’s cryptocurrency market, speculative information is key. Articles, tweets, and other content can travel around the world in seconds and affect how traders view certain projects. NLP programmatically interprets words and phrases to disseminate sentiment. E.g. An article that says “ZRX is booming after fund manager buys stake” might drive a trader to buy into the market. An NLP algorithm will process the sentence (ZRX, booming, and buy are keywords!) according to its parameters to determine a positive or negative relation and act accordingly, i.e. buy.

Twitter Cryptocurrency Sentiment Analysis by hazelcast

Recommended Read: Natural Language Processing by Adam Geitgey

How do I get started?

If you’re still interested in delving further into algorithmic trading, you’re in luck! As mentioned before, there’s a wide array of primers, tutorials, and sample code to get you started. Here’s a small collection to get you going:

Preliminary Reading

Languages & Tools

Coding Walkthroughs

Code Samples

We don’t claim to be the definitive guide to algorithmic trading, so we encourage you to do your own research! We especially recommend deepening your knowledge on the theory and math behind strategies to strengthen your analysis skills. Algorithmic trading is an interdisciplinary field that combines finance, mathematics, engineering, and economics–and it’s certainly not easy.

__________________________

If you have any questions or comments, join our community of traders on Discord. We’d be more than happy to help.

Follow us on Twitter at @TheOceanTrade or subscribe to our newsletter to stay in the loop.

The information contained in this document is not (and should not be construed as) investment advice or a solicitation. The information is not necessarily verified nor is it provided under any sort of warranty, including as to completeness or accuracy. The information is subject to change without notice. The Ocean is not a licensed financial advisor. Trading virtual currencies or digital assets is volatile and risky: recipients of this information should do their own due diligence, considering their specific financial circumstances, investment objectives, capabilities, and risk tolerance, before taking any action. Pursuant to The Ocean’s internal policies, individuals who contribute to this information may have positions in digital assets, including those discussed herein. Any comments or statements made in this communication do not necessarily reflect the views of The Ocean or its affiliates. This information does not constitute an offer to buy or sell any of the assets referenced herein.

--

--

The Ocean
The Ocean

The Ocean is a high performance 0x-based Ethereum ERC20 token trading platform. Sign up for launch news: www.theocean.trade