scieee AI-readable full text Open interactive document viewer

Harnessing statistical arbitrage in cryptocurrencies: the machine learning edge: Strategic portfolio construction using logistic regression and gradient-boosted decision trees

Abdelazeem, Ahmed Asaad Refaei

Abstract

This study develops a predictive framework for identifying anomalies in cryptocurrency prices using only market data. The focus is on training and evaluating binary classification models, particularly Gradient-Boosted Decision Trees and Logistic Regression, to predict whether cryptocurrencies will outperform or underperform within the next 6-hour and the next 12-hour period. The methodology encompasses gathering exchange data, engineering features using market data, training the models, and performing backtests. The research reveals the limitations of relying solely on the binary classification (outperform or underperform), evidenced by an average accuracy of 51% in testing. However, the study innovatively utilizes the probabilistic outputs from these models instead of their binary predictions, leading to significantly positive returns when applied to a long-short, long-only, and short-only portfolio construction. This approach corroborates recent findings in the field, demonstrating the potential of machine learning in enhancing cryptocurrency trading strategies through a nuanced use of model-generated probabilities, building a long-only strategy with a return 3 times that of Bitcoin and double its Sharpe Ratio and a long-short strategy with a Sharpe of 1.49 and a lower drawdown than of Bitcoin’s.

Full text

Master Degree Program in Statistics and Information Management HARNESSING STATISTICAL ARBITRAGE IN CRYPTOCURRENCIES: THE MACHINE LEARNING EDGE Strategic Portfolio Construction Using Logistic Regression and Gradient-Boosted Decision Trees AHMED ASAAD REFAEI ABDELAZEEM Project Work presented as partial requirement for obtaining the Master Degree in Statistics and Information Management NOVA Information Management School Instituto Superior de Estatística e Gestão de Informação Universidade Nova de Lisboa MEGI NOVA Information Management School Instituto Superior de Estatística e Gestão de Informação Universidade Nova de Lisboa HARNESSING STATISTICAL ARBITRAGE IN CRYPTOCURRENCIES: THE MACHINE LEARNING EDGE Strategic Portfolio Construction Using Logistic Regression and Gradient-Boosted Decision Trees by Ahmed Asaad Refaei Abdelazeem Project Work presented as partial requirement for obtaining the Master’s degree in Statistics and Information Management, with a specialization in Risk Analysis and Management Supervised by Haris Chalvatzis Head of Quantitative Research, 3 Comma Capital SCR SA, Lisbon, Portugal (Current) PhD in Machine & Deep Learning, University of Macedonia, Thessaloniki, Greece (Current) MSc in Financial Engineering, University of California, Berkeley, California, United States (Past) VP - Machine Learning & Quantitative Research, Blackrock, San Francisco, California, United States (Past) David Duarte Investment Director, 3 Comma Capital SCR SA, Lisbon, Portugal (Current) Adjunct Lecturer, Nova Information Management School, Lisbon, Portugal (Current) Head of Markets and Portfolio Management Department, IGCP, E.P.E, Lisbon, Portugal (Past) MSc in Financial Derivatives, London Metropolitan University, London, United Kingdom (Past) January, 2024 1 STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Rules of Conduct and Code of Honor from the NOVA Information Management School. Lisbon, 21/01/2024 2 DEDICATION I dedicate this thesis to my loving mother and brother, whose unwavering support and belief in me have been my anchor throughout this challenging journey. Their sacrifices have not gone unnoticed, and this achievement is as much theirs as it is mine. In memory of my uncle, Dr. Hisham Sadek, who gave me full support and to my father. I also dedicate this work to my mentors Haris Chalvatzis and David Duarte and partners of 2iQ Research GmbH (my current employer and sponsor of the research) Patrick Hable and Robert Hable. 3 ACKNOWLEDGEMENTS I would like to extend my sincere gratitude to the following individuals, whose contributions were indispensable to the completion of this thesis: ▪ Haris Chalvatzis, offered invaluable guidance throughout the design phase of the prediction and backtesting engine. His insights and mentorship significantly shaped the direction of this research ▪ David Duarte, offered profound insights into the intricate nuances of the nascent crypto market. His expertise and patient guidance profoundly influenced my understanding of this evolving field, contributing substantially to the depth and breadth of this project ▪ Tomas Juhos, Quant Analyst at 2iQ Research, who contributed to the structuring and code quality for the data ingestion segment. His dedication added value to the overall quality of this work and its usability for 2iQ Research 4 ABSTRACT This study develops a predictive framework for identifying anomalies in cryptocurrency prices using only market data. The focus is on training and evaluating binary classification models, particularly Gradient-Boosted Decision Trees and Logistic Regression, to predict whether cryptocurrencies will outperform or underperform within the next 6-hour and the next 12- hour period. The methodology encompasses gathering exchange data, engineering features using market data, training the models, and performing backtests. The research reveals the limitations of relying solely on the binary classification (outperform or underperform), evidenced by an average accuracy of 51% in testing. However, the study innovatively utilizes the probabilistic outputs from these models instead of their binary predictions, leading to significantly positive returns when applied to a long-short, long-only, and short-only portfolio construction. This approach corroborates recent findings in the field, demonstrating the potential of machine learning in enhancing cryptocurrency trading strategies through a nuanced use of model-generated probabilities, building a long-only strategy with a return 3 times that of Bitcoin and double its Sharpe Ratio and a long-short strategy with a Sharpe of 1.49 and a lower drawdown than of Bitcoin’s KEYWORDS Statistical Arbitrage; Quantitative Finance; Cryptocurrencies; Machine Learning; Binary Classification; Portfolio Management; Logistic Regression; Algorithmic Trading; Sustainable Development Goals (SDG): 5 TABLE OF CONTENTS Statement of Integrity ....................................................................................................... 1 Dedication ......................................................................................................................... 2 Acknowledgements ........................................................................................................... 3 Abstract ............................................................................................................................. 4 List of Figures ..................................................................................................................... 7 List of Tables ...................................................................................................................... 8 List of Abbreviations and Acronyms .................................................................................. 9 1. Introduction ................................................................................................................ 10 2. Literature review ........................................................................................................ 10 3. Data and software ...................................................................................................... 15 3.1. Data ..................................................................................................................... 15 3.2. Software .............................................................................................................. 15 4. Overview of software infrastructure .......................................................................... 16 5. Methodology .............................................................................................................. 18 5.1. Training configuration ......................................................................................... 18 5.2. Training and trading datasets .............................................................................. 20 5.3. Feature engineering ............................................................................................ 20 5.3.1. Simple percentage change ........................................................................... 20 5.3.2. Time-series statistics .................................................................................... 21 5.3.3. Technical indicators ...................................................................................... 22 5.3.4. Categorical variables .................................................................................... 22 5.3.5. Features summary ........................................................................................ 23 5.4. Feature groups .................................................................................................... 23 5.5. Liquidity cutoff ..................................................................................................... 24 5.6. Target generation ................................................................................................ 24 5.7. Feature selection ................................................................................................. 24 5.8. Model Training .................................................................................................... 25 5.8.1. Logistic Regression ....................................................................................... 25 5.8.2. Gradient-Boosted Decision Trees ................................................................. 26 5.8.3. Baseline model ............................................................................................. 27 5.8.4. Cross-validation and model training ............................................................ 27 5.9. Model monitoring and metrics ............................................................................ 28 5.10. Portfolio Construction ................................................................................... 28 6 5.10.1. Trading strategies .................................................................................. 29 5.10.2. Trading constraints ................................................................................ 30 6. Results and discussion ................................................................................................ 31 6.1. Model results ....................................................................................................... 31 6.1.1. Prediction distribution per model ................................................................ 31 6.1.2. Aggregated metrics ...................................................................................... 31 6.1.3. Class 1 (Outperform Median XS) Metrics ..................................................... 31 6.1.4. Class 0 (Underperform Median XS) Metrics ................................................. 32 6.1.5. Feature importance ...................................................................................... 32 6.2. Portfolio results ................................................................................................... 33 6.2.1. Long portfolios summary results .................................................................. 33 6.2.2. Short portfolios summary results ................................................................. 34 6.2.3. Top-performing portfolios ............................................................................ 34 6.2.3.1. Top-performing long portfolio ........................................................... 35 6.2.3.2. Top-performing short portfolio ......................................................... 36 6.2.3.3. Top-performing long-short portfolio ................................................. 37 6.3. Discussion ............................................................................................................ 38 7. Conclusions and future works .................................................................................... 41 Bibliographical References .............................................................................................. 42 Appendix A ...................................................................................................................... 44 Appendix B ...................................................................................................................... 45 Appendix C ...................................................................................................................... 46 7 LIST OF FIGURES Figure 2.1: Cumulative Return of Major Cryptocurrencies over the past 3 years ................... 10 Figure 2.2: Trading Volume of Stablecoin-denominated Pairs ................................................ 11 Figure 2.3: Evolution of Stablecoin-denominated Pairs ........................................................... 11 Figure 5.1: Microservices workflow ......................................................................................... 17 Figure 6.1: Train-Test split ........................................................................................................ 19 Figure 6.2: Time-series cross-validation ................................................................................... 28 Figure 7.1: Feature importance (GBDT) – 6-hour .................................................................... 33 Figure 7.2: Feature importance (LR) – 6-hour .......................................................................... 33 Figure 7.3: Feature importance (GBDT) – 12-hour .................................................................. 33 Figure 7.4: Feature importance (LR) – 12-hour ........................................................................ 33 Figure 7.5: Cumulative Returns of Strategy Against Bitcoin .................................................... 36 Figure 7.6: Cumulative Returns of Strategy Against Short Bitcoin .......................................... 37 Figure 7.7: Cumulative Returns of Strategy Against Bitcoin .................................................... 38 14 conclusion, through examining efforts by other recent papers. The replicability or application of such framework is extremely challenging, due to the storage and computational costs of storing on-chain data as well as the data collection challenges when it comes to sentiment analysis. In this study we hedge against that by only combining market factors and technical factors for the price predictions. Tianyu Ray Li et al. (2019) explored the viability of forecasting price trends of ZClassic, a cryptocurrency which is deemed susceptible to sentiment due to its technological nuances and relatively lower trading volume. The authors combine sentiment analysis based on tweets related to the coin, as well as price data of the coin to measure the correlation of the prediction with real price movements, it is notable that the model proposed by the researchers struggled to capture sarcasm. The authors find a correlation of 0.81 with real price movements. Our research endeavours to delve into an area not extensively explored: analyzing the overall cryptocurrency market through a machine learning framework, particularly focusing on crosssectional analysis for portfolio construction. Furthermore, it introduces an innovative approach by utilizing the inherent probabilities from decision tree models and random forests, employing these as signals in portfolio construction. This aspect of our research is relatively new and forms the central theme of our study. 15 3. DATA AND SOFTWARE 3.1. DATA In this study, we use hour-binned data retrieved from Binance API for both prices and volumes, with date range from July 2020 to August 2023 (inclusive). For each hour, the following fields are collected: Table 1: Raw data fields Field Description symbol A trading pair composed of a base currency and a quote currency (eg. BTCBUSD) open_time Timestamp of open of the 1-hour tick, microsecond granularity open Price at open_time high Highest price recorded between open_time and close_time low Lowest price recorded between open_time and close_time close Price at close_time number_of_trades Indicates the total number of trades that have occurred for a specific trading pair between open_time and close_time. It represents the count of individual buying and selling transactions that have taken place volume Total trading volume of the base currency between open_time and close_time (eg. Number of Bitcoins traded) quote_volume Total trading volume between open_time and close_time, in terms of the quote currency The initial data collection covers more than 2000 trading pairs, and is narrowed down to 816 pairs, these are pairs quoted in USDT (Tether) or BUSD (Binance USD), TUSD (TrueUSD) and USDC (USD Coins). These coins are commonly used for various purposes within the cryptocurrency market, including trading and hedging. This constructs our main universe. 3.2. SOFTWARE This project uses Python 3.5.1 (Python Software Foundation) to conduct the analysis. This involves loading the data into PostgreSQL databases, preprocessing the data, and training machine learning models. Additionally, a backtesting engine is built to evaluate the trading performance of the models, given various portfolio constraints; the purpose of the backtesting engine is to run trading simulations, which are driven by the machine learning generated signals to simulate realistic investment portfolios to measure the expected profitability of the machine learning techniques. 16 4. OVERVIEW OF SOFTWARE INFRASTRUCTURE To answer our initial research question, on whether binary classification helps in identifying sources of outperformance in cryptocurrencies, a set of software components were developed to enable for training multiple models in parallel, using large amounts of data (hourly frequency) on more than 800 trading pairs. The process is composed of multiple steps and components. Table 2: Framework microservices Component Purpose 1. Binance API integration Retrieval and storage of 1 hour Kline data at high speed, with at most 5 minutes of delay 1.1 Metrics computation Applying feature transformation to raw data ingested from Binance API Kline data, this enables for speeding up the machine learning processes as the feature are already pre-computed and readily available through querying a PostgreSQL database 2. Model training and evaluation Enabling for cost-efficient parallelized model training using different training environments (including features used, feature selection method and different target variables) 3. Model monitoring Further analysis of the distributions of the predictions produced by the models to detect the variability in predictions produced by each model, at each point-in-time 4. Backtesting engine Building a flexible and specialized backtesting engine which constructs portfolios that replicate the signals produced by the models, while allowing for enforcing liquidity constraints and applying different transaction cost profiles for each trading strategy In summary, the framework enables for flexible and affordable testing of binary classification predictions on future returns of cryptocurrencies, using open-source software and publicly available datasets. This allows for fast-iteration of ideas, good and bad ones, evaluating them from both angles, predictive power, and profit-generation. The framework acts as a foundation, and provides a simple, easy to follow approach to change model training and trading environments and track the outcomes easily. The work could be extended through building dashboards to visualize the results for selected models or portfolios. It is important to note that the solution offers high flexibility changing the following aspects of the framework: ▪ Algorithms used as long as they predict a probability or a numerical target variable ▪ Target variable and frequency, the study focused on returns over the next 6 and 12 hours, yet the framework accommodates for changing the target to any other 17 variable computed during the feature engineering method. For example, the target could be a binary classifier of the Z-scored returns over the next 48 hours ▪ Target variable generation method, we use median cross-section return but other targets could be used such as percentile-based targets (e.g. if the return of coin will be above the 75th percentile of the market or whether the coin will underperform or outperform Bitcoin) ▪ Baseline model, we use a uniform distribution to simulate random predictions, to test the additivity of the models, other methods could be used by applying a new function, such as a naïve approach of using historical returns as a predictor of the probability of outperformance of future returns The framework is summarized in Figure 5.1. Figure 5.1: Microservices workflow 18 5. METHODOLOGY In many machine learning scenarios, datasets are divided into training and test sets, often with data from certain years used for training (in-sample) and subsequent years for testing (out-of- sample). This approach carries the risk of models overfitting the training data. Additionally, when signals derived from these training datasets are used for backtesting, such as in portfolio construction, the outcomes might appear impressive despite potentially underperforming in the test dataset. This risk could even be more prominent in crypto markets, as the market dynamics change rapidly, due to the immaturity of the market. This suggests that utilizing models trained on data from previous years to forecast the next day's market outperformance may be ineffective or illogical. A more reasonable approach is to build a continuous training and testing framework, or a rolling-window approach, where models “forget” older data points and are re-trained with fresher (more recent data). We have two windows of predictions, the next 6-hour and 12-hour periods. The methodology of this research is inspired by the methodology used by Fischer and Krauss (2018), aiming to create continuous out-of-sample datasets, with non-overlapping periods, to support portfolio construction. The key concept in this approach is building a set of training sets for in-sample model training and trading sets for out-of-sample predictions; the design yields a continuous out-of-sample trading dataset. This step is then followed by feature selection, model training and evaluation, and lastly portfolio construction. 5.1. TRAINING CONFIGURATION We define a training configuration as a set of parameters that construct a group of models, a GBDT algorithm, a Logistic Regression, and a baseline model. Each group of models holds the following variables in Table 3: Table 3: Training configuration variables Variable Possible values Observations Algorithms GBDT LR Model groups will always run both algorithms Training Frequency Size (in hours) 48 72 The size of the training and test dataset at each training instance, 48 and 72 for the Number of hours forward look of 6 and 12, respectively Number of hours forward look 6 12 Number of hours used to construct the median crosssection return target variable Liquidity metric Number of trades Metric used to represent liquidity Liquidity lookback period (in hours) 48 72 Always equivalent to the Training Frequency Size 19 Liquidity cutoff percentile 60 The lower bound of the percentile of the Liquidity metric, measured through the mean of each coins Number of trades during the last 48 or 72 hours prior to the datasets’ first timestamp Feature groups Group 1: [MOMENTUM, NUMBER_OF_TRADES, VOLUME, ZSCORE_RETURNS, VOLATILITY_RETURNS, RSI] Group 2: [ST_MOMENTUM, MT_MOMENTUM, LT_MOMENTUM, ST_VOLATILITY_RETURNS, MT_VOLATILITY_RETURNS, LT_VOLATILITY_RETURNS, ST_VOLUME, MT_VOLUME, LT_VOLUME] The feature values are grouped into main groups where the first group includes higher granularity and more features, while the second group contains hand-picked features that suit the problem at hand. Both feature groups also receive the liquidity bucket Cross-validation metric F1 Score Used during the cross-validation to select the best parameter set Feature selection method Correlation-based (Corr) Principal Component Analysis (PCA) Method used for selecting the best features We end up with a total of 8 combinations of model groups, by mixing the variables, the aim is to either the outperformance to the median cross-section median over the next 6 hours or 12 hours, using the 2 feature groups proposed, and using two distinct feature selection methods. Since each model group consists of both GBDT, LR and a randomized baseline, we end up with a total of 24 models, 12 for each time period. A combination of the variables described in Table 3 defines a model group. Each training instance represents a model to predict the next 6 hours or 12 hours of crosssectional outperformance/underperformance. An example is provided In Figure 6.1 for the 6- hour prediction. Figure 6.1: Train-Test split The result of the design is a continuous out-of-sample period and a reactive model that maintains a short memory of training and gets updated according to new market conditions. As explained in Figure 6.1, the last 6 hours (or 12 hours) of training data is excluded from the 20 dataset to avoid data leakage, as the target variable will be developed using data that is computed within the out-of-sample data. Another very important concept is that our training datasets are both coin agnostic and time agnostic, in other words, we drop the symbol, open_time and close_time variables completely, and treat all the rows equally, considering only the features mentioned in section 5.3. 5.2. TRAINING AND TRADING DATASETS For each model group, we start with loading data starting from the timestamp: 2020-07-28: 00:00:00 (start timestamp), plus its respective Training Frequency Size, 48 or 72 hours ahead. This data encompasses all coins that have been trading during the start timestamp, and encompasses hourly data for all coins, with the columns being the variables belonging to the Feature Groups (Group 1 and Group 2). For the trading dataset, we use data from 2020-07-29 until 2022-07-31 as in-sample and from 2022-08-01 to 2023-07-31 as out-of-sample. The full trading period falls within the test datasets constructed; no trading simulation ever occurs on training data. In other words, we have continuous predictions on the test datasets, from the start to the end of the entire study period. The in-sample and out-of-sample split is only useful to evaluate portfolio performance in two different periods and the stability of returns and risk profiles of models. 5.3. FEATURE ENGINEERING After collecting the raw hourly price data, we compute a set of hourly metrics for all coins in the universe. The features fall into the main groups: 5.3.1. SIMPLE PERCENTAGE CHANGE We calculate different speeds (or lookback periods) for percentage changes of variables. We use the momentum variable as an example: 𝑅𝑡,𝑡−ℎ 𝑐=𝑃𝑡𝑐 𝑃𝑡−ℎ 𝑐− 1 ▪ 𝑃𝑡−ℎ 𝑐: Price of coin c at the close of hour t - h ▪ 𝑃𝑡𝑐: Price of coin c at hour t ▪ 𝑡: Is the current hour ▪ 𝑅𝑡,𝑡−ℎ 𝑐: Return of coin c between at close of hour t, given a lookback h The percentage change at period 𝑡 is calculated by dividing the value of the field at 𝑡−ℎ, where ℎ is the lookback period (inclusive), so for example, for computing the return the last 3 hours, the price at close of hour 𝑡, will be divided by the close price at hour 𝑡−3. The same logic is applied for other fields, including number of trades and quote volume. 21 5.3.2. TIME-SERIES STATISTICS We then compute statistics which use the momentum return variables: 𝜎(𝑅𝑡,𝑡−ℎ 𝑐)= √1𝑁∑(𝑅𝑖,𝑖−1 𝑐− 𝑅𝑡,𝑡−ℎ 𝑐)2 𝑡 𝑖=𝑡−ℎ First, the Standard Deviation of returns: Where: ▪ N: The number of return observations in the lookback period ℎ ▪ 𝑅𝑖,𝑖−1 𝑐: Return of coin c at close of hour 𝑖, given a lookback of 1 hour ▪ 𝑅𝑡,𝑡−ℎ 𝑐: Average return of coin c over the lookback period from 𝑡−ℎ to t ▪ 𝑡: Is the current hour ▪ 𝜎(𝑅𝑡,𝑡−ℎ 𝑐): standard deviation of returns for coin c over the lookback period Secondly, the time-series Z-Score: 𝑍𝑡,𝑡−ℎ 𝑐= 𝑅𝑡,𝑡−ℎ 𝑐−𝜇𝑡,𝑡−ℎ 𝑐 𝜎(𝑅𝑡,𝑡−ℎ 𝑐) Where: ▪ 𝑅𝑡,𝑡−ℎ 𝑐: Return of coin c between at close of hour t, given a lookback ℎ ▪ 𝜇𝑡,𝑡−ℎ 𝑐: mean (average) return of coin c over the lookback period ℎ ▪ 𝜎(𝑅𝑡,𝑡−ℎ 𝑐): standard deviation of the return of coin 𝑐 over the lookback period ℎ ▪ 𝑡: Is the current hour ▪ 𝑍𝑡,𝑡−ℎ 𝑐: Z-Score of the return of coin c at time t with a lookback period ℎ 22 5.3.3. TECHNICAL INDICATORS Lastly, a single technical indicator, Relative Strength Index (RSI): 𝑅𝑆𝐼ℎ=100−( 100 1+𝑅𝑆ℎ) Where: ▪ 𝑅𝑆ℎ= 𝐴𝑣𝑒𝑟𝑎𝑔𝑒 𝐺𝑎𝑖𝑛ℎ 𝐴𝑣𝑒𝑟𝑎𝑔𝑒 𝐿𝑜𝑠𝑠ℎ ▪ 𝐴𝑣𝑒𝑟𝑎𝑔𝑒 𝐺𝑎𝑖𝑛ℎ= 𝑆𝑢𝑚 𝑜𝑓 𝐺𝑎𝑖𝑛𝑠𝑡 ℎ ▪ 𝐴𝑣𝑒𝑟𝑎𝑔𝑒 𝐿𝑜𝑠𝑠ℎ= 𝑆𝑢𝑚 𝑜𝑓 𝐿𝑜𝑠𝑠𝑒𝑠𝑡 ℎ ▪ 𝐺𝑎𝑖𝑛𝑠𝑡={∆𝑃𝑡𝑐 | ∆𝑃𝑡𝑐>0} ▪ 𝐿𝑜𝑠𝑠𝑒𝑠𝑡={∆𝑃𝑡𝑐 | ∆𝑃𝑡𝑐<0} ▪ ℎ: is the number of hours in the lookback period ▪ 𝑡: Is the current hour ▪ 𝑃𝑡𝑐: Price of coin c at hour t ▪ 𝑅𝑆𝐼ℎ: Relative Strength Index during the lookback period of ℎ 5.3.4. CATEGORICAL VARIABLES Since the models are intended to be symbol-agnostic, the Liquidity Bucket variable is added to differentiate between highly liquid symbols and less liquid symbols, comparing them 72 or 48 hours (depending on the target variable) before the training datasets’ minimum timestamp, at each training instance. The liquidity classification is calculated through the following function: 𝑓𝑐(𝐿)= {3, 𝑖𝑓 𝐿>𝑄𝑢𝑎𝑛𝑡𝑖𝑙𝑒0.67(𝐻[𝐿]) 1, 𝑖𝑓 𝐿<𝑄𝑢𝑎𝑛𝑡𝑖𝑙𝑒0.33(𝐻[𝐿]) 2, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 Where: ▪ 𝐿: This specific instance or current value of the Number of trades for the cryptocurrency in question, used to compare against historical quantiles to determine its liquidity classification ▪ 𝐻[𝐿]: Represents the set of historical values of Number of trades for all coins in the universe ▪ 𝑓𝑐(𝐿): A function which classifies the liquidity of a cryptocurrency into three levels based on its Number of trades historical distribution Through this, records belonging to symbols that have been highly tradeable during the past 72 or 48 hours get assigned one of the three buckets, this classifier aims to help the models 23 consider the liquidity bucket the coin belongs to and to not treat records of highly liquid coins similarly to illiquid ones. 5.3.5. FEATURES SUMMARY In Table 5.1, a comprehensive summary of the selected features is presented. Each feature belongs to a “feature group”, implying that a feature group will include multiple features. This facilitates evaluating models trained using different feature groups. Table 4: Computed features Field mnemonic Field description Values of 𝒏 (in hours) Feature group Statistic type ret_c_pct_{𝒏}h Percentage change in Close price between current hour and 𝑛 hours back [1, 3, 6, 9, 12, 18, 24, 30, 36, 42, 48, 57, 63, 69, 72] MOMENTUM Simple percentage change [1, 3, 6] ST_MOMENTUM [12, 18, 24] MT_MOMENTUM {36, 48, 72} LT_MOMENTUM volume_pct_{𝒏}h Percentage change in Volume between current hour and 𝑛 hours back {1, 3, 6, 9, 12, 18, 24, 30, 36, 42, 48, 57, 63, 69, 72} VOLUME Simple percentage change {1, 3, 6} ST_VOLUME {12, 18, 24} MT_VOLUME {36, 48, 72} LT_VOLUME stdev_ret_c_pct_{𝒏}h Time-series Standard Deviation of the ret_c_pct_{𝑛}h values of a single symbol for a lookback 𝑛 {3, 6, 9, 12, 15, 18, 24, 30, 36, 42, 48, 54, 60, 66, 69, 72} VOLATILITY_RETURNS Timeseries statistics {3, 6} ST_VOLATILITY_RETURNS {18, 24} MT_VOLATILITY_RETURNS {36, 72} LT_ VOLATILITY_RETURNS not_pct_{𝒏}h Percentage change in Number of trades between current hour and 𝑛 hours back [1, 3, 6, 9, 12, 18, 24, 30, 36, 42, 48, 57, 63, 69, 72] NUMBER_OF_TRADES Simple percentage change zs_ret_c_pct_{𝒏}h Time-series Z-Score of the ret_c_pct_{𝑛}h values of a single symbol for a lookback 𝑛 [3, 6, 9, 12, 15, 18, 24, 30, 36, 42, 48, 54, 60, 66, 69, 72] ZSCORE_RETURNS Timeseries Statistics rsi_{𝒏}h Relative Strength Indicator (RSI) over a lookback period of 𝑛 hrs [3, 6, 7, 9, 12, 14, 15, 18, 21, 24, 30, 36] RSI Technical statistic liquidity_bucket A categorical variable classifying the level of liquidity of each coin compared to the crosssection, during the last 𝑛 hours 48 72 N/A Categorical variable 5.4. FEATURE GROUPS We construct two feature groups: Group 1: A highly dimensional group, consisting of 90 features (including the liquidity bucket variable). The motivation behind the selection is to provide the models with variables from different themes, ranging from momentum indicators to technical indicators, with several lookback periods. 30 behind tracking each portfolios long and short legs separately (instead of a long-short directly) is enabling for building new long-short combinations from portfolios with different models, signal sensitivity and fallback market positions. This supports our effort in finding the best long-short combination across all portfolios constructed in the study. 5.10.2. TRADING CONSTRAINTS For all portfolios, we consider two important constraints and assumptions we only trade coins if the pair had liquidity of at least $200,000 in the previous hour pre-trading. When it comes to trading costs, the analysis considers 6 basis points for both buying and selling. This is derived from Binance’s VIP 3 level, which requires approximately $20,000,000 of trading volume during a the last trailing 30 days. Given the high rebalancing frequencies (6-hours and 12- hours), reaching such volume in a month through a $100,000 - $200,000 of invested capital would be feasible. 31 6. RESULTS AND DISCUSSION 6.1. MODEL RESULTS In this section we display the analysis of the models during the entire study period with only looking at predictions on the test datasets. 6.1.1. PREDICTION DISTRIBUTION PER MODEL Table 6: Algorithms comparison prediction distribution Baseline LGBM LR mean 0.50 0.49 0.46 median 0.50 0.49 0.46 mode 0.50 0.52 0.56 min 0.01 0.27 0.10 max 0.99 0.72 0.81 stdev 0.29 0.09 0.12 range 0.99 0.45 0.71 iqr 0.49 0.12 0.11 skewness 0.00 -0.02 -0.08 kurtosis -1.18 0.48 16.20 jarque_bera_p_value 0.01 0.13 0.01 At each test instance, for each model belonging to the algorithms in question, we get the universe of predictions by coin and calculate the metrics above. After that, we take an average for the metric throughout the whole period. These values correspond to the out-of-sample predictions only. 6.1.2. AGGREGATED METRICS We further analyze the performance on each algorithm (Appendix A), through calculating the average, minimum and maximum of the following performance statistics: Accuracy, Precision, Recall, F1 Score and AUC on both the training dataset and the test dataset. 6.1.3. CLASS 1 (OUTPERFORM MEDIAN XS) METRICS Conducting the same analysis on the relevant metrics for the Class 1 (Appendix B), outperformance, we find the following: ▪ Overall, GBDT produce a higher precision delta than the baseline consistently across all both its models, with average precision of 51% for this class, and a maximum of 89% of Precision. 32 ▪ Models trained using LR where PCA-based feature selection is applied, are highly performant. Matching the 51% average precision achieved through GBDT, and yielding a delta of 6% and 7% over the baselines’ Recall, for the 6-hour and 12- hour predictions. ▪ When taking a closer look at the PCA-based models (which typically yield a lower dimension), the LR outperformed significantly for this class. Especially when it is provided the hand-curated feature group (Group 2), which includes much fewer variables; in fact, the best-performing model is the LR’s 6-hour PCA-based model, achieving an average prediction Precision of 52% (with a maximum of 92%), and average Recall of 61%, implying an 11% delta over the random baseline. 6.1.4. CLASS 0 (UNDERPERFORM MEDIAN XS) METRICS Analyzing the model’s performance on predicting a coin’s underperformance against the XS- median (Appendix C), we observe similar patterns when it comes to the performance of LR being negatively impacted with high dimensionality. We prioritize evaluating the class performance based on Precision, as False Positives, in the context of a long portfolio could be expensive. ▪ LR with PCA and Group 2 continues to outperform, yielding an average delta of 3% in Precision over the baseline model ▪ GBDT with Correlation-based also produces a delta of 1% over the baseline average Precision, reaching a maximum of 81% and an average Recall delta of 8% 6.1.5. FEATURE IMPORTANCE In this section, we aim to analyze which features seem to explain both the 6-hour and 12-hour predictions the most. We observe the correlation-based models, as they are the ones where we can trace back the features used (unlike the PCA approach). We also check only for the models trained using Group 2, the curated features group. The goal is to conduct a fair comparison between both algorithms, as the LR would be more sensitive to high dimensionality. We restrict the universe to the top 10 ranked features to ease the analysis. For the LR, we define feature importance as the absolute value of the coefficients of the regression. For the GBDT we use sci-kit learns’ feature importance method using the default ‘split’ parameter which measures the number of times a feature is used in the model to make splitting decisions across all trees. 33 Figure 7.1: Feature importance (GBDT) – 6- hour Figure 7.2: Feature importance (LR) – 6- hour Figure 7.3: Feature importance (GBDT) – 12- hour Figure 7.4: Feature importance (LR) – 12- hour 6.2. PORTFOLIO RESULTS We start by analyzing the 144 initial portfolios that were constructed based on the 24 models, looking at the portfolios with the best-performing long-legs and short-legs. Returns on the short legs are presented in positive values, with positive returns implying profitability. During the research we maintain portfolio identifiers as numerical IDs, to avoid being biased towards an algorithm or another. In this section, we only compute the portfolio metrics in net terms, while with the Sharpe Ratio, we do not use a risk-free. 6.2.1. LONG PORTFOLIOS SUMMARY RESULTS We first look at the performance in the in-sample period, Table 7 displays the top 15 long-legs are displayed, sorted by Cumulative Return. Table 7: Long-legs performance (in-sample) Annualized Ret Annualized Vol Sharpe Ratio Skewness Kurtosis VaR (5%) Max DD Cum Ret Portfolio Algorithm Model Fallback Prediction Hour 1.33 0.94 1.41 1.08 32.45 0.01 -0.71 4.42 481 LGBM 61 buy_btc 6 1.11 0.59 1.86 4.56 165 -0.02 -0.33 3.44 475 LGBM 61 buy_nth 6 1.08 1.1 0.98 0.07 24 0.01 -0.82 3.34 478 LGBM 61 buy_basket 6 0.55 1.21 0.46 0.99 83.13 0 -0.72 1.41 594 LR 65 buy_nth 12 0.54 0.83 0.66 0.21 19.07 0.01 -0.79 1.38 526 LGBM 52 buy_btc 6 0.53 1.04 0.51 -0.47 21.18 0.02 -0.76 1.34 517 LGBM 64 buy_basket 12 0.39 0.85 0.46 0.19 30 0.01 -0.72 0.93 529 LGBM 64 buy_btc 12 0.36 1.02 0.35 -0.62 17.78 0.02 -0.85 0.85 514 LGBM 52 buy_basket 6 0.22 1.44 0.15 5.82 297.77 -0.1 -0.79 0.48 518 LR 65 buy_basket 12 0.13 1.18 0.11 -0.37 27.04 0.02 -0.9 0.27 505 LGBM 73 buy_basket 12 34 0.12 1.29 0.09 0.8 64.74 0 -0.77 0.25 690 LR 65 buy_btc 12 0.1 1.08 0.09 -0.62 26.68 0.02 -0.89 0.21 689 LGBM 64 buy_btc 12 0.07 1.09 0.07 -0.77 28.5 0.02 -0.92 0.15 548 LGBM 67 buy_basket 12 0.05 0.37 0.15 2.57 224.48 -0.01 -0.32 0.11 532 LGBM 52 buy_nth 6 0.02 1.17 0.02 -0.64 20.94 0.02 -0.92 0.04 641 LGBM 64 buy_basket 12 We note that portfolio 481 is the top performant, a portfolio that buys BTCUSDT when the underlying model is inactive, rebalances every 6-hours and receives signals from an LGBM model, following the Group 2 features and a correlation-based feature selection approach the top 3 portfolios belong to the same model, suggesting that low-dimensionality seems to contribute in the effectiveness of the predictions, irrespective of the fallback market position. An important result is that none of the top 15 portfolios belong to the baseline models, suggesting that the models outperform pure random behaviour. The additional portfolios that are later added (by removing volume features from Group 2) change the ranking of the top 15, with three of them appearing in the top 15. This suggests that reducing dimensionality improves predictions of coins outperforming the XS, those that make it to the top 15 belong to the 12-hour prediction. 6.2.2. SHORT PORTFOLIOS SUMMARY RESULTS The same analysis is conducted on the short side: Table 8: Short-legs performance (in-sample) Annualized Ret Annualized Vol Sharpe Ratio Skewness Kurtosis VaR (5%) Max DD Cum Ret Portfolio Algorithm Model Fallback Prediction Hour 2.02 0.83 2.42 -1.32 113.3 0 -0.36 0.75 566 LGBM 67 sell_nth 12 -0.29 1.02 -0.28 0.15 15.29 0.01 -0.49 -0.16 568 baseline 69 sell_nth 12 -0.1 0.47 -0.2 -0.39 336.15 -0.02 -0.56 -0.18 514 LGBM 52 sell_nth 6 -0.19 0.8 -0.24 -2.79 119.13 0 -0.76 -0.35 548 LGBM 67 sell_nth 12 -0.25 1.02 -0.25 -2.53 107.92 0 -0.93 -0.44 496 LGBM 70 sell_nth 12 As expected, during the in-sample period, market conditions are not in favour of shorting cryptocurrencies, with the best-performing short portfolios being the ones where selling nothing is a fallback strategy during model inactivity. The LGBM models dominate the top 5 portfolios, with one portfolio reaching a Sharpe Ratio of 2.42. After that, we analyze how the newly created portfolios impact the ranking. Contrary to the long portfolios, the newly created portfolios slightly change the ranking, with one portfolio going to the Top-performing one, with more than three times the Cumulative Return of the top portfolio (566), but a lower Sharpe Ratio and worse Maximum Drawdown. The reason behind focusing on the top 5 only is the fact that we selected 2 fallback strategies (out of 3) in which we choose to not trade any coins whenever the models’ short leg is inactive. 6.2.3. TOP-PERFORMING PORTFOLIOS In this section, we consider all the constructed portfolios during the in-sample and out-of- sample periods. We also construct long-short combinations based on the top 15 long portfolios and top 5 short portfolios during the in-sample period. Our metric to define the best-performing is the cumulative return across the entire period (in-sample and out-of- sample). 35 6.2.3.1. TOP-PERFORMING LONG PORTFOLIO Table 9: Top-performing long portfolio statistics Long Portfolio 481 BTCUSDT In Sample Out Sample Combined In Sample Out Sample Combined Sharpe Ratio 1.41 0.33 1.03 0.57 0.53 0.55 Max Drawdown -0.71 -0.31 -0.71 -0.74 -0.37 -0.77 Cumulative Return 4.42 0.18 5.42 1.07 0.25 1.61 Annualized Return - - 0.86 - - 0.37 Annualized Vol - - 0.83 - - 0.68 Portfolio 481, the best-performing long-leg in-sample, continues its outperformance for the entire period. This portfolio buys coins whenever predictions are above 90% probability of outperformance, and otherwise buys BTCUSDT. The portfolio is backed by signals generated every 6 hours, through an LGBM model, using correlation-based feature selection and trained on the Group 2 feature group. The portfolio clearly enhances the overall performance of being just exposed to Bitcoin. Figure 7.5 illustrates the performance across the entire period. The top portfolio is exposed to the strategy approximately 10% of the time. The spread between the return of the portfolio over Bitcoin, when it is exposed to the predictions, is positively skewed, with a skewness of 1.35. 36 Figure 7.5: Cumulative Returns of Strategy Against Bitcoin 6.2.3.2. TOP-PERFORMING SHORT PORTFOLIO We display the return of a naive short position on BTCUSDT pair vs the best-performing short portfolio. The best-performing portfolio sells no coins when there are no predictions meeting its criteria, a probability of 10% (at most) of outperformance (or at least 90% of underperformance) and belongs to an LGBM model, with correlation-based feature selection, predicting the outperformance/underperformance over the next 12-hour. This model uses Group 1, a highly dimensional group. Table 10: Top-performing short portfolio statistics Short Portfolio 496 Short BTCUSDT In Sample Out Sample Combined In Sample Out Sample Combined Sharpe Ratio -0.25 4.41 0.42 -0.80 -0.76 -0.79 Max Drawdown -0.93 -0.54 -0.93 -0.93 -0.56 -0.93 Cumulative Return -0.44 4.16 1.87 -0.85 -0.37 -0.91 Annualized Return - - 0.42 - - -0.54 Annualized Vol - - 1 - - 0.68 37 Although short-selling is deemed very risky in cryptocurrency markets, during the entire study period, Portfolio 496 outperforms all other short-portfolios, with a positive annualized return and a cumulative return in of 1.87. This portfolio is exposed to the strategy approximately 20% of the time, and when the model is inactive (not producing strong enough signals or probabilities of coins underperforming the cross-section) the portfolio does not short any pairs. The strategy beats the long BTCUSDT’s overall cumulative return. Figure 7.6 demonstrates the outperformance of the strategy. Figure 7.6: Cumulative Returns of Strategy Against Short Bitcoin 6.2.3.3. TOP-PERFORMING LONG-SHORT PORTFOLIO After examining the long-short portfolio combinations, we sort by Sharpe Ratio and find that the best-performing long-short portfolio is a mix between the best long-portfolio and the best short-portfolio, the results are displayed in Table 11 and Figure 7.7. 38 Table 11: Top-performing Long/Short portfolio statistics Long/Short BTCUSDT In Sample Out Sample Combined In Sample Out Sample Combined Sharpe Ratio 0.69 5.21 1.49 0.57 0.53 0.55 Max Drawdown -0.7 -0.57 -0.7 -0.74 -0.37 -0.77 Cumulative Return 2.69 5.37 22.49 1.07 0.25 1.61 Annualized Return - - 1.86 - - 0.37 Annualized Vol - - 1.24 - - 0.68 Figure 7.7: Cumulative Returns of Strategy Against Bitcoin 6.3. DISCUSSION We note that the LR has, on average, a higher standard deviation in the predictions, hinting that it can differentiate between different coins, as well as having a larger range of predictions. On average, the 𝑝−𝑣𝑎𝑙𝑢𝑒 of the Jarque-Bera normality test is 1%, which suggests that the predictions follow a normal distribution. It is important to note that on average the LR predicts that coins have a 46% probability of outperforming the XS, this potentially suggests that the algorithm might not be able to capture coins which will outperform and may be better in 39 predicting the ones underperforming. On the other hand, the LGBM algorithm seems to have predictions more centred around the 50% mark, with lower 𝑟𝑎𝑛𝑔𝑒. We find that through both algorithms we reach an Accuracy of 74%, at some test instances, and an average Accuracy of 50% or 51%. This depends on both variables, the algorithm used as well as the feature selection method. For the GBDT, the models trained through correlationbased feature selection outperform the PCA-based ones; we observe the opposite behaviour for LR. More signs of overfitting, due to the loss in predictive power between training datasets and test datasets in the GBDT, compared to the LR. However, the best-performing models overall, that are consistent across both feature selection methods are of the GBDT, when predicting the outperformance/underperformance over the next 6-hour returns cross-sectional median returns. Across all models on both time periods, the Volatility of Returns over the past 72 hours (stdev_ret_c_pct_72h) appears the most in the top 5 positions, across all training instances of the models. This is an important finding highlighting the significance of historical volatility in predicting return direction for cryptocurrencies. Additionally, most of the relevant variables are of lookback periods that are higher (longer) than the forward look period; in GBDT models, both the ret_c_pct_12h and ret_c_pct_6h seem to contribute to the prediction, yet are both superseded by the ret_c_pct_72h, ret_c_pct_48h and ret_c_pct_36h. The same pattern holds true for the LR. This suggests that returns of over a larger period are more indicative of future performance, or at least carry more information. This contradicts the results of (Fischer et al., 2019) who attempted to predict the same target variable, using minute data, for the next 120 minutes of return. The authors conclude that the lower lookback periods contribute more. It is important to note that their analysis was conducted on a smaller universe, different target variable and period. When it comes to the portfolio simulation, we observe that portfolios which act on model predictions only on high probability values (high conviction) outperform others. This suggests that the underlying probability behind the classifications generated by both LR and LGBM hold important information. Both the top performant long and short portfolios belong to LGBM trained models on correlation-based feature selection, suggesting that the PCA approach might not be the most ideal for LGBM. Another important finding is that baseline portfolios do perform extremely poorly compared to portfolios backed by LR and LGBM. We do find additionality when it comes to constructing portfolios that use the signals when they are strong enough and find that the results are robust even when changing the fallback strategies when not enough signals are present. The top three long portfolio all belong to the same model (an LGBM), yet have different fallback strategies (buy nothing, buy BTCUSDT or buy a basket of coins). 46 APPENDIX C Class 0 (Underperform Median XS) Metrics Algorithm GBDT LR aux_target_variable ret_c_pct_12h ret_c_pct_6h ret_c_pct_12h ret_c_pct_6h feature_selection_method correlation_based pca_based correlation_based pca_based correlation_based pca_based correlation_based pca_based features_nature Group 1 Group 2 Group 1 Group 2 Group 1 Group 2 Group 1 Group 2 Group 1 Group 2 Group 1 Group 2 Group 1 Group 2 Group 1 Group 2 avg_train_precision_c0 0.8 0.77 0.78 0.71 0.81 0.78 0.8 0.72 0.53 0.52 0.53 0.57 0.53 0.52 0.53 0.56 avg_train_recall_c0 0.78 0.74 0.75 0.67 0.79 0.75 0.77 0.68 0.62 0.57 0.49 0.44 0.59 0.55 0.49 0.43 avg_train_f1_c0 0.78 0.75 0.76 0.69 0.8 0.76 0.78 0.7 0.48 0.49 0.5 0.49 0.47 0.48 0.5 0.48 avg_test_precision_c0 0.51 0.51 0.5 0.51 0.51 0.51 0.5 0.51 0.5 0.5 0.5 0.53 0.5 0.5 0.5 0.53 min_test_precision_c0 0.26 0.32 0.41 0.33 0.31 0.16 0.29 0.26 0 0 0.35 0.2 0 0 0.19 0.22 max_test_precision_c0 0.71 0.74 0.6 0.74 0.81 0.76 0.67 0.75 1 0.81 0.69 0.82 1 1 0.78 0.8 avg_test_precision_c0_delta 0.01 0.01 0 0.01 0.01 0.01 0 0.01 0 0 0 0.03 0 0 0 0.03 avg_test_recall_c0 0.53 0.53 0.49 0.51 0.52 0.52 0.49 0.5 0.61 0.56 0.48 0.44 0.58 0.54 0.48 0.43 min_test_recall_c0 0.05 0.08 0.1 0.1 0.02 0.01 0.01 0.07 0 0 0.03 0.03 0 0 0.02 0 max_test_recall_c0 0.98 0.99 0.94 0.97 0.99 0.98 0.93 0.98 1 1 0.98 0.98 1 1 0.99 1 avg_test_recall_c0_delta 0.04 0.03 -0.01 0.01 0.03 0.02 -0.01 0.01 0.12 0.06 -0.02 -0.06 0.08 0.04 -0.02 -0.07 avg_test_f1_score_c0 0.51 0.51 0.49 0.5 0.51 0.5 0.48 0.5 0.47 0.48 0.46 0.45 0.46 0.47 0.46 0.45 min_test_f1_score_c0 0.09 0.13 0.17 0.16 0.04 0.02 0.02 0.11 0 0 0.06 0.05 0 0 0.03 0.01 max_test_f1_score_c0 0.71 0.73 0.67 0.71 0.71 0.75 0.66 0.73 0.67 0.67 0.68 0.73 0.67 0.67 0.68 0.74 avg_test_f1_score_c0_delta 0.01 0.01 -0.01 0 0.01 0 -0.01 0 -0.03 -0.02 -0.03 -0.05 -0.04 -0.03 -0.04 -0.05 47