Building a successful trading algorithm that ignores price
We’ve seen the rise and fall of many coins over the last few years. Sometimes new projects seem to come out of nowhere, while other times a given coin rises steadily through the ranks until it gets noticed by the main stream. With more than 1600 coins and tokens on the market today, things are getting awfully crowded, and it is difficult to learn enough to know whether any given coin is worthy of inclusion in our portfolios.
In contrast to the stock and bond markets, there is very little financial information to consider when picking coins, and often it feels like grasping at straws. The best method is probably to learn about each project, its team, and its ambitions to make a determination about its future viability. In this approach, diversification is less important than proper due diligence. But even a good understanding of a project does not necessarily indicate whether it is meant for greatness or doomed to failure.
Is there another way? As most of my efforts were focused on complex analyses of price only to end in mediocre results, I decided to look at the problem another way. What if we can pick a winning crypto portfolio, without ever looking at price? What follows is my preliminary research into this question, and the simple implementation of an algorithm that makes use of an entirely different piece of data: relative rank. To my surprise, this actually works pretty well.
Relative Rank as Indicator for Future Performance
When we think of rank, it is usually used as an argument for one coin or another, but I have not seen any serious attempt at quantifying and understanding how well of a predictor relative rank is. In fact, there are very little good data driven analyses of investment strategies out there, with ShrimpyApp and a few others being among the few good sources of properly crunched statistics.
The idea of relative rank is simple: each coin and token can be ranked based on market capitalization. This in itself is uninteresting. However, when we rank all coins against each other over time, we can try to find those coins that rise in rank relative to their peers, and detect patterns that may indicate some underlying driver of market confidence (or perhaps more mundane events, like the developers deciding to increase the circulating supply).
After painstakingly wrestling with the historical data set of over 1600 coins, we finally get a look at the development of relative rank over time. Already there are some interesting observations:
1) Most coins seem to lose rank over time
2) The top 10 coins are relatively stable in their position
3) There is an exponential increase in the number of coins
To illustrate the first point more clearly, we can randomly select a couple of tokens and see that, in general, they are all falling in the rankings over time.
I found approximately 40 coins that defy this trend, and show a clear, and often massive gain in rank:
The vast majority of these “winning” tokens are very young, hitting the markets in 2018, or late 2017, but constructing a portfolio of these cryptos does turn out to be a profitable move. Testing our hypothesis that relative rank increases correspond to above average ROI, I created a backtesting portfolio of these over-achievers, and found that we would have made an approximate 4% gain between January and July 2018, a time in which the overall markets are significantly in the red, and Bitcoin is down about 60%. A further consideration is that our investment strategy in this case is a simple buy and hold, and does not feature rebalancing, or any trading related activities.
An interesting trend is that the exchange tokens are doing rather well. Binance Coin, Huobi Token and Bibox Token are all up significantly, likely due to the bond-like nature of these coins, and the fact that exchanges will regularly buy them back to stabilize the price. Stay tuned for an upcoming, in-depth analysis of these special coins.
Post Hoc Problems
The above portfolio relies heavily on hindsight. In truth, the argument it makes is rather tautological, namely that coins whose rank increases, do better than other coins whose rank is decreasing. This in itself is not very useful information. Rather, we need a mechanism by which we can recognize these trends early on, assuming that upward rank trends are indicative of good projects. This in itself is controversial.
Most of the up-trending coins in our above portfolio are relatively new, which raises the suspicion that they are not in fact rising up the ranks due to their merit, but on account of some other factor. In the case of EOS, for instance, the ICO was spread out over an entire year, gradually increasing the number of ERC-20 tokens in circulation, and thus leading to a rapid rise through the rankings because of increasing market cap. The corresponding increase in rank is therefore not solely an indicator of merit.
Can Rank Trends be Used to Make Profits?
Let us consider only the year 2017 to manually establish trends, and use 2018 as a test case. Looking at coin projects that rise through the ranks in 2017, we make note, and then buy all relevant coins in January of the following year.
Using these and other upward trending coins, we select a portfolio and buy in on January 1st, 2018. Sadly, the result is a 75% loss, compared to an approximate 55% loss in Bitcoin, and 40% loss in Ethereum during that same time. Granted, a bubble collapse may not be the best test dataset, but the selected portfolio, for the most part, did not continue to gain rank. Instead, most of its coins fell significantly and were replaced by other, newer tokens, in the next wave of ICOs.
As far as I can tell, there are roughly four patterns that emerge from the ranking data:
1) Coins that remain approximately at the same rank
2) Coins that rise continually through the ranks
3) Coins that fall continually through the ranks
4) Coins that initially rise, and then fall in a wave-like pattern
Bitcoin is pretty much the only token that has remained steady at its number one spot, while Ripple, Ethereum, and Bitcoin Cash and Litecoin have all roughly stayed in the same vicinity at the very top of the rankings for a long time. Other coins are not so lucky.
If we select only those tokens that started off anywhere below the top 5, have risen to a height within the top 50, and have since then dipped below the 50th rank again, we are presented with a list of 270 coins. That is, one out of every six cryptocurrencies ever, exhibits the characteristic wave pattern of initially rising in rank, and then falling into oblivion.
Little Mobility For Top Coins
Of all coins within the current top 50, only 35 have started out below the top 50, and only four of these 35 (Verge, Bytom, IOST and Nano) have a median rank of greater than 50, which means that 92% of these currencies have spent the majority of their life above that threshold rank. Essentially, there is a ridged rank structure in place, and new top 50 coins do not generally rise through the ranks from below, but are born into, or born close to, the tip of the iceberg.
(‘Novacoin’, ‘ Start Rank: ‘, 6, ‘ End Rank: ‘, 567, ‘ Average Rank: ‘, 98.13365539452496, ‘ Median Rank: ‘, 36, ‘ Min Rank: ‘, 4)
(‘Freicoin’, ‘ Start Rank: ‘, 8, ‘ End Rank: ‘, 1071, ‘ Average Rank: ‘, 243.55662514156285, ‘ Median Rank: ‘, 117.0, ‘ Min Rank: ‘, 5)
(‘Mincoin’, ‘ Start Rank: ‘, 9, ‘ End Rank: ‘, 1211, ‘ Average Rank: ‘, 265.08640939597313, ‘ Median Rank: ‘, 165.0, ‘ Min Rank: ‘, 9)
(‘Ixcoin’, ‘ Start Rank: ‘, 10, ‘ End Rank: ‘, 782, ‘ Average Rank: ‘, 150.83040272263187, ‘ Median Rank: ‘, 52, ‘ Min Rank: ‘, 9)
This lack of mobility is just as present amongst the highest echelons. Only Tether, Binance Coin and VeChain have spent the majority of their lifetime outside the high 20 club, and only Stellar and EOS, both with a median rank of 12, are from outside the semi-permanent top 10.
Putting it all Together
Handpicking tokens has turned out to be less than optimal, but given these observations and patterns, we can try to construct a simple, rule-based algorithm that buys a token if it sufficiently rises in rank, and sell it if it falls. For the purposes of this test, the algorithm shall not look at price as a determining factor, such that only rank is considered.
Aside from start and end date of the backtest as well as the amount of money we start out with, there are essentially three variables of concern to us, namely those that determined when rank has sufficiently increased or decreased given a certain time period. Let’s call these three variables UP_MOVE, DOWN_MOVE and DAYS.
If we set UP_MOVE to 100, and DAYS to 20, then the algorithm will search for all coins that show an upward move of 100 ranks within 20 days. The same goes for downward movement. Then, the algorithm will buy that token on the 21st day, meaning that it is not relying on hindsight. Even though this is a backtest, the algorithm does not know which coins will ultimately win, meaning that this code should be able to function just as well going forward, and if fed live market data.
The UP_MOVE, DOWN_MOVE and DAYS variables themselves create a huge search space, in which the optimal configuration is yet to be found. I have simply tried several combinations and determined that 100, 100 and 15 seem to return pretty good results. This means, however, that the algorithm is more long term, and cannot be used in short time period.
Testing commences initially with a portfolio constructed from the 1st of January 2017, to the first of January 2018, beginning with $10 thousand:
TEST PORTFOLIO: 2017-01-01 To 2018-01-01:
Start Amount: 10000
Total Profits: 434839.2122343267
Percentage Gain: 42.48392122343267
Investments Made: 95
Winner percentage: 0.5894736842105263
Average Loss amongst losers: -8.707790663503474
Average Gain amongst winners: 7770.894790706064
Average Buy Ranking: 375.81052631578945
Average sell rank: 480.7684210526316
('Eternity', '2017-01-27', 16771.8215025232, 'Buy Price: ', 0.001898, 'Sale Price:', 0.07810800000000001, 'Buy Rank:', 391, 'Sell Rank: ', 501, 'DIFF:', 1278.1805167072932)
('Advanced Technology Coin', '2017-01-27', 18401.062837071957, 'Buy Price: ', 0.0024980000000000002, 'Sale Price:', 0.12250499999999999, 'Buy Rank:', 242, 'Sell Rank: ', 647, 'DIFF:', 2208.256347888494)
('BitTokens', '2017-01-27', 9564.468688885734, 'Buy Price: ', 0.006662, 'Sale Price:', 0.27108699999999997, 'Buy Rank:', 390, 'Sell Rank: ', 426, 'DIFF:', 2529.08463305861)
As we can see, of the 95 positions chosen, 58% were winners. This in itself is not that impressive, but considering that the losers typically lost only $8 each, while the winners averaged $7700, I am quite happy with that ratio. Overall, we achieved a 4248% gain.
In 2017, the crypto markets exploded, and during that same time period the overall market cap of cryptocurrency increased from $17 billion, to $565 billion; an increase of 3223%. Bitcoin increased by a measly 1243%. Depending on how we measure it, our algorithm performed quite well. If we test several other time periods with the same variable settings, we also achieve good results:
TEST PORTFOLIO: 2016-01-01 To 2017-01-01 :
Start Amount: 10000
Total Profits: 248321.28874742566
Percentage Gain: 23.832128874742565
Investments Made: 25
Winner percentage: 0.72
Average Loss amongst losers: -118.37396571274549
Average Gain amongst winners: 13841.661472634161
TEST PORTFOLIO: 2015-01-01 To 2016-01-01 :
Start Amount: 10000
Total Profits: 2396744.694364711
Percentage Gain: 238.67446943647113
Investments Made: 105
Winner percentage: 0.47619047619047616
Average Loss amongst losers: -38.11501443323653
Average Gain amongst winners: 47976.05810288214
Average Buy Ranking: 141.32380952380953
Average sell rank: 213.10476190476192
The algorithm does not buy any tokens in 2018, when attempting to run from January to June, which is likely due to some bug or error in my code, rather than the markets, given that we have already seen that several coins gain significantly in this time period, when choosing a portfolio manually. Further testing is certainly required here.
The second most obvious question is that of the ideal variable settings. Determining this could be a machine learning task, or I could simply loop the algorithm with different settings each time and make note of the most profitable UP_MOVE, DOWN_MOVE and DAYS variables, which essentially is what a machine learning setup would do. However, I have not yet had the time to build in this feature.
In conclusion, I think we have shown something very interesting, namely that it is theoretically possible to construct portfolios that outperform the markets without considering price. Or rather, considering price only in its effect on relative ranking. Stay tuned for more.