1 Introduction

A financial trading system that operates on public market exchanges comprises a structured set of protocols and analytical tools designed to optimize the decision making abilities of the trading agent in search of maximum investment returns. These protocols and tools are instantiated within trading algorithms, which process data associated with one or more financial assets to detect and exploit opportunities for profit generation. Multiple data streams are used to support the decision-making process. An example of such methodologies in financial applications is Standard & Poor’s Neural Fair Value 25. This portfolio employs an artificial neural network to perform weekly selections of 25 stocks from a candidate pool of 3000, aiming to surpass market performance by obtaining the weekly fair value of each stock through fundamental analysis. The deployment of forecasting models, such as Neural Networks (NN), in securities trading has been subject to extensive scientific scrutiny, with evidence suggesting considerable efficacy (Kumbure et al. 2022). However, the assimilation of these techniques into operational trading environments remains frequently proprietary, limiting public disclosure of implementation details (Gerlein et al. 2016). As a result, substantial scope persists for advancing the investigation of automated trading systems through the application of modern machine learning (ML) paradigms.

In recent years, cryptocurrencies have entered the maturity stage, becoming widely accessible as investment opportunities to the general public through Exchange Traded Funds (ETFs) that incorporate them (Olabanji et al. 2024). Furthermore, several countries (e.g. El Salvador, Central African Republic) have granted legal tender status to certain major cryptocurrencies (see Alvarez et al. 2023). It should be noted that, in this highly dynamic environment, profit opportunities are proliferating. As a consequence, numerous hedge funds and investors are now incorporating cryptocurrencies into their financial portfolios, significantly impacting the overall market and generating substantial interest in trading algorithms for these digital assets. According to Fang et al. (2022), research on cryptocurrency trading has seen a dramatic increase in recent years. The authors highlight that an impressive 85% of all published scientific papers have been produced on algorithmic trading of cryptocurrency-related assets in the last five years. This indicates that the field of cryptocurrency trading research is rapidly advancing, with a growing interest in the development of innovative strategies and methodologies for trading.

In this research, we investigate the feasibility of extracting generic price patterns, not tied to specific assets, and to assess their performance using off-label data derived from Bitcoin and Ethereum across an extended temporal span. Specifically, we propose a robust trading strategy that, following the training of a neural network (NN) on an expansive corpus of historical market data encompassing hundreds of cryptocurrency assets, could autonomously execute trades in the market to yield positive financial returns. Our methodology differs from existing approaches by using a single and comprehensive dataset comprising hundreds of cryptocurrencies. As demonstrated in subsequent analyses, this approach is markedly more effective than alternative strategies that rely on historical data from a limited subset of one or a few assets at a time.

Although strategies developed for conventional financial markets may be adapted for application within the cryptocurrency domain, the latter exhibits distinctive attributes that require novel investigative efforts from the scientific community. Conventional trading methodologies lay their foundations on fundamental and technical analysis. The fundamental approach aims to determine whether the current trading value of an asset aligns with its fair market value, employing financial metrics and comprehensive evaluations of business-related data specific to the asset. In contrast, technical analysis examines time series of price and volume data to forecast the future value of an asset, based on the premise that future market prices are indeed predictable.

In the Efficient Market Hypothesis, as stated by Malkiel (2003), market agents exhibit rational behavior, and novel information is promptly incorporated into asset prices. In contrast, the adaptive market hypothesis (Chu et al. 2019) states that investors can display irrational responses to market volatility, thus generating opportunities for advantageous asset acquisition. Such phenomena may be attributed to human behavioral tendencies, including loss aversion, overconfidence, and overreaction, which, under specific conditions, amplify market volatility. The inefficiency of prominent cryptocurrencies is examined by Zhang et al. (2018), with findings asserting that “results indicate that all these cryptocurrencies are inefficient markets”. This characterization positions the cryptocurrency market as an advantageous domain for the deployment of technical analysis through the use of automated agents.

An additional distinctive feature of this context lies in the operational structure of digital exchanges, particularly cryptocurrency exchanges, which impose lower transaction costs compared to conventional brokerage entities. This disparity can have a substantial impact within the high-volume, high-frequency trading environment characteristic of this market. Currently, transaction fees on cryptocurrency exchanges can be as minimal as 0.1% per trade. Furthermore, most of these exchanges offer a complimentary trading API, thereby diminishing the impediments to starting algorithmic trading endeavors.

1.1 Our contribution

We built a large data set of more than 400 cryptocurrencies, developed a complete classification pipeline based on neural network, then we used them to simulate a trading simulation on two major cryptocurrencies: Bitcoin and Ethereum. We search for generic patterns by splitting the dataset in a way that ensures this, see Sect. 4 for details. Finally, we look at the importance of features during the classification process.

2 Related works

Research on trading systems requires consistent effort in feature extraction and time series modeling. It starts from raw market data composed of prices and volume over time. In the specific field of cryptocurrencies, many research works try to correlate different social phenomena with prices.

In Sattarov et al. (2020), Valencia et al. (2019), and Kraaijeveld and De Smedt (2020) the main source of information for the price direction is collected by analyzing the tweeter data feeds. The authors used sentiment analysis based on various models (Multi layer Perceptron, Support Vector Machines, Random Forests) to forecast the price direction. Kim et al. (2016) similar techniques, but uses text messages taken from Web forums. The authors used a model based on Averaged One-Dependence Estimators (AODE)

One peculiarity of cryptocurrencies is that they are based on the concept of blockchain, a distributed data structure where all transactions are stored. Some researchers investigated whether information taken from blockchains could spot useful information for price forecasting. Guo et al. (2021) took data from blockchains and Google Trends to forecast the price of Bitcoin. The researchers obtained the features by modeling the size of transactions over time by wavelet decomposition than using them to train a Multi-Head Attention Temporal Convolutional Network. Another study that collects data from blockchains is Li and Du (2023), using the graph structure of the transactions emerging from the Bitcoin blockchain to search for graph patterns. Then, uses different ML models to map patterns on price changes. Saad et al. (2020) found that the price of crude oil (CO) has a negative correlation with the price of Ethereum, due to the increasing energy cost, and found a positive correlation with some specific user activities on the blockchain, leading to the predictive power of CO price and blockchain user activities.

Classical methods for trading public securities also apply for cryptocurrencies.

There are strategies taken form well established tools in public market analysis: correlating price change with macroeconomic and financial indicators. Walther et al. (2019) search correlation between financial indexes and the volatility of top-5 cryptos for market capitalization. He models the volatility by GARCH-MIDAS methodology Engle et al. (2013). Parvini et al. (2022) forecasts daily Bitcoin prices leveraging data from commodities and financial indexes. They preprocess data by wavelet decomposition and modeling them by the long-short-term memory network.

Some academic papers leverage the information contained within the order book. The order book comprises limit orders on both the buy and sell sides, as recorded by market participants. Orders submitted by market players are frequently utilized as an informational resource to forecast asset prices in the short-term future. For instance, the study referenced as Tsantekidis et al. (2017) employs Convolutional Neural Networks, while Kercheval and Zhang (2015) utilizes Support Vector Machine models for this purpose. Likewise, Guo et al. (2018) integrates the order book with the price and volume information to derive features and enhance the price predictions.

Another source of information proven to have some sort of prediction power is time-based, Baur et al. (2019) and Kaiser (2019) observed the so-called seasonality effect on cryptocurrencies. This search correlation from price and month of the year and day of the week.

In fact, tools and methods of technical analysis have proven to work well on blockchain based assets. Many researchers rely on time series of prices and volumes associated with crypto assets. They extract features using well-known technical analysis tools. Lahmiri and Bekiros (2019) forecasts the open price for the next day by modeling the prices of the top 3 cryptos by market cap. He uses an LSTM network for price regression. Alonso-Monsalve et al. (2020), similarly, uses different neural networks to forecast the direction of the trend in a time frame of one minute. Findings show that hybrid LSTM with a convolutional preprocessing layer yields the best results.

One open problem in the field of the financial assets price forecast is the labeling scheme and cryptocurrencies do not make exception. This problem lead to 2 main variation: prediction of the direction (classification) and prediction of the price (regression).

The latter fall into two main schemes since 2 or 3 labels are used for direction encoding: Buy/Sell or Buy/Hold/Sell. Our choice falls into a three-labels classification (as Kraaijeveld and De Smedt (2020) and Tsantekidis et al. (2017)) because it best fit normal traders operation.

3 The dataset

In this section we describe the dataset used to build our trading system. It is gathered from one of the most popular cryptocurrency exchange: Binance. It comprises time series of prices and volume. After that, we show how the features were extracted by computing candlestick patterns, financial indicators, moving average crossovers and temporal data. Finally, we describe the labeling algorithm that we developed to label each observation and how we parametrized it to maximize the accuracy of classification and the final profitability of the trading system.

3.1 Data collection

Data were downloaded from Binance, it exposes an APIs endpoint where we can connect to download data of the listed crypto pairs. Data were collected in the very common format that encodes prices and volumes of a given time frame. In Table 1 4 samples of the BTCUSDT pair are given, each sample corresponds to 4 h of price change:

  • Date: the start of the time frame.

  • Open: the price at the opening of the time frame.

  • High: the highest price during the time frame.

  • Low: the lowest price during the time frame.

  • Close: the price at the end of the time frame.

  • Volume: the amount of currency exchanged during the time frame.

  • Asset: the currency pair which the sample refer.

Table 1 Sample of data format: 4 time frames for Bitcoin-US Dollar Tether pair

Later we refer to this data format as OHLC + V (High, Open, Low, Close + Volume) format. We collected data in a single dataset for 402 different crypto assets for a period spanning from August 17, 2017 to December 4, 2022. Bitcoin and Ethereum forward testing data was collected until April 2024. As not all assets, composing the dataset, were available at the beginning, they are included as soon as the exchange made them available. All cryptocurrencies are those paired with the stable coin United States Dollar Tether (USDT). With preprocessing, discussed later, we built a dataset of 1.5 million samples with the distribution shown in Fig. 1. Let us note that data, whose distribution is charted in Fig. 1 only encompasses training/test set data made of 400 cryptocurrencies. Validation data (see Fig. 4) are only made by two most capitalized cryptos (Bitcoin and Ethereum) and are not reported on this chart.

Fig. 1
Fig. 1
Full size image

Training/test samples distribution over 5 years time span

3.2 Feature extraction

Feature extraction is a relevant step in preprocessing data, his main objective is to transform data into a format viable to be used to train machine learning models. Feature extraction makes the information to be learned more accessible, so this is a fundamental phase of our research. We borrowed, to extract features, tools and methods from Technical Analisys (TA), it is a well established discipline to spot market opportunity of gain. TA uses past prices to compute quantitative and qualitative (e.g. candlestick patterns) indicators that give information about potential future price direction. Many of those of TA indicators are computed by using past prices and volume data, often, the first step is to compute different moving averages (e.g. see MACD, CCI, ADX, Alligator) The main idea behind our feature extraction process, is to use simple indicators and moving average and let the NN discover how to map those indicators to the price direction. We completed the feature set with temporal information (see 2 and standard candlestick patterns found in TA books (Pring 1991; Murphy 1999). In detail, we built a set of 36 features, whose majority are candlestick patterns, (note that one of our objectives is to assess importance of candlestick patterns in predicting the price direction, see 7) the rest is composed of moving averages, TA indicators not related to moving averages and temporal information. Here follows a brief description of the three main sets composing the features.

Candlestick patterns. Candlestick patterns are graphical patterns that often emerge from charts and are associated to distinct price behaviors (trend continuation or inversion) and are seen on every time frame. They are made up of 1–3 candlesticks. Our research used 23 of the ones mentioned in Pring (1991) for both the bullish and bearish case. As a reference some of the used patterns are: all of the Doji (standard, gravestone, dragonfly), Engulfing pattern, Hammer, Morning star, ...

Technical indicators we use are known as oscillator, they assumes values into a specific interval (e.g. 0–100) and can be used as-is to extract features from prices-volumes timeseries. We use 6 of the most common and are as follows: Bollinger bands, ULTOSC, RSI, Close price percentage variation, Z-Score and volume Z-Score. Other TA indicators that we used are computed by moving average crossovers. They used two moving averages of different lengths to compute ratio or difference and provide useful information on the past trend direction.

In detail, the six TA indicators are as follows:

  • Bollinger bands are commonly used to check if price is too far from the past average. They are computed by adding (upper band) and subtracting (lower band) 2 standard deviation from the average of the past 14 close prices. The current price is likely to be overextended (overbought or oversold) if it is above the upper band or below the lower band.

  • RSI. The Relative Strength Index is a momentum indicator that measures oversold or overbought conditions. It assumes values in the range of 0–100. Values over 70 or under 30 are, respectively, overbought or oversold condition, then a direction change is more likely.

  • ULTOSC. The Ultimate Oscillator uses the values of three different moving averages with multiple time periods (or cycles) to identify overbought and oversold conditions in the market, thus improving the accuracy of the signals generated by the indicator.

  • Close price percentage change. It measure the magnitude of change from the actual price and previous close price. It assumes values from 0 to infinity (unlimited upper bound)

  • Z-Score. This gives to the model another measure of how actual price is overextend in one direction or another; we computed the standard deviation of the 30 past close prices and then computed the Z-score of the current close price.

  • Volume Z-score: To allow comparing volumes of different assets, we used Z-score normalization.

  • EMA crossovers. The Exponential Moving Average crossovers are well established method to analyze price action, it helps to spot trend continuation and inversion. We used 4 EMA crossovers computed starting from 1, 20, 50, 100 exponential moving averages.

Temporal information, in the related works Sect. 2, emerged that temporal information constitutes an edge to spot price direction of the publicly traded assets. Then we added other features extracted from the time information in the dataset. More in detail, we used the time-stamp of each sample to extract the number of samples in the day, the day of the week and the month of the year. Them makes the model detect how time influences the market.

In summary, feature vectors is composed of 36 entries: 23 candlestick patterns, 6 financial indicators, 4 EMA crossovers and 3 temporal features.

3.3 Labeling algorithm

The research objective is to predict near-future (one to five time frames), direction of a crypto, that is, we have to label data samples. As stated in Sect. 2, labeling financial time series is an open problem. Most of the scientific literature falls into one of these three categories: price regression, buy/sell classes and buy/hold/sell classes. The first two do not require parameterization while the third poses challenges in defining parameters and grid searching them for optimal results. Using three classes, in our opinion, reflects the real word operation by a professional trader. We chose to structure the problem into a three-label one, analogously to Kraaijeveld and De Smedt (2020) and Tsantekidis et al. (2017). This choice leads to a better characterization of the real traders’operativity and helps to put out weak signal by limiting buy and sell to strong market movements. Considering also the Hold label, helps to avoid confusion that may arise when deciding whether to refrain from opening a Buy position initially.

We now define the concepts of temporal windows (TW) and the return for a trade.

Definition 1

Given a time frame at time t and a cryptocurrency c, a Forward Window of size k, \(\mathcal{F}\mathcal{W}_{t,c}(k)\), is the sequence of time frames \(t,t+1, \ldots , t+k-1\) and a Backward Window of size k, \(\mathcal{B}\mathcal{W}_{t,c}(k)\), is the sequence of time frames \(t-k+1,t-k+2, \ldots , t\).

In the following, we drop the subscripts t and c when it is clear from the context. Opening a position in the market at the open price of the time frame at time t, \(Open_t\), and closing the position at the close price of the time frame \(t+k\), \(Close_{t+k}\), yields a revenue or a loss, formally defined as follows.

Definition 2

The return of the trade of a cryptocurrency c, opened at time t and closed at the time frame \(t+k\), is given by:

$$ \mathcal{R}_{t,c}(k) = \frac{(1 - f)\cdot Close_{t+k} - (1 + f) \cdot Open_{t} }{Open_{t}} $$

where f is the fee, give as the percentage applied by exchange for each trade.

The labeling algorithm, outlined in Algorithm 1, has two parameters, \(\alpha \) and \(\beta \), which are the thresholds of the return values \(\mathcal{R}(k)\), where k is the size of the Forward window. The former is used to establish a low value below which it is not convenient to place a trade and the latter is a high value above which we consider a price variation outside the technical framework that leads to high-risk trade due to volatility. In these extremes we do not start new trades. In summary, to trigger a Buy, Sell or Hold signal, given \(Open_t\) we try to predict the direction of the price at the end of the Forward window \(Close_{t+k}\). Figure 2 shows how the labeling algorithm assigns labels to data samples w.r.t. \(\alpha \) and \(\beta \) parameters.

Fig. 2
Fig. 2
Full size image

Label boundary based on the \(\alpha \) and \(\beta \) parameters

The Algorithm 1 starts has five input parameters: the array of closing prices closePs, the Backward and Forward window sizes (BWin and FWin respectively), and the two thresholds \(\alpha \) and \(\beta \).

Algorithm 1
Algorithm 1
Full size image

Labeling algorithm

Figure 3 shows a price chart. The rectangles are the Forward and Backward windows w.r.t. the price bar pointed by the arrow. The Backward window and the Forward have, respectively, size of 5 and 2 samples. The 5EMA of the close prices computed in the Backward window is the reference price we use to compute the price direction in the Forward window, it is shown as a dotted line.

Fig. 3
Fig. 3
Full size image

A price chart with backward and forward windows of sizes 5 and 2, respectively, with a positive price variation

4 Models and methods

To address the classification problem of the price direction exposed in the previous sections, we built a multilayer perceptron. It is composed of the input layer of 128 neurons, two hidden, fully connected layers of, respectively, 64 and 32 neurons, and an output layer (softmax) of three nodes that ensures calibrated output. The activation function was the LeakyReLU. As described in Sect. 3, the dataset was composed of 403 prices and volumes timeseries at a sampling rate of 1 sample/4 h. We split the dataset in three non-intersecting sets as shown in Fig. 4. The training/testing set: it was composed of all coins except Bitcoin and Ethereum ending on the 22 of December 2022. It was used in the model building for training and testing in the percentage of 70% and 30%. The backtesting set (see Sect. 6: it was composed of the prices and volumes data for Bitcoin and Ethereum ending on the 22 of December 2022. It was used for the simulation carried out in Sect. 6. The forward test set (data in the future of those used for the training, testing and validation phase): it was composed of the prices and volumes data for Bitcoin and Ethereum starting at 23 of December 2022 and ending at 11 of November 2024. It was used in Sect. 6 together with the backtesting set to asses how the model performs on data not timely correlated with the training set. This data partition ensures (as requested in the financial world, see Sect. 6) that the model is built, validated and forward tested on completely disjoint data.

Figure 4 shows the data partitions. Bars have different lengths because coins data feed are available when the broker starts to adopt them into their exchange.

Fig. 4
Fig. 4
Full size image

Dataset partitions

After the feature extraction phase, to check for the best combination of labeling parameters, we defined different labels for each feature vector for different values of the Forward and Backward windows using a fixed set of thresholds \(\alpha \) and \(\beta \), determining them by statistical analysis of the price change in each data sample in the dataset.

To compute \(\alpha \) and \(\beta \), we performed a statistical analysis of the close percentage change w.r.t. to the open price for the entire dataset. \(\alpha \) and \(\beta \) are computed as the value of the 85-th and 99.7-th percentiles, their values are set to \(\alpha = 0.038 \text{ and } \beta = 0.24\). The \(\beta \) mark the outlier boundary (e.g. price changes outside a technical framework), see Fig. 2, it is incremented by 10% each time the size of the Forward window is increased. Thus, for windows of size 2, \(\beta =0.24+0.024\), for size 3, \(\beta =0.24+2*0.024\) and so on.

This particular choice of \(\alpha \) produced an unbalanced dataset with the Hold class over represented w.r.t. Buy and Sell ones (\(70\%\) of samples are labeled as Hold) this leads to a classification results. To overcome this, we used a random undersampling of the majority class to balance the dataset, see e.g. Buda et al. (2018).

5 Results

In the previous section we described models and methods adopted to set up models. Here we give some metrics on the performance achieved. In Table 2 we reported average and standard deviation for accuracy, precision and recall computed for 10 different models for each of the best 5 combinations of the Forward and Backward windows. We trained each of the 10 models on a different stratified random split of the dataset (holdout validation) then computed average and standard deviation of the performance metrics.

Table 2 Top 5 BWin and FWin combinations sorted by accuracy

To select the combinations of windows Forward and Backward that yield the maximum return, we trained and tested one model, with a proportion of 70%-30%, for each combination of window sizes ranging from 1 to 5 timeframes. This gives us 25 different models with varying performances. We then ranked the models by accuracy and chose the top 5 and validated them by training and testing 10 different models with 10 different partitions of the dataset. Each partition was computed by a different stratified random sampling of the dataset in the proportion of 70%-30%. In Table 2 we show the average results of each group of 10 models used to validate the best 5 combinations of BWin and FWin (50 fully trained models). The results show very stable results across different partitions of the dataset.

Consider that due to different labeling parameters we observed a variation in the size of the samples. The length of the five combinations are, respectively, from (3–1) to (5–2) combinations: 124k, 138k, 192k, 152k, 202k. Note that metrics for the Hold class are worse than those of Buy and Sell. This behavior can be explained by the fact that the Hold class is an artifact introduced to avoid entering and exiting the market too often due to the fees applied by the exchanges. In this research effort, we define the hold class by statistical analysis of price changes through \(\alpha \) and \(\beta \) parameters, that is, there is no unique definition. In fact, when a sample is labeled or predicted as Hold the trading system does nothing because we are not interested in predicting Holds (see Recall worse than Precision), we are interested in predicting when to enter and exit market, than metrics of the Hold class are not concerning.

6 Validation

In the previous section we evaluated the model in terms of well-known metrics in the field of machine learning. However, in the financial field, the strategy’s profitability is clearly the final evaluation metric of trading algorithms, in line with Olorunnimbe and Viktor (2023). In this section, to evaluate the Return On Investment (ROI) we used the models developed with the methodology seen in the previous sections to simulate a trading session on unseen data. We have chosen 2 top crypto currencies by market capitalization: Bitcoin (BTC) and Ethereum (ETH) (whose data are not included in the training/testing sets). We used models, reported in the Sect. 4 whose Forward and Backward windows are shown in Table 2. During the trading simulation, based on a buy-only strategy, the stop losses were set at 10% and the fee applied by the brokers set at 0.1%, for each market operation. For each backtest 2 models are tested: one with the MLP and one with a random sequence of buy-hold-sell operations (the so-called dummy model). In Table 3 we report some performance indicator for the back/forward test. As mentioned before, currencies used in this validation phase are paired with the stable coin US Dollar Tether (USDT), the period data are gathered, includes the time used to collect the training/test set plus more than one year of completely new data for the currencies used in the validation (see dataset partition chart in Fig. 4). In this way, we validated the trading strategy through a joined backtest and forward tests on more than 6 years of data. Table 3 shows that the most profitable combination of forward and backward windows are the (5, 2) for Bitcoin and (4, 2) for Ethereum (see Fig. 5). The table shows respectively: the asset, the model used (MLP and Dummy), the backward and the forward window sizes, the ROI, the number of buy closed during the period, the number of buy ending in positive profit. We can observe that dummy models always end in a capital loss, that positive ending operations are almost half of the total number of operation closed. This suggests, in our opinion, that stop losses play an important rule in obtaining good performances. To better expose the behavior of the trading simulations for the best two exposed above, we charted, in Fig. 5, the ROI curve over time of both MLP-based strategies and the dummy ones. Note that ROI are in logarithmic scale to better appreciate the behavior of the MLP strategy over the dummy one. We can observe that MLP based strategy behaves well in every market phase. In the bull market, the strategy multiply the original capital, while in the bear and flat markets, the earnings are protected.

Table 3 Trading simulation results
Fig. 5
Fig. 5
Full size image

Back and forward test for Bitcoin and Ethereum on their best backward and forward windows combinations

7 Feature explanation

Here we did a study on features explanation based on test set samples, discussed in the previous sections. The field of interpretability/explainability in ML focuses on understanding how models make predictions by mapping input data to output. It aims to increase transparency in ML models. While some models like linear models and decision trees offer understandable behaviors, MLPs models act as black boxes. Here we infer global model behavior by averaging the behavior on different input samples. To explain our model predictions we used SHAP (SHapley Additive exPlanation) (see Lundberg and Lee 2017), a framework that explains any black box model by inferring the contribution of every feature into the final prediction. In this way SHAP gives an explanation (feature contribution/importance) for each prediction. We averaged the absolute importance of each feature of 10,000 random samples/predictions of the test set to obtain the charts. Here we took the two models used in the simulation done in Sect. 6, the one trained using labeling scheme based on 5-backward and 2-forward (used for Bitcoin) window and the one with 4-backward and 2-forward (used for Ethereum) and use SHAP to investigate the top 10 features importance. In Figs. 6 and 7 we show the importance, in determining the model output, of the top 10 most important features computed on a 10k random sample of the test set. Figures 6a and 7a plots the importance of the top 10 features by computing the mean of SHAP absolute values for each feature. This give an average weight of how much a feature influence predictions. In Figs. 6b and 7b we plotted, for the same subset of 10k feature vectors, the beeswarm plots. Each dot relate feature value (color) and the impact of the feature on a specific prediction (value along the x-axis). In this way we can spot how feature values are correlated to model output. Note that in the implementation, we have encoded the label Buy with \(-1\), Hold with 0 and Sell with 1, thous read the beeswarm plots accordingly. The two models exhibit a similar behavior for what concerns the features importance but different performance on trading simulation (see Sect. 6). This, in our opinion, can be ascribed to the variability of different models trained on different labeling scheme. Bollinger, RSI and EmaCross1_21 emerge as the most important features the models use for making prediction, but not by large extent relatively to others. Note the asymmetry of Bollinger and RSI features around the 0-value on Figs. 6b and 7b. The Bollinger asymmetry is inverted from 6b to 7b, RSI and EmaCross1_21 are inverted in term of importance and RSI has a less clear separation on (4, 2) scheme. EmaCross21_50, despite the different importance, exhibits the same, counter-intuitive, inverse behavior w.r.t the other features, it seems that negative value (falling close prices) triggers Buy signals and positive values (raising close prices) trigger a Sell signal. We don’t have a clear explanation for this behaviors of the models, may be a dynamic of the specific assets or market. Temporal features (DayOfWeek, Month and Hourly) have an important (together weight as the Bollinger) impact, but nothing emerge in the beeswarm plot, seems a non-linear dependence from feature value and model output. It is noteworthy to mention that candlestick patterns are not in the top 10 features (composed only of moving average crossovers, temporal and well known indicators), in fact, by analyzing features beyond the top 10, they exhibit a very low level of effectiveness in predicting prices.

Fig. 6
Fig. 6
Full size image

Top 10 feature importance for 5-backward, 2-forward windows labeling

Fig. 7
Fig. 7
Full size image

Top 10 feature importances for 4-backward, 2-forward windows labeling

7.1 Financial interpretation

Here we give a financial interpretation of the three most important technical indicators emerging in this section. In general, public markets tend to be very efficient in determining the right price of an asset, but some times tend to overreact to news (good or bad), this leads to overbought or oversold conditions that expose chances to make profits. The three most important technical indicators spotted in this section, try to spot when prices are statistically overextended. The Bollinger bands are graphical tools composed of a central line computed as a simple moving average of the last 20 close prices and an upper (lower) band computed as the central line plus (minus) twice the standard deviation. When the price hits the upper or lower band, it is a signal that the price has a higher chance to reverse direction. Another tool for detecting price over-extensions is the RSI indicator, it is a so-called momentum indicator, it is computed as follows:

$$ RS = \frac{\text {Average Gain over } n \text { periods}}{\text {Average Loss over } n \text { periods}} $$
$$ RSI = 100 - \frac{100}{1 + RS} $$

Where:

  • n is the number of periods (typically 14).

  • Average Gain = \(\frac{\sum \text {Gains over } n \text { periods}}{n}\), where gains are positive price changes.

  • Average Loss = \(\frac{\sum \text {Losses over } n \text { periods}}{n}\), where losses are negative price changes (taken as absolute values).

It assumes values in the 0–100 range, values. It helps to identify oversold or overbought conditions (< 30 and > 70 respectively) so that in these overextended price conditions there is a higher chance of inversion. Finally, the last indicator that has emerged as highly important in predicting the price direction is the EMA crossover. It is a trend following indicator, as it signals that the price is trending (high or low) if the price itself is above or below the EMA. It is computed as price/EMA, it is > 1 if the price is above the EMA and < 1 if the price is below the EMA. The financial interpretation is that the farther distance from the EMA, the stronger the trend.

8 Conclusion

Trading automation in blockchain-based assets faces challenges due to poor regulation and market manipulations, leading to high volatility (Gandal et al. 2018; Eigelshoven and Ullrich 2021; Fratrič et al. 2022). Although these fluctuations hint at profitable opportunities, recognizing them in an automatic setup remains a complex task. In this work we clearly see that our trading system performs well on Bitcoin and Ethereum against a dummy model. Note that, at the time of writing, Bitcoin and Ethereum accounts for 60%+ of the total crypto markets capitalization. It is in our opinions that major coins price movements are predictable on a technical framework basis and this is confirmed by our research. Feature importance confirmed that the classical approach based on moving averages crossovers and simple technical indicators worked very well, while candlestick patterns are shown to be ineffective. In Sect. 2 we conclude that social networks have some correlation with price dynamics. Then social networks are one of the most important sources of information (together with others) to merge to get a more complete view of the market sentiment for any particular cryptocurrency. In future works a more complex pipeline should be deployed by merging data from different sources: different social network sentiments, financial news, blockchain analysis, order book information, technical indicators and some pattern matching techniques to incorporate into the data known and unknown technical pattern on different time scale. Candlestick patterns can be removed as we found them completely ineffective in predicting the direction of prices for the cryptocurrencies. Moreover, this approach can be deployed against different assets, like currency pair (forex), stocks, commodities, and their leveraged derivatives, like CFD.