In a recent blog post at Trality, we have already seen how applying a trend-following signal on Bitcoin can provide protection during a market downturn. For the current series, we are now going to take a step back and have a closer look at the individual parts that must be considered to take a trading strategy from an idea to a deployable bot.
This introductory post briefly describes the main building blocks of strategy development, namely universe selection, time frame and trade frequency, signal selection, parametrisation, position sizing and finally backtesting. Each of these building blocks answers important questions about our final strategy.Try for yourself for free
The first building block for our bot is the universe it will trade. An investment universe constitutes a predefined set of tradable assets that satisfy some common selection criteria. In the above mentioned post, we have used BTC as the only coin that our bot trades. We now take it one step further and expand our universe for this strategy. The reason we do this is diversification. The old saying “Don’t put all your eggs in one basket” is also applicable to crypto trading. The intuition behind this statement is that the risk of a balanced portfolio is less than the sum of the risks for all its individual securities. For a given expected return the portfolio that exhibits the least amount of risk is deemed the most efficient. As Nobel laureate Harry Markowitz already pointed out, “Diversification is the only free lunch in investing”.
The choice of the universe is also influenced by the time frame and the trading frequency of our strategy. The higher the trade frequency, the more important considerations like liquidity, bid-ask spread and trading costs of individual coins become. (Market-) liquidity refers to the ease at which one can buy or sell an investment within a given time period, without affecting the market price. For example, if we were to deploy a strategy that only trades once a week, we would not care too much if we have to wait a bit for the desired volume to be available in the market without getting a bad price due to the size of the trade. If we were to trade every minute, however, low liquidity could immediately turn our strategy unprofitable. Especially in crypto trading, liquidity varies widely across assets.
Additionally, the more we trade, the higher the trading costs that accumulate. In general, we can observe an inverse relationship between liquidity and trading costs for any asset. For these reasons trading frequency plays a critical role in the success of a strategy.
The core of our strategy deals with the selection of trading signals. A trading signal creates the position entries and exits for our trading algorithm. There are various ways to come up with such trading signals. A very popular choice is to use technical trading indicators. Alternatively, machine-learning can be used to generate signals. For instance, in the recent blog post at Trality, two exponential moving average (indicators) are compared to generate entry and exit signals for a strategy. In order to avoid confusion, we will subsequently refer to signal generators as methods to produce entry and exit signals.
Whatever signal generation processes we use, we must decide on which data we want to base our strategy on. Do we use price data, order book data or a combination of both? Do we use additional, alternative data? Most commonly, price data is obtained per time-interval (e.g. hourly, daily, etc.) and contains an asset's open, high, low and close price (OHLC) as well as related volume traded within this interval. In finance lingo, these data points are also called candles. The order book comprises all open orders at a given point in time. Analysing order book data provides an even more in-depth view on the market. Due to instantaneous changes in order book data, it also becomes more complex to analyse. A detailed overview of alternative data in finance can be found in this JP Morgan report.
Moreover, we need to decide which class of trading strategies our bot belongs to. For example, is it employing a trend-following strategy or basing its positions on mean-reversion? Of course, these are not the only types of trading strategies, there are many more that can be considered, and we will cover some of them in future posts.
It is also possible (even recommended!) to use multiple signal generators in a trading strategy. This enables our bot to perform well in different market conditions and adds another layer of diversification. Using a multitude of signals reduces the overall volatility of our strategy and protects from overfitting in backtests.
Once we have decided upon which signal generator(s) we are going to use, we need to specify appropriate parameters for them. In the field of technical indicators we often need to specify look back periods, thereby weighting parameters. Within the domain of machine learning we specify the hyper-parameters of our models.
For example, in our previous post, we used two EMA indicators, based on 20hr and 40hr period windows. How to choose these parameters is an art in itself. A problem that often arises when choosing parameters based on historical simulation is overfitting. This issue arises most often when our signal generators employ a lot of parameters that can be tweaked. In such a situation the temptation to adjust parameters such that they perform extremely well on past data is very high. As a result it needs to be ensured that the set of parameters is not only optimal for historical data, but continues to deliver performance when actually trading the strategy live.
Last but not least we need to decide how much we trade (the position size) in order to finish our strategy. Position sizing deals with the question of how much capital is allocated to a trade, position or even a strategy itself. There are various techniques like, fixed dollar amount, equal percentage, risk based position sizing and many more.
In the case of our previously built BTC strategy, we employed 80% of capital per trade. How to choose this number? What about a strategy where multiple coins are traded? Do we split our capital equally between all coins or do we change the position size depending on factors such as signal strength, volatility of the underlying coin or general market environment? This decision can have a great impact on the overall profitability of a strategy.
A backtest is an ex-post simulation of a trading strategy. In its traditional sense a trading strategy is evaluated on historical market data. When running a backtest, it is particularly important to split the time period that is available for backtesting into in-sample and out-of-sample data. We use the in-sample data to optimise our strategy and, once we are satisfied, we use the out-of-sample data to validate our results and make sure that we do not just end up with an overfitted strategy that will likely perform poorly in actual live trading. Lucky for us, the Trality backtesting module makes this as easy as it gets!
This concludes the first part of our series on strategy development, as we have gained an overview of the individual building blocks of strategy development. Stay tuned for the next post where the first learnings will be applied to build the first iteration of our multi-coin trading bot!Try for yourself for free
Stefan is a quant with more than 6 years experience in the finance industry. He currently holds the role of Director Risk Management & Analytics at an independent investment manager specialising in insurance investments for institutional clients. In his free time he has been developing and implementing algorithmic trading strategies across multiple asset classes for 7 years.