Crypto Currencies
This is an analysis of 8 crypto currencies. We’ll look at some market efficiency test and then move into a potential trading strategy using different types of machine learning algorithms.
The data selected for this analysis were crypto currencies:
Symbol |
Name |
ADA-USD |
Cardano USD |
BNB-USD |
BinanceCoin USD |
BTC-USD |
Bitcoin USD |
ETC-USD |
EthereumClassic USD |
ETH-USD |
Ethereum USD |
LTC-USD |
Litecoin USD |
SOL1-USD |
Solana USD |
TRX-USD |
TRON USD |
These currencies were selected because they are in the top 25 cryptocurrencies by market capitalization. The data was taken hourly from January 3^{rd} 2021 to June 23^{rd} 2021. Looking at the correlations of each of the variables and plotting it onto a heatmap seen below. It can be seen looking at the graph that many of the variables are correlated with one another. This could be due to the fact that they are similar products as well as the fact that it is priced against the same currency. But it can be seen that if one some currencies are strongly correlated to each other while others are not for example Solana is not strongly correlated with Bitcoin.
Figure 1-Heatmap of Crypto Currencies
Below a box plot of the different currencies shows that their distributions are very close to 0 with some strong outliers. This is not abnormal for stock data; stock data is usually a Cauchy distribution. When the log-returns is taken, it is an attempt to try and normalize the data. It can be seen that most of the data does follow a normal distribution, but heavy tails still exist.
Figure 2- Box Plot of Log Returns of Crypto Currencies
The histogram below of BinanceCoin is a representative sample of the cryptocurrencies distribution. The Cauchy distribution can be seen more easily with most data clusters around 0 with some values further away from 0.
Figure 3-histogram of BNB Log Returns
Along with price data. I also used a python package known as TA, which allows users to input OHLC data as well as Adjusted Closes and volume data, was used to generate all the technical analysis data. The package takes this data and outputs 70 well known technical indicators. The technical indicators will be used by the algorithms to determine which way the market will move on the next tick.
The concept of market efficiency is a cornerstone of finance. The primary empirical investigation of market efficiency involves measuring the statistical dependence between price changes. If no statistical dependence is found in the prices, that means that the price changes are random. The lack of statistical dependence provides evidence favoring the weak-form of EMH, which implies that no profitable investment trading strategies can be derived based on past prices. If statistical dependence is uncovered, that means prices do not change randomly; a trading strategy can be created around that fact. If statistical dependence is discovered, this means that the weak form of the EMH does not exist.
The EMH asserts that market prices incorporate all publicly available information, and various researches that are familiar with behavioral economics and finance have challenged this hypothesis. They argue that markets are not rational but are driven by fear and greed instead. Andrew Lo, in 2004, proposed a new framework that reconciles market efficiency with behavioral alternatives by applying the principles of evolution to approach economic interactions. The proposed idea by Andrew Lo is called the "Adaptive Markets Hypothesis" (AMH). Lo, and other researchers have stated in their publications that the AMH implies complex market dynamics, such as cycles, herding, bubbles, crashes, trends, and other phenomena in the financial markets. In their papers, emphasized that market efficiency varies throughout time using first-order autocorrelations. They showed that the market was more efficient in 1950 than in the early 1990s. Andrew Lo used an example by computing the rolling first-order autocorrelation for monthly returns of the Standard & Poor's (S&P) Composite Index from January 1871 to April 2003.
First Order Autocorrelation is a common metric used to test for the AMH. When performing multiple linear regression using the data in a sample of size n, there are n error terms, called residuals, defined by e_{i} = y_{i} – ŷ_{i}. One of the linear regression assumptions is that there is no autocorrelation between the residuals, i.e. for all i ≠ j, cov(e_{i}, e_{j}) = 0. ("Sample autocorrelation - MATLAB autocorr", 2020)
The autocorrelation (aka serial correlation) between the data is cov(ei, ej) says the data is autocorrelated or there exists autocorrelation. If cov(ei, ej) ≠ 0 for some i ≠ j. ("Sample autocorrelation - MATLAB autocorr", 2020)
In this paper, correlations were checked between today’s price and yesterday’s price using a rolling window of 60 days. It can be seen that the correlations fluctuate between positive and negative correlations. If no correlation exists that means that the market is efficient.
Another common way to test market effiency is though the Vratio test. The Vratio test is available in MATLAB as a built-in function. It is based on a ratio of variance estimates of returns r(t) = y(t)–y(t–1) and period q return horizons r(t) + ... + r(t–q+1). The overlapping horizons increase the efficiency of the estimator and add credence to the test. Under either null, uncorrelated innovations e(t) imply that the period q variance is asymptotically equal to q times the period one variance. The variance of the ratio depends on the degree of heteroscedasticity; therefore, on the null. ("Variance ratio test for a random walk - MATLAB vratiotest", 2020)
Rejection of the null due to dependence of the innovations does not imply that the e(t) are correlated. Dependence allows that nonlinear functions of the e(t) are correlated, even when the e(t) are not. For example, it can hold that Cov[e(t),e(t–k)] = 0 for all k ≠ 0, while Cov[e(t)2,e(t–k)2] ≠ 0 for some k ≠ 0. ("Variance ratio test for random walk - MATLAB vratiotest", 2020)
Cecchetti and Lam show that sequential testing using multiple values of q results in small-sample size distortions beyond those that result from the asymptotic approximation of critical values. ("Variance ratio test for a random walk - MATLAB vratiotest", 2020)
The currency below is of BNB with a 60-day rolling window. When the pValue drops to the 0.05 and lower level. This means that the returns are not random, and they are predictable. However, it can be seen that the vast majority of the time that the currency prices move with a degree of predictability, hopefully making prediction of returns easier.
The currencies will have varying efficiencies over time, with when the p-value is 1 means that the market or stock is perfectly efficient at that time. From the figure above, it can be seen that the market is never perfectly efficient, which supports the Grossman-Stiglitz Paradox, which argues perfectly informationally efficient markets are an impossibility since if prices perfectly reflected available information, there is no profit to gathering information, in which case there would be little reason to trade. Markets would eventually collapse (Lo,2007).
Trading Strategy:
I decided to look at Classificaiton Machine learning algorithms to see if they could make a profitbale trading strategy. The algorithms used were:
Machine Learning Algorithms |
Abbreviation |
Logistical Regression |
LR |
Logistical Regression (Ridge Regression) |
LR-L2 |
Linear Discrimination Analysis |
LDA |
K Neighbors Classifier |
KNN |
Gradient Boosting Classifier |
GB |
Ada Boost Classifier |
ABC |
Random Forest Classifier |
RF |
Support Machine Vectors |
SVM |
Support Machine Vectors Perceptron |
SVMP |
Support Machine Vectors Hinge |
SVMH |
Multilayer Perceptron |
MLP |
The back test of these models starts from May 28^{th} to June 23^{rd}. Multiple machine learning algorithms used are a wide range of classification, regression, and clustering algorithms. The algorithms try to predict one period forward whether the stock will move up or down. If the algorithms guess correctly, it makes money; if it fails to determine the stock's movement, it loses money. The backtest assumes no transaction costs and no slippage. The metrics used are are: Cumulative Return, Sharpe Ratio, Max Drawdown. The machine learning algorithms will also be compared to a buy and hold (B&H) strategy.
The table below it can be seen that some currencies it was possible to make a significant amount of money using machine learning algorithms. The results appear to be mixed though with machine in regards to the Sharpe Ratios however the machine learning algorithms had lower drawdowns over a buy and hold strategy.
Table 1-Currency Backtest Results
Currency |
Average of Total Returns |
Average of Sharpe Ratio Algorithm |
Average of Sharpe Ratio B&H |
Average of Drawdown Algorithm |
Average of Drawdown B&H |
ADA-USD |
$ 32,153.11 |
3.51 |
0.62 |
$ 2953.29 |
$ 7,631.48 |
BNB-USD |
$ 10,261.69 |
0.52 |
-0.25 |
$ 1,256.10 |
$ 4,586.41 |
BTC-USD |
$ 7,601.83 |
-1.10 |
-0.19 |
$ 849.05 |
$ 2,792.57 |
ETC-USD |
$ 10,365.36 |
0.47 |
-1.32 |
$ 1,750.33 |
$ 5,321.56 |
ETH-USD |
$ 8,617.95 |
-0.32 |
-0.62 |
$ 956.80 |
$ 3,978.54 |
LTC-USD |
$ 9,361.42 |
-1.20 |
-0.86 |
$ 1,201.12 |
$ 4,515.01 |
SOL1-USD |
$ (1,822.49) |
-9.33 |
0.55 |
$ 1754.66 |
$ 6,207.41 |
VET-USD |
$ 8,411.68 |
-0.30 |
-0.42 |
$ 1,896.19 |
$ 5,947.78 |
XRP-USD |
$ 10,737.11 |
0.47 |
-0.81 |
$ 1,256.20 |
$ 5,203.63 |
The figure below shows BNB with different machine learning algorithms applied to the stock trying to make money. It can be seen that the cumulative value is very volatile over time within this instance, LDA being the most profitable.
It can be seen in the table below. that the max drawdown of the algorithm has the potential to be lower than that of a B&H strategy, however many of the Sharpe Ratios are less than 1.This observation has been seen in the literature where the max drawdown is lower than a B&H strategy. However, because the backtest does not include transaction costs and the algorithms closing their positions at the end of each day. The transaction costs in a real-world situation would destroy most, if not all, the algorithms' profits.
Table 2-Machine Learning Algorithm Backtest Results
Machine Learning Algorithms |
Average of Total Returns |
Average of Sharpe Ratio Algorithm |
Average of Sharpe Ratio B&H |
Average of Drawdown Algorithm |
Average of Drawdown B&H |
Ada Boost Classifier |
$ 7,854.61 |
-1.76 |
-0.37 |
$ 6,655.67 |
$ 5,131.60 |
K Neighbors Classifier |
$ 14,541.90 |
-1.34 |
-0.37 |
$ 6,164.24 |
$ 5,131.60 |
Linear Discriminant Analysis |
$ 11,168.82 |
-0.77 |
-0.37 |
$ 5,246.38 |
$ 5,131.60 |
Linear Regression |
$ 9,451.41 |
0.62 |
-0.37 |
$ 5,850.21 |
$ 5,131.60 |
Linear Regression with Regularization |
$ 8,268.68 |
0.00 |
-0.37 |
$ 5,981.44 |
$ 5,131.60 |
Multi-layer Perceptron classifier |
$ 9,723.88 |
-1.83 |
-0.37 |
$ 4,227.83 |
$ 5,131.60 |
Random Forest |
$ 12,534.41 |
-1.25 |
-0.37 |
$ 6,012.22 |
$ 5,131.60 |
Support Vector Machine |
$ 13,305.92 |
0.05 |
-0.37 |
$ 5,491.40 |
$ 5,131.60 |
Support Vector Machine Hinge |
$ 7,942.61 |
-1.55 |
-0.37 |
$ 7,554.80 |
$ 5,131.60 |
Support Vector Machine Perceptron |
$ 7,075.99 |
-0.45 |
-0.37 |
$ 6,800.66 |
$ 5,131.60 |
Gradient Boost |
$ 15,083.35 |
-0.62 |
-0.37 |
$ 5,353.61 |
$ 5,131.60 |
The figure below results from conducting a two-sided T-test on the accuracy of the machine learning algorithms to a random walk. If the values below are greater than 1.96, then the accuracies would be statistically significant over a random walk. Looking below, it can be seen that none of the machine learning algorithms are able to predict the movements of the market better than a random walk.
Table 3-T-Test of Machine Learning Algorithms to Random Walk
This shows that the price data used does not help to predict cryptocurrencies selected. This may be due to the algorithms only trying to predict one time period ahead vs multiple hours ahead caused the accuracy to be low. It is also possible that alternative data would help increase the accuracies of machine learning algorithms. In the literature, there are machine learning algorithms that have higher accuracy. This is often due to the lagging of specific indicators that researchers may think are leading indicators. This increases the accuracy to a point where it would be statistically significant and would make an academic or trader go to the next step of backtesting.
It can be seen that the EMH does not hold over long periods. If the time period selected has an extended period of time, the market saw behavioral bias such as herding, confirmation, and confidence that the EHM hypothesis testing will claim that the market is inefficient. Using the AMH, it was seen that the currencies have periods where the market is efficient and inefficient and is seen cyclically. The machine learning algorithms predicting the movement of the stock market did not have statistically significant results. Results may improve by having more economical data as well and having the machine algorithms predict more than 1 period into the future.
Write your comment....
Sign in to comment