A New Approach to Predicting Cryptocurrency Returns Based on the Gold Prices with Support Vector Machines during the COVID-19 Pandemic Using Sensor-Related Data

In a real-world situation produced under COVID-19 scenarios, predicting cryptocurrency returns accurately can be challenging. Such a prediction may be helpful to the daily economic and financial market. Unlike forecasting the cryptocurrency returns, we propose a new approach to predict whether the return classification would be in the first, second, third quartile, or any quantile of the gold price the next day. In this paper, we employ the support vector machine (SVM) algorithm for exploring the predictability of financial returns for the six major digital currencies selected from the list of top ten cryptocurrencies based on data collected through sensors. These currencies are Binance Coin, Bitcoin, Cardano, Dogecoin, Ethereum, and Ripple. Our study considers the pre-COVID-19 and ongoing COVID-19 periods. An algorithm that allows updated data analysis, based on the use of a sensor in the database, is also proposed. The results show strong evidence that the SVM is a robust technique for devising profitable trading strategies and can provide accurate results before and during the current pandemic. Our findings may be helpful for different stakeholders in understanding the cryptocurrency dynamics and in making better investment decisions, especially under adverse conditions and during times of uncertain environments such as in the COVID-19 pandemic.


Introduction
In the last two years, the impact of the 2019 Coronavirus Disease (COVID-19) on the trading strategies between different types of cryptocurrencies, gold, exchange market, portfolio diversification, and macroeconomic policy has attracted a great deal of interest in the financial market [1]. The unexpected recent exponential increase in cryptocurrency prices has exceeded the investors' imaginations. However, this does not indicate that cryptocurrencies are a substitute for gold [2]. For more than 2000 years, gold has been known as a high-quality liquid asset that has served as a hedge and safe haven for exchanging commodities. Several robust statistical models have been proposed to explore the predictability of the gold price [2,3].
Cryptocurrencies are digital currencies that belong to a decentralized system still classified in the nascent asset class [4]. Their prices are very sensitive to good and bad news with significant instability leading to high volatility and making the predictions hard and challenging, especially under adverse market conditions [2,4]. Thus, investments in cryptocurrencies are, often, equated to investments in gold, where cryptocurrencies may benefit from higher allocations to gold and vice-versa [2]. the SVC model was utilized to predict whether the price of three cryptocurrencies (BTC, ETH, and LTC) would increase or decrease in the next day.
Note that traditional econometric and time-series models, such as the ARMA and GARCH models, might not provide helpful results in predicting cryptocurrency returns due to the impact of risk and uncertainty on return volatility. Although several SVM techniques have already been used in numerous applications, very few have been done in the cryptocurrency market. To the best of our knowledge, the SVM has never been employed to predict the daily classification of cryptocurrency returns according to the quantiles of the gold price the next day.
Our objective is to propose a new approach for predicting cryptocurrency returns by using the SVC technique. Specifically, instead of forecasting the movement of the cryptocurrency return indicating whether it would go up or down, we forecast the type of this return reporting whether it would be in the first, second, third quartile, or any quantile of the gold price the next day. Therefore, our investigation fills this gap by proposing a new methodology for predicting the daily classification of cryptocurrency returns according to the quantiles of the gold price the next day. We classify the returns of the six major digital currencies (ADA, Binance Coin -BNB-, BTC, Dogecoin -DOGE-, ETH, and Ripple -XRP-) selected from the list of top ten cryptocurrencies into four categories according to the quartiles of the gold price values. In the current COVID-19 contingency scenario, data of cryptocurrency returns and COVID-19 are often collected through sensors [31][32][33].
The rest of this article is organized as follows. In Section 2, we propose an algorithm that uses a sensor in the database to predict the return of cryptocurrencies considering COVID-19 data and the price of gold. Section 3 defines the methodology based on the SVM models employed in this study. In Section 4, we present the data and results of our investigation, whereas in Section 5 our conclusions are reported.

Sensing Data of Cryptocurrencies, Gold, and COVID-19
To perform the empirical analysis proposed in this work (see Section 4), a software has been implemented with a local database that uses the SVM algorithm considering two aspects. In addition, we design an algorithm that allows us to sense changes in the data and show updated results. The database management system permits the configuration of a digital sensor. This sensor can detect if new data are entered into the database, if the data are modified, or if data are deleted.
In this work, a sensor that detects the presence of new data is utilized. As a response to new data, a trigger is implemented, which enables instructions to be registered and executed when the new data arrive. This sensor permits the software that performs the calculations to be notified that new records were entered in the database and therefore that the computations must be updated.
In summary, the local database is updated daily with external data (websites). A sensor in the local database sends a signal to the developed software to perform the calculations considering the new data. The software receives the signal and executes the corresponding processing. Lastly, the software delivers the results.
Next, we describe Algorithm 1 that senses changes in the data and shows updated results. For the sake of better understanding, we relate some steps of this algorithm to our case study in Section 4.

Algorithm 1
Approach to predict the daily classification of cryptocurrencies returns relating them to gold price and COVID-19 data using sensors. 5.2 Use the probability density function to state the type of skewness and kurtosis of the data empirical distribution and describe the shape of their distribution. Table 2. 5.4 Execute the SVM algorithm considering the one-to-one method (see Section 3), that is, separate the observations into training and testing data sets, and select the best model based on the indicators defined in (11). 5.5 Apply the SVM algorithm considering the one-to-rest method (see Section 3) and build a dynamic model based on the available data.

Construct Figures 5-7.
6: End the algorithm reporting the results of the updated data analysis in the graphical user interface of the software.

Methodology
SVM with binary classification is a powerful learning algorithm that aims to differentiate between two classes by finding an optimal hyperplane that maximizes the separation between the two-dimensional space points [23].
An algorithm that maximizes the margin between the training patterns and the decision boundary is a helpful tool that can be applied to a wide variety of classifiers. In this tool, the number of parameters must be fit automatically to match the complexity of the problem, with the solution being formulated as a linear combination of support patterns, which are a subset of training patterns that are closest to the decision boundary.
Next, we provide a background of the method used in the present investigation. For detailed mathematical derivations of the results presented in this section, we refer the readers to [34].
For m-dimensional space points, with 2 < m ∈ Z, we cannot utilize the binary SVM to obtain the separation hyperplane (decision surface) directly. To overcome this issue, the multi-classification problem breaks down into multiple binary classification problems. Then, the binary SVM algorithm is applied to these binary classes. This may be done in a one-to-one or one-to-rest manner explained as follows: • One-to-one method: Here, we break down the m classes into m(m − 1)/2 mutual binary classes, where a binary SVM is employed to differentiate between every two binary classes. Each binary SVM finds a hyperplane that separates between every two classes, neglecting the data points of the other classes. • One-to-rest method: Here, the classifier can use m binary SVMs by obtaining an optimal hyperplane that separates between a class and all others at once. For example, consider m = 3, say, with classes 1, 2, and 3. In this case, we have three different SVMs applied to the binary classes {1, not 1}, {2, not 2}, and {3, not 3}. The data points classification depends on the type of the kernel function to be employed, which aims to reduce the computational time and effort by transforming a nonlinear decision surface to a linear equation in a higher number of dimension spaces. For any two vectors u and v, the most popular kernels, utilized with SVM algorithms, are linear, polynomial, radial basis, and sigmoid functions defined as:

•
Linear function: where K is the kernel function and denotes the transpose of a vector. • Polynomial function: where γ > 0 and d > 0 are the parameters of scale and degree, respectively. • Radial basis function: where γ > 0 is the inverse influence radius of points selected as support vectors. • Sigmoid function: where γ > 0 is a tuning meta-parameter that defines how far the influence of a training point can reach.
Let (x 1 , y 1 ), . . . , (x n , y n ) be the training data set, where each pair belongs to one of two classes that we name A or B, according to Each x k , with k = 1, . . . , n, is a p-dimensional vector of real numbers. From the training data set, the maximum margin hyperplane algorithm is used to estimate the parameters of the decision function D(x). Hence, the classification of unknown patterns is predicted based on the following criteria: is a predefined function, which separates the hyperplane in n-dimensional spaces, whereas w = (w 1 , . . . , w n ) and b are vectors of weights and noise coefficients, respectively, with both w and b being adjustable parameters computed along with minimizing the empirical risk. The distance between the pattern x and the separated hyperplane is D(x)/||w|| (see Figure 1). Note that the axes in this figure (left) are labeled as x 1 and x 2 . Nonetheless, the figure on the right-hand side is the same as that on the left-hand side but as an image (photography).
The maximum margin hyperplane algorithm aims to find the vector w that maximizes the margin M between the training set and class boundary, which is formulated as where the bound M for supporting patterns attains to satisfy the condition M = min k y k D(x k ). The decision function, D(x) namely, with maximum margin M , is shown in Figure 1. Therefore, the hyperplane with maximum margin can be obtained by solving the minimax problem established as max w,||w||=1 min k,b y k D(x k ). Usually, the product of the norm of w and the margin M is scaled to be fixed, that is, M||w|| = 1, to avoid the problem of getting an infinite number of possible solutions. Therefore, maximizing M as in (5) is equivalent to minimizing ||w||. Thus, finding the hyperplane with maximum margin (M = 1/||w ||) reduces to solve the quadratic form given by subject to y k D(x k ) ≥ 1, k = 1, . . . , p. Often, we may tolerate some cost errors ξ ≥ 0 by allowing for some observations to violate the margin. The cost C is defined by the number of observations beyond the margin. In this case, instead of minimizing the form stated in (6), we need to minimize min w,b subject to y k D( where ξ k ≥ 0 and ∑ p k=1 ξ k ≤ C. However, although the problem stated in (7) can be solved by numerical methods in direct space, these methods are impractical for high dimensionality of the dual space ϕ. In this dual space, the decision function is defined as where 0 ≤ α k ≤ c are adjustable parameters computed along with minimizing the empirical risk, C is the cost given by the number of observations outside the margin, and K is a predefined kernel function. The values of the kernel function stated in (8) may be calculated by the inner product of ϕ( where the operator • denotes the inner product of two vectors. We aforementioned the most popular kernels in the expressions defined in (1) to (4). The problem stated in (7) can be transformed into a dual space using a Lagrangian algorithm [31] by means of the representation formulated as under the condition that the Lagrangian multipliers α k ≥ 1, for k = 1, . . . , p [35]. Note that the tolerance errors are again introduced, defining ξ as the value outside the error margins and ξ to limit the value to the dependent variable. Thus, the Lagrangian dual of the problem stated in (9) may be solved by minimizing the expression given by under the conditions (w

Empirical Analysis with Real-World Data
To conduct our study with real-world data, we employ the SVC algorithm proposed in [23]. We use the R software with the e1071 [36] and ggplot2 [37] packages to carry out the data analysis [38]. As mentioned, we perform our analysis using three type of data: (i) daily confirmed COVID-19 infections and deaths; (ii) daily gold price -in US dollars-; and (iii) daily closing price of major cryptocurrencies-in US dollar-.

•
Daily confirmed COVID-19 infections and deaths: First, we collect the daily confirmed COVID-19 infections and deaths from the online repository https://github.com/CSSEGISandData/COVID-19 (accessed on 29 August 2021). This web-hosting has been operated by the Johns Hopkins University Center for Systems Science and Engineering from 23 January 2020 until the present, and it is updated twice daily. We consider the period from 23 January 2020 to 14 July 2021. This period essentially accounts for all available data officially published [39] up to the date where we started this research. • Daily gold price in US dollars: Second, to compare the impact of the pre-COVID-19 period with the COVID-19 period on the classification of cryptocurrency returns according to the quantile values of the gold price (in US dollars), we collected the gold price data from the website https://www.gold.org/goldhub/data/gold-prices (accessed on 29 August 2021) over the period 04 December 2018 to 14 July 2021. In this article, the word return is used synonymously with log returns. The four graphs in the upper and middle of Figure 2 present the distribution and trend of the daily infections and deaths due to COVID-19. The graphs show that, for more than 100 days, the number of daily deaths ranged from 5000 to 7500 cases. The plots in Figure 2 show that the daily confirmed COVID-19 infections and deaths and the daily gold prices followed a similar trend during the period of the ongoing COVID-19 pandemic. The gold prices report high volatility clustering in the pandemic compared with the pre-COVID-19 period. For the entire period of study, the probability density function of the gold prices is slightly skewed to the left with a high excess kurtosis.
Remark. Note that the shaded region in Figures 2-4 describes the period after the beginning of the pandemic for better visualization of the impact of COVID-19 on the gold price/cryptocurrency return. Also, in these figures and in Figures 5-7, the vertical dotted line represents the threshold between the pre-COVID-19 period and ongoing COVID-19 period. • Daily closing price of major cryptocurrencies in US dollars: Third, we collect the daily closing price and market capitalization for some major cryptocurrencies available from the online source https://coinmarketcap.com (accessed on 29 August 2021). For the current research, as mentioned, we study the six cryptocurrency assets, that is, ADA, BNB, BTC, DOGE, ETH, and XRP, selected from the top 10 ranked currencies. Table 1 provides the main characteristics of the top-ranked cryptocurrencies and Figure 3 presents the market capitalization of used currencies over the study period. Again, the vertical dotted lines represent the threshold between the two periods of time (before and during the pandemic). The trends show an exponential increase in the market capitalization of BTC and ETH and less increase in the other currencies during the period of the outbreak of the pandemic.  Almost all currencies followed a similar trend during the period of study. The graphical plots also indicate that the market capitalization substantially plummeted, from mid-May 2021 until the end of the study period, when Tesla (https://www.bbc.com/news/ business-57096305, accessed on 29 August 2021) announced that it would not accept or sell the cryptocurrencies due to pollution concerns. Such bad news often impacts the cryptocurrency prices leading to a substantial increase in the volatility of the returns. Thus, the traditional time-series models might not provide accurate cryptocurrency returns forecasting results, especially during adverse market conditions. Then, the SVM model might be a good option to achieve forecasting accuracy as we will show next.
We split the gold price into four classes according to their quartiles and labeled the values as Q 1 , Q 2 , Q 3 , and Q 4 . Note that, although our approach can work for all quantiles (from 0 to 100), we consider only four quartiles for simplicity's sake. Readers may use the supplementary source code for any subset of gold-price quantiles. We combine the quartiles of the gold prices one day in advance with the daily log-returns of the employed currencies and the COVID-19 cases and deaths. The resulting date corresponds to a time series comprised of 682 observations from 04 December 2018 to 22 January 2020 (before COVID-19 with 297 observations) and from 23 January 2020 to 14 July 2021 (during COVID-19 with 385 observations). Figures 4a,b illustrate the daily returns, distribution, box-plot, and prices of the studied currencies. The box-plots illustrate that the cryptocurrency returns have many outliers in both periods and the volatility of the returns during the COVID-19 period is considerably higher than in the pre-COVID-19 pandemic period.  Table 2 summarizes the statistics of the daily gold prices and returns of the studied currencies. The averages of the gold price and all cryptocurrencies returns have substantially increased over time, especially during the ongoing COVID-19 pandemic. The p-values based on the JB test strongly reject the hypothesis that the returns are normally distributed, which is coherent with the graphical analysis. During the entire period of the study, gold and currencies have a significant excess kurtosis with negative skewness (except the probability density function of the DOGE returns which has a positive skewness), as noted in Figures 2-4.
To examine for a bi-directional causal relationship between the daily number of newly infected cases (deaths) of COVID-19 and the daily gold price (cryptocurrencies returns), we apply the Granger causality test at a lag equal to three. The results are reported in Table 3, which reports that no Granger causality exists. In contrast, we find a significant casualty between the quartiles of the gold price and almost all of the cryptocurrencies returns the next day. According to the findings, contrary to the BNB and DOGE, the returns of the ADA, BTC, and ETH can affect the quartile value of the gold price, but the opposite is not true. In addition, we do not find enough evidence for a causal relationship between the XRP returns and the quartiles of the gold prices.    The results in Table 2 and Figures 2-4 also show a significant increase in the volatility of the returns of gold and currencies after the outbreak of the COVID-19, compared with the pre-pandemic period. Note that, in these figures, as mentioned, the vertical dotted line represents a threshold between the pre-COVID-19 period and during the pandemic. In addition, the circled points are the support vectors, and misclassification appears when the color of the support vectors does not match the color of the decision boundary. Thus, the traditional econometric and time-series models might not provide helpful results in such cases. Hence, due to its superior forecasting performance, we implement the SVM in our analysis.
The SVM optimization strategy is usually done in two stages. First, we separate the observations into training and testing data sets. A rule of thumb indicates to consider the first 75% contiguous days as a training set to fit the model and the remaining 25% days as a testing set, which is used to validate the prediction accuracy of this model [40]. The best model is selected based on minimizing the mean absolute percentage error (MAPE), root mean square error (RMSE), or normalized root mean square error (NRMSE) defined as where N is the total number of observations,ŷ i is the predictive value of y i , for i = 1, . . . , N, and y i −ŷ i denotes the prediction error in y i . Second, we utilize the SVM optimization strategy as a dynamic model that involves all available data. In [41], it is showed that the dynamic model can achieve more accurate forecasting results compared with the one based on a fixed training set. Therefore, in this article, we adopt the dynamic SVM algorithm.
The optimized estimation of the coefficient c stated in (10) and the parameters γ, d defined in (2) and (3), respectively, may be obtained based on the k-fold cross validation method, where the index expressed in (11) has the mimimum value. In this article, we consider a 10-fold cross validation and a set of tuning parameters c ∈ {0.001, 0.01, 1, 2, 2, 4, 8, 16, 32, 64, 128, 256}, d ∈ {1, 2, 3}, and γ ∈ {0.3, 0.4, 0.5}. The estimated parameters of the linear, polynomial, and radial kernel models for the entire sample are shown in Table 4. Applying the optimized parameters in Table 4, the SVM models with each kernel are run on a daily series and the forecasting performance accuracy (in %) for each currency is calculated. The results are indicative of the SVM's superior predictive power when using a radial kernel (between 89.4% and 91.8% performance accuracy) compared with linear (between 71.8% and 74.5% performance accuracy) and polynomial (between 74.8% and 79.3% performance accuracy) kernels.
To illustrate the SVM classification prediction capabilities, using the radial classifier, during both periods, pre-and during the COVID-19 outbreak, Figures 5-7 show the decision rules for a different set of patterns in the hyperplane. The four classes of gold price quartiles are represented by dotted points with four different colors. In the figures, we indicate the support vectors (patterns) with dotted points and double circles, and the errors (misclassifications) with dotted points and double circles but in different colors. Figures 5-7 display that the majority of the errors occurred during the COVID-19 period compared with the pre-period of COVID-19, where some of the cryptocurrencies returns from Q 3 class of the gold price are misclassified as Q 4 . This is justifiable as the uncertainty about the COVID-19 has resulted in significant effects that continue to drive perceptions of risk and volatility in cryptocurrencies and gold prices.

Conclusions
In this study, we have applied the support vector machine model to daily returns of six major cryptocurrencies: Binance Coin, Bitcoin, Cardano, Dogecoin, Ethereum, and Ripple, before and during the COVID-19 pandemic. The daily returns and volatility spillover substantially increased during the period of the pandemic, due to the high fluctuation in prices in comparison with the pre-pandemic period, making accurate forecasting a complex duty. Instead of using a traditional time series model to predict the return of the cryptocurrencies, we have proposed a new easy approach based on an advanced machine learning algorithm to achieve accurate forecasting results for the classification of the returns.
We have designed an algorithm that allows us to use sensors when submitting requests for data of cryptocurrency returns, gold prices, and COVID-19. After collecting the price series of the gold and a cryptocurrency, one can classify the returns of the cryptocurrency in the previous day based on the quartile of the gold price the next day. Also, we may employ the proposed model to predict the classification of the return, whether it will be in the first, second, third or fourth quartile of the gold price.
We have shown that the SVM model can provide significant accurate forecasting, especially during crises. Overall, our model is not only valuable for predicting the classification of the returns of the aforementioned cryptocurrencies, but it is also helpful to be used for other cryptocurrencies.
Our findings support the claim that the SVM technique provides a robust algorithm for the predictability of cryptocurrencies under bad or good news. We believe that the findings of this research are not only helpful for exploring the relationship between the classification returns of the cryptocurrencies and the quantiles of the gold price, but they are also of great interest to macroeconomic policymakers, portfolio managers, and investors who are actively trading in the cryptocurrency market, especially under adverse market conditions and during times of uncertainty. In summary, our new approach can help to devise trading strategies for cryptocurrencies and help investors and macroeconomic policymakers making better investment decisions.
This article provides avenues for further research in digital currency portfolios by comparing our model with other existing evolutionary machine learning algorithms to achieve more accurate results.