Intraday trading of cryptocurrencies using polynomial auto regression

: This research attempts to fit a polynomial auto regression (PAR) model to intraday price data of four major cryptocurrencies and convert the model into a real-time profitable automated trading system. A PAR model was constructed to fit cryptocurrencies' behavior and to attempt to predict their short-term trends and trade them profitably. We used machine learning (ML) procedures enabling our system to train using minutes' data for six months and perform actual trading and reporting for the next six months. Results have shown that our system has dramatically outperformed the naive buy and hold (B&H) strategy for all four examined cryptocurrencies. Results show that our system's best performances were achieved trading Ethereum and Bitcoin and worse trading Cardano. The highest net profit (NP) for Bitcoin trades was 15.58%, achieved by using 67 minutes bars to form the prediction model, compared to −44.8% for the B&H strategy. Trading Ethereum, the system generated 16.98% NP, compared to −33.6% for the B&H strategy, 61 minutes bars. Moreover, the highest NPs achieved trading Binance Coin (BNB) and Cardano were 9.33% and 4.26%, compared to 0.28% and −41.8% for the B &H strategy, respectively. Furthermore, the system better predicted Ethereum and Cardano uptrends than downtrends while it better predicted Bitcoin and BNB downtrends than uptrends .


Introduction
Intraday trading is very-short-term trading that is based on minutes of position holding, and it is known to require special training and experience. Intraday trading can be performed manually or automatically using a preprogrammed algorithm that detects changes in a financial asset's pricing using artificial intelligence (AI) and machine learning (ML) techniques. Intraday trading challenges increase as the asset's volatility grows and demand algorithms with learning and optimization abilities. Because of the frantic price movement, not many researchers have attempted the challenge to develop and test intraday trading platforms for cryptocurrencies. In this study, we programmed, optimized and tested the ability of polynomial auto regressions (PARs) to successfully predict short-term price trends of cryptocurrencies that result in a profitable trading strategy. The cryptocurrencies that were used are Bitcoin, Ethereum, Binance Coin (BNB) and Cardano.
Artificial neural networks (ANN) are known to be able to provide an abnormal return by using technical indicators as predictors in stock markets (see, for example, Fischer and Krauss [10]). Those methodologies were adopted by researchers to predict cryptocurrency future prices. Jay et al. [18] predicted cryptocurrency prices using a stochastic model that induces layer-wise randomness in the observed feature activations of neural networks (NN). Their results show that the proposed model can better predict cryptocurrencies' future prices than deterministic models. Senthuran and Halgamuge [28] offered cryptocurrency price forecasting methodology using an ML algorithm and blockchain information. They concluded that prediction performance is high for both currencies when the blockchain data is used together with Bitcoin and Ethereum prices. Moreover, they documented that the Ethereum currency has the highest percentage of prediction accuracy and the lowest error rate compared to Bitcoin. NN use learning filters that are generated in each of the network layers to detect a predetermined signal at any given layer and to send real-time information to the system that performs automated trading decisions. Shahariari et al. [27] constructed an ordinal partition network using price signals to investigate cryptocurrencies' fluctuations. They investigated the permutation entropy and clustering coefficient and concluded that the global clustering coefficient using a minimum function for triplets in a loop in one direction has the highest predictive power.
In the current research, we used one year of minute-by minute price data from the beginning of 1.12.2021 till the end of November 2022 to construct our trading platform. The data was split into six months of training and six months of actual trading and results reporting. We used ML procedures based on polynomial autoregression to predict the minute behavior of cryptocurrencies. The estimation of the parameters of the projected polynomial autoregressions is a non-linear least-squares problem. A PAR model for a stochastic process is defined in Eq 1: where follows an independent distribution process with zero mean and finite variance.
The use of PAR models to make predictions is common in the scientific world because of their relative implementation simplicity compared to other non-linear models due to their parameter's linearity characteristics. PAR was used in a variety of academic fields such as communication (see, for example, Fernandes et al. [9], biological control systems (see, for example, Gruber et al. [14]) and energy (see, for example, Hong et al. [16]). Karakuş et al. [19] used the Kuruoğlu [21] model (presented in Eq 2) to predict the wind speed on the current day based on the previous day and concluded that the PAR model outperformed other models in both speed and power of predictions.  where ( ) is an independent and identically distributed sequence, P = the non-linearity degree, k = the Autoregression order. PAR models are also used for financial research. De Luna [6] argued that PAR could successfully be used to forecast time series trends. He used artificial Neural Networks (NN) to avoid an explosion of the parameters when considering a large number of lags. Furthermore, he demonstrated the methodology with real data for three-month US Treasury Bills. He concluded that that the stationarity of PAR is of no concern if they are considered not as models for stochastic process but as approximation of the optimal predictor ( +ℎ ⋮ ,….) defined by the minimum mean-squared error (MSE) of prediction. They offered a family of predictors +ℎ , ℎ > 0, and the model he used is described in Eq 3: In practice, the optimal number of regressors can be decided using machine learning (ML) that searches for the best predictive model during the learning period. Moreover, in time series autoregression analysis, a lag operator is needed to produce forecasts. A polynomial lag operator can be used within an ARMA (Autoregressive Moving Average) of orders p, q (Eq 4).
In lag operator notation, the ARMA process is defined as The characteristic polynomial can be expressed as where are the reciprocal roots. In this research, we constructed an optimized trading platform using ML procedures. We aimed to examine whether the polynomial model can fit minute data of cryptocurrencies, enabling the programmed trading platform to generate profits that outperform the simple Buy and Hold (B&H) strategy. We find that it is possible to intraday trade cryptocurrencies using a polynomial model. Our system has outperformed the B&H strategy for all examined cryptocurrencies.

Literature review
ML has been used before to try to identify cryptocurrencies' price direction. Balcilar et al. [1] discussed the predictability of Bitcoin returns and volatility based on transaction volume. They found that when extreme events are excluded, volume is an important predictor of price. In studying Bitcoin's price dynamics and speculative trading, Blau [2] concluded that speculative behavior could not be directly linked to the unusual volatility of the Bitcoin market. Griffin and Shams [13] examined whether Tether, which is pegged to the U.S. dollar, influenced Bitcoin and other cryptocurrencies' prices during the 2017 boom. They found that Tether purchases follow market downtrends, resulting in an increase in Bitcoin price. In addition, they suggested that there are insufficient Tether reserves before the month ends. Liu and Tsyvinski [23] argued that cryptocurrencies' returns can be predicted by factors that are specific to the cryptocurrency market. They conducted a network factors analysis that captures the production along with the user adoption process of digital currencies and found that there is a strong time-series momentum effect and that proxies that capture investors' attention can forecast the future price trends of cryptocurrencies. Caporale and Plastun [5] examined the day-of-theweek effect in the cryptocurrency market and found that most cryptocurrencies such as Litecoin, Ripple and Dash do not exhibit this anomaly. The only exception is Bitcoin, for which returns on Mondays are significantly higher than those on the other days of the week.
Brandvold et al. [4] investigated the role of various Bitcoin exchanges in the price discovery process, noting that the information shared is dynamic and evolves significantly over time. Feng et al. [8] found evidence of informed trading in the Bitcoin market prior to major events. Moreover, when examining the timing of informed trades, they noticed that informed traders prefer to build their positions two days before large positive events and one day before large negative events. This result serves as proof of the market inefficiency that differentiates uninformed traders from informed traders of Bitcoin.
Some trading algorithms use only market data, and some combine market data with social media data (see, for example, Liu [22], Sohangir et al. [29]). The social media information is extracted mainly from Google and Twitter along with popular investors' idea exchange platforms like Seeking Alpha 1 and Investopedia 2 . Since cryptocurrencies are relatively new, there is little research on the factors or tools that can help people invest in them. The first group of studies linked the price of Bitcoin to social networks. For example, Kim et al. [20] tried to predict fluctuations in the prices of cryptocurrencies by analyzing comments in online cryptocurrency communities. They found that positive user comments significantly affected the price fluctuations of Bitcoin, whereas the prices of two other cryptocurrencies, Ripple (XRP) and Ethereum, were strongly influenced by negative user comments and replies. Garcia and Schweizer [12] also demonstrated the existence of a relationship between returns and signals about the volume of trade, and Twitter valence and polarization. Matta et al. [24] studied the existing relationship between Bitcoin's trading volumes and the number of queries on Google. They reported significant cross-correlation values, demonstrating that the volume of searches could predict the trading volume of Bitcoin. Detzel et al. [7] examined trading strategies based on daily ratios of prices to their moving averages for Bitcoin and found that a trading strategy that is based on this concept beats the naï ve strategy of Buy and Hold (B&H). Unlike Detzel et al. [7] we use intraday data of five major cryptocurrencies. Shorter time frames have a different characteristic than daily data since they are not subjected to overnight new economic data. Moreover, intraday trading strategies should capture changes in the asset's price trends in shorter time frames measured in minutes not days. In addition, in the following research, we documented that the relative strength index (RSI) based trading system has beaten the B&H strategy and can be used by intraday traders both human and robotic. Although the RSI and Moving Average (MA) are both momentum oscillators, they measure different factors. The RSI uses average price gains and losses over a given period to indicate whether a security is overbought or oversold in relation to recent price levels while the MA-based strategy measures the current price against its periodic moving average.
Since financial asset price movements are very complex and affected by many factors, traders and researchers are using Support Vector Machines (SVM) for algorithmic detection of investment opportunities. The method that was developed by Vapnik [30] is a machine learning technique based on statistical learning theory and structural risk minimization that is commonly used for classification (see, for example, Jan [17], Xiao et al. [31]). In addition to SVMs, long-short term memory (LSTM) is also being used for algorithmic trading because it can selectively decide whether historic data is important or not important as basis information for future price forecasting (see, for example, Nelson et al. [25]). Borovkova and Tsiamas [3] ensembled the LSTM model for intraday stock predictions, using a large variety of technical analysis indicators as network inputs. They evaluate the predictive power of their model on several US large-cap stocks and benchmark it against lasso and ridge logistic classifiers. The proposed model is found to perform better than the benchmark models or equally weighted ensembles. Fister et al. [11] looked for a profitable trading strategy for stocks that experience low frequency release of new information. They formed LSTM networks that included trading patterns that are based on universal decision factors and stock specific factors. They documented that their LSTM model significantly outperformed traditional trading strategies. Hansun et al. [15] proposed a three-layer architecture for the regression prediction models. They found that LSTM and the gated recurrent unit (GRU) have the same price prediction accuracy of major cryptocurrencies. However, in terms of execution speed, GRU is slightly better than LSTM. Oyedele et al. [26] assessed the performance of deep learning (DL) models on six cryptocurrencies. Their results show that the convolutional neural networks (CNN) model has the highest explained variance score and lowest percentage error. They concluded that the CNN models are reliable for cryptocurrency daily closing price prediction.

Data and methodologies
Our data consists of twelve months' minutes' prices beginning at 1.12.2021minute-by -minute bars 3 of the four most popular cryptocurrencies. The data was split into two periods: six months of training (December 2021-May 2022) and six months of actual trading and documenting the results (Jun 2022-November 2022). The autoregression model is described in Eq 7. +1 = + 1 ( 1 + 2 − ) + 2 ( 3 + 4 − ) 2 + 3 ( 4 + 5 − ) 3 (7) where n= the number of minutes of lag.
Our trading platform initially estimates and draws a polynomial model estimation line that best fits the data. Then, the system generates long and short signals according to the real-time price relative to the estimated line and enters trades accordingly. A long signal is generated when the price crosses the estimation line to the upside and a short signal is generated when prices cross the line to the downside. The methodology is illustrated in Figure 1.
To minimize false entries to each trade, our system determined and optimized a minimum buffer above and below the prediction line ( ). The entry to a long/short position is defined in Eqs 8 and 9. Long entry rule: Short entry rule: where = the minute closing price, = the polynomial prediction line, = minimum buffer. Our starting point is a $100,000 portfolio value, enabling us to calculate the net profit (NP), profit factor (PF) and percent of profitable trades (PP) of six months of trading. Moreover, we calculate the percentage of returns and compare it to the simple buy and hold (B&H) strategy to examine the ability of our systems to outperform the B&H strategy. Moreover, we separated long from short positions to examine the abilities of the AI to trade profitably long versus short positions. The split between long and short trades was done for each cryptocurrency using the time frame that maximized NP.
NP is the dollar value of the total net profit generated by the trading system. The PF is defined as gross profits divided by gross losses. The result indicates the difference between the system's gains and losses. For example, if the profit factor is equal to 1.2, the system generated 20% more profits than losses. The PP is the percentage number of winning trades out of the entire set of trades generated by the system. If it is above 50 percent, the trading system has generated more winning trades than losing trades. However, this does not mean that the net profit of all trades is positive and vice versa. A score of less than 50 percent does not mean that the trading system is losing money. Although one might assume that the three profit indicators (NP, PF and PP) move together, in fact, they can vary dramatically and therefore may confuse investors and algorithmic traders. Each individual investor should pick at least one parameter as his/her target function according to the investor's risk aversion. For example, a more risk-averse investor will probably choose to maximize PP rather than maximize the NP, while a risk seeker investor will prefer maximizing NP or PF as his/her primary target. The optimization process is presented in Figure 2. Figure 2 demonstrates that setups particles (A, B, C, D) are entered randomly into the system calculating initial NP, PP, and PF, then the system alters each particle at a time to reach the maximation of the target function. If the maximum is achieved, the system halts; otherwise, the setup's particles continue to change. The system is trained to generate long and short signals in a sequence, meaning that it will stay in a certain position (long or short) until an opposite signal appears.

Results
Our trading system used six months of training to identify the best fit polynomial model for the examined cryptocurrencies. Moreover, the system has optimized the percentage deviation from the prediction line that will guide the trade entrance (long or short). In this regard, the optimal 4 was found to be 1.5 % for all four cryptocurrencies. Table 1 summarizes the trading performance according to our system for Bitcoin and Ethereum. Table 1 shows that the highest NP for Bitcoin trades, $15,580 (15.58%), was achieved using 67 minutes bars. This result dramatically outperformed the B&H strategy trading Bitcoin from the beginning of June 2022 till the end of November 2022, which achieved −44.8%. The 67-minutes setup also produced the highest FF (2.3) and PP 71.67%. The best NP, for Ethereum trading, was $16, 980 (16.98%), compared to −33.6% for the B&H strategy, using 61 minutes to form the best prediction line. This setup also achieved the highest PF (2.04) and PP (66.67%). In Table 2, we separate long trades from short trades to be able to identify which price trend is better predicted by our system. Moreover, Table 2 reports the result of the trading using the best setup for each crypto (67 minutes for Bitcoin and 61 minutes for Ethereum). Table 2 demonstrates that for Bitcoin trades, the algorithm has achieved better results for short trades than for long trades. Short trades of Bitcoin have achieved 3.44 PF and 73.33% PP compared to 2.73 PF and 70% PP for long trades. With respect to Ethereum, the system better performed for long trades rather than for short trades, resulting in 10.478% NP compared to 6.5%. Table 3 shows the result of the optimized trading platform for BNB and Cardano trading.      Figure 3 is graphing the dollar value NP for the examined cryptocurrencies with respect to the number of minute configurations of the polynomial model.  Figure 3 demonstrates that our system has achieved the best results trading Ethereum and Bitcoin and was worse trading Cardano. However, as pointed out before, the system has outperformed the B&H strategy for all four cryptocurrencies. Figure 3 also points out that every crypto best-performing model relies on a different number of minutes. Moreover, three out of four currencies experience a signal peak performance while only BNB experiences double peaks at 65-and 75-minute models.
Notes: The number of minutes represents the number of minutes bars that were used to construct the prediction model.

Summary and conclusions
In this research, we attempted to fit a PAR model to minute price data of four major cryptocurrencies. The first intuition that raised this possibility is the visualization of the data that resembled a polynomial process. The challenge was not only to examine if a polynomial autoregression fits the data but to be able to convert it into a real trading algorithmic platform. We used ML procedures, enabling our system to train for six months and perform actual trading and reporting for the next six months. Results have shown that for all four examined cryptocurrencies, our system has dramatically outperformed the naive B&H strategy. Our system performed the best trading Ethereum and Bitcoin and worse trading Cardano. Trading Ethereum, the system generated 16.98% NP, compared to −33.6% for the B&H strategy. Trading Bitcoin, the system generated 15.58% NP, compared to −44.8% for the B&H strategy. Moreover, the system located different best setups for each crypto. Furthermore, the system better performed Ethereum and Cardano long trades than short trades, while it better performed Bitcoin and BNB short trades than long trades.