This short paper discusses setup of automated trading model for selected cryptocurrencies, with the goal of creating trading strategy that produces positive returns. Fundamentally, the model is based on mean reversion concept borrowed from finance, which essentially states that an asset price should revert to its long term average. One can expect that, absent shocks or trends, an average long term price should be more or less constant. And therefore occasional movements in price will have to be offset to some degree by opposite price movements in order to maintain the price average.
Even though the change in price level can be expected often in the cryptocurrency market due to various shocks and trends being abundant, it appears that the price movement often follows a pattern of moving too much in the direction of the change and then reversing some of the movement. Which essentially the same mean reversion principle, but taking into account shifts in the market. To capitalize on such pattern, the approach is essentially a classification predictive model that attempts to predict a reversal in a coin price that deviated too much from longer-term moving average price. The results of this predictive model are then supplied into a rule-based trading logic that executes actual trades. In simulation, most of cryptocurrencies trading produces positive returns.
Bitcoin prices will be used for the purposes of describing the model, however the same logic is applicable to other coins.
In its essence, any successful trading strategy is a prediction exercise. Since this is an attempt to approach trading in quantitative way, the foundation of the whole process is a predictive model based on statistical techniques.
Predicting future prices would be the most appealing, however it is rather unlikely that such model can be built directly for the price. Looking at bitcoin daily price graph, it is quite impossible to see any meaningful repetitive patterns.
Figure 1 — Bitcoin price
However, a ratio between a price and its moving average behaves much better. There are clear visible cycles. And while there is clearly a lot of noise here, some statistical modeling is possible.
Figure 2 — Price to moving average ratio
A first approach is to predict this series directly. If possible, simple algebra shows that this would translate into predicting actual price, which is highly desirable. Indeed a statistical autoregressive model with excellent fit is possible, however simulations proved it to be useless. The reason is that the model fails to predict price reversions, which is pivotal to the trading.
In order to avoid this problem, another autoregression model was developed, which only predicts the direction of this series. Essentially, it exploits the trade-off that by avoiding predicting the actual price, we can gain in the quality of predictions in predicting only the direction. Since the goal is now much simpler, the model avoids dealing with portion of the noise in the data.
Since the model predicts the direction of the series, there is a trading opportunity once there is a change in direction. Simulations, however, showed that simple rules fail in the long run. Note that in figure 2 above, value above 1 implies a growing price, and a value below 1 implies a decline. Even though the series shows repetitive cycles, the implication for trading is different from cycle to cycle because some of them happen while market is in overall decline, while others happen while market is growing. So a second model was developed, which predicts overall market growth vs decline.
The set of rules for the first direction model is now split in two depending on prediction of the second growth-or-decline model.
The fit for these models is acceptable to good and indicates that both models pick up signal in the data.
The directional predictive models produces a number between 0 and 1 as output. A number close to either of this extreme indicates strong signal towards one of the direction. Similarly, the market growth-or-decline model produces a number between 0 and 1 that indicates a signal towards market growth or contraction. Both of the make mistakes sometimes, and a number in the middle of the 0 to 1 range represents a weak signal. Therefore, the trading strategy should be different depending on a particular combination of these outputs.
Based on various simulations, it appears that there is a combination of rules that produces positive returns for most coins in the long run. Translated into plain language, the rules imply that if there is a good chance of overall growth predicted by the growth-or-decline model, than we should short the coin only if the direction model produces strong signal for a decline. Similarly, if there is strong signal for decline, we should long the coin only if there is a strong directional signal for growth. Note that this rule is not symmetrical despite how it sounds — the required confidence to sell during growth is higher than the required confidence to buy during decline. There are also indecisive regions of the outputs, when the signal is too weak either way. In such cases, the rule is to continue to hold existing position.
Trading rules also depend on price levels and sometimes a trade recommended by signal is not executed if price levels appear to be unfavorable.
Since both predictive models are probabilistic in nature, they should be expected to occasionally produce wrong signals. To guard against these, an extra rule was put in place that requires an accumulation of a particular signal over fixed number of time periods before a trade is made. Here time period is a the step of the time series data upon which the model is build — i.e. daily, hourly etc.. In simulation, a rather long waiting time between 12 and 18 time periods produced the best result. Also, an alternative approach was developed, when the waiting period is much shorter, but depends on the strength of the signal in the model. There are two variants of this approach different in how favorable/unfavorable price levels are tracked. For some cases, the second approach produced better results.
For the purposes of developing the trading logic, two predictive models described above were fit into the daily bitcoin data. Then trading logic was then developed and tested on the piece of withheld daily data. Then the same models were fit into hourly data for various coins — these produced different model parameters for each model, but the model structure is the same across all coins and the same as in the daily data models. The trading logic that was developed on daily data was then applied on withheld portion of hourly data. The results are summarized in the table below.
Summary table 1
Each simulation starts with long of 1 coin, and the ‘end balance’ field in the table indicates how many coins are there in the end of the simulation. Most of cases are profitable, but it should be noted that even the most profitable models occasionally make mistakes and lose money — but they are able to recover in the subsequent trades.