Log in

An introduction to automated trading

Automated trading (or algorithmic trading) is a large field. Many people assume that automated trading means high-frequency trading (HFT), but that's only one approach.

Practitioners of HFT are typically concerned with shaving microseconds off their trades. But the major cryptocurrency exchanges don't have the required infrastructure to support anything close to those speeds (yet).

Tradewave supports a minimum trading interval of 1-minute, meaning that a trading strategy is woken up once a minute to take action (if it needs to). Many profitable trading strategies operate in the 1-2 hour range or more.

Most of the trading strategies that we support rely on some form of technical analysis in order to make their decisions. This means using current and past market data (mainly prices) to identify patterns and trends.

For example, when a strategy's analysis determines that the price is likely to rise soon (a buy signal) it may choose to enter a position in Bitcoin. It will then hold it for a while until it decides that the price is likely to fall, then close the position by selling.

First, we're going to describe a few concepts that you'll need to familiarise yourself with. Most of these apply to trading in general, not just automated trading.

Concepts

Candles

A market is a complex and fast moving collection of unresolved orders and executed trades. In order to make sense of it, most traders use candlesticks. A candle is an aggregation of the set of trades that occurred over a given time period, e.g. 5 minutes.

A trade is a transaction between two parties. A simplified example: Alice places a buy order for 5 BTC at $1000 each and a few seconds later Bob places a sell order for 5 BTC, also at $1000 each. The exchange matches their orders together and both orders are executed. The price of our imaginary trade was $1000.

Tradewave uses standard OHLC candles, which stands for Open, High, Low and Close. The usual convention is to treat the close price as the estimated market price of our instrument for the time period that we're aggregating.

To calculate the Close price for a candle spanning 5 minutes, we simply take the price of last trade that occurred in our time window. The other metrics are calculated in a similar way:

  • Open: price of the first trade that occurred in our time window
  • High: the highest price trade in our time window
  • Low: lowest price trade
  • Close: price of the last trade

We're also interested in volume, which is the summed amount of every executed trade in our time window.

Read more about candles and how they are used in charting.

Ticks

We use the word tick to describe a moment in time when your bot 'wakes up' to make a trading decision. A Tradewave strategy always defines a tick() function which is called repeatedly according to a tick interval that you choose. Between each tick, a bot is typically sitting idle.

Note: The word tick is used often in trading to mean different things. In our case, we're not referring to a change in the bid/ask spread. Each tick event is separated by a set amount of time.

If you choose a 5 minute tick interval, the tick() function is called every 5 minutes. When it is called, your bot gets an opportunity to look at the latest data and decide whether to buy, sell or do nothing.

The tick interval that you choose also determines the candle data that your bot receives. If you choose 1 hour then each candle will be an aggregation of trades across the hour that ended at the moment of the current tick.

Indicators

An indicator is a mathematical operation applied across market data (usually prices). The result is typically used to make some kind of trading decision.

One basic example is called the Simple Moving Average. It's just the average of the last N prices, where N is usually called the period. Here's what it looks like:

As you can see, untreated price data is erratic and noisy; this indicator smooths it out. So how does this help you to build a trading strategy? One classic example is called the moving average crossover. The idea is to plot two separate moving average indicators, where each line has a different period. A longer period means a smoother line, which means that it takes longer to show upward and downward trends. Here's what it looks like:

The moment at which the two lines cross can be interpreted as a trading signal. If the short-term line (shorter period) crosses above the long-term line (longer period) then you might think that this is indicative of an upwards trend, and therefore a buy signal. When the opposite happens you can interpret it as a sell signal.

To see how this looks as a Tradewave strategy, scripted in Python, take a look at the example strategy in our Strategy API guide.

There are hundreds of indicators to choose from and many different strategies. You can read more about them in the resources we refer to at end of this guide.

Pairs

We use the term pair to refer to the market between two currencies, e.g. BTC/USD. You may also see these referred to as instruments.

In our example, if you hold USD and you want to exchange it for BTC, you need to place a buy order for the BTC/USD pair. Going in the other direction, if you hold BTC and want to clear your position back to USD, you place an order to sell your BTC and in return you get USD.

You can interpret the BTC/USD pair as the market for BTC, expressed in terms of USD. Ticker prices are always expressed in terms of the second currency in that pair, so USD in this case.

Orders

For every pair that it supports, an exchange maintains an order book of unresolved buy and sell orders. When you place a buy order, it enters the order book on the buy side and vice versa for sell orders.

In simplified terms, the exchange is constantly trying to match both sides together to execute a trade. This can only happen when the price of both orders is the same.

When you place a market order with Tradewave, you're actually telling us to find the most favourable price on the other side of the order book and to post your order at that price. That way, unless someone else gets there first, the exchange can match your orders together immediately.

A limit order might be posted at a price with no corresponding matches at the other side of the order book, and thus will stay there unresolved until someone else places a matching order on the other side.

Read more about order books

Building a strategy

The basic idea is to use each tick to look for signals, using some combination of one or more indicators. If, according to your calculations, the price looks like it is going to increase, then you place a buy order. A few ticks later you might clear your position by selling because the market now looks unfavourable.

A strategy can be far more complicated than this, but these are the basic fundamentals. Buy low, sell high.

For a more concrete example, take a look at some of our featured strategies:

Learn more

This guide has only skimmed the surface of automated trading. If you would like to learn more, we recommend studying some resources on technical analysis. This list should get you started:

Books

Videos

If you think you're ready to start building strategies with Tradewave, take a look at our Strategy API guide.

Log in