# Empirical Research for Investment Model Based on VMD-LSTM

Authors: Aihua Gu; Zhengqian Wang; Zuohao Yin; Mingming Zhou; Shujun Li; Qifeng Xun; Jian Dong
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

Investment diversification has become an inevitable trend with the development of the world economy. In this work, we first compare the K-Nearest Neighbor model, the Artificial Neural Network model, the grey prediction model, and the LSTM (Long Short-Term Memory Networks) prediction model for a period of data analysis. The experimental results show that LSTM is superior, and thus LSTM model is selected to forecast the long-term prices in this work. Then, we introduce some indicators, such as convergence divergence ratio and risk coefficient to qualitatively analyze the market price. The five-day moving average method is used to formulate the best trading strategy based on the above-introduced indicators. We apply the commonly used regression indicators (R2 and RMSE) to verify the reliability of the prediction model. Then we introduce new strategies to compare the performance of different ones with them. We found that the five-day moving average method achieved 20% higher returns than the other strategies we used for comparison. Considering the fact that transaction costs may change, we perform the polynomial fitting based on existing strategies by changing the commission cost. The results show that a 1% increase in the gold commission will reduce the total return by 24% to 25%, while a 1% increase in the bitcoin commission will only reduce the total return by 7% to 8%.


---

## Body

## 1. Introduction

With the increasing development of the world economy, market investment has ushered in more diversified choices. Bitcoin and gold, which are the mainstream investments, have played an important role in avoiding the risk of currency depreciation. At the same time, the trading characteristics of these two commodities are obvious, the historical data is detailed, and the trading rules are unified, which is a good research investment sample.However, the uncertainty of the market situation leads to a greater risk of market trading investment, so it is imperative to establish an appropriate forecasting model and determine the appropriate trading strategy. This article attempts to explore the best strategies for market investment by studying the changing trends of these two commodities.In this article, we constructed the Quantitative Trading Decision Model (QTDM) task into two steps: selecting the strategy for the day and building a circular decision model.Among them, according to the reference paper, inflation is an important factor affecting commodity prices. Therefore, this article adds an indicator that reflects inflation and the consumer price index; deep learning Artificial Neural Network (ANN) and machine learning algorithms K-Nearest Neighbor (KNN) are added. The model is then demonstrated by common measurement model error indicators (such as MSE, MAE, RMSE, and RMAE) and economic indicators (such as Sharpe ratio, annualized, and return) [1].Then, we determine the transaction decision result by increasing or decreasing the percentage of transaction cost (0.5%, 1%, 1.5%, and 2%), which proves that the model constructed in this paper has good robustness under different transaction costs.Finally, we divide 2016–2021 into three phases and summarize the corresponding strategies, models, and results for their different characteristics.Of course, there is still room for improvement in this article; for example, there are many factors that affect the price of gold and bitcoin, and at present we can only analyze the relationship between CPI and gold, so the predicted data obtained cannot be completely used as reference data. In addition, we only summarized the characteristics of the different stages from 2016 to 2021 but did not further quantify the characteristics into indicators and integrate them into the model to achieve more complete price predictions.The data for this paper comes from 2022 MCM/ICM Problems C forhttps://www.comap.com/undergraduate/contests/mcm/contests/2022/problems/.


## 2. Review of Literature

In the early 1990s, White used neural networks to predict the daily return on IBM’s stock. But there is a problem with converging to a local minimum in this model [2], and then Gen Cay proved that neural network models were far better than simple moving average statistical algorithms in predicting industrial indicators [3]. Later, G. Peter Zhang found that the neural network model has significant advantages in processing nonlinear data by comparing the ability of the ARIMA model and neural network model in time series prediction [4].Chi Jie Lu believed that the stock price data had high white noise and certain randomness. He preprocessed the data by establishing a complete and independent component analysis method, and established a stock trend prediction model combined with the neural network model [5]. However, researchers such as Hammad and L. Hall paid more attention to the internal study of the neural network model [6]. Then RNN neural network improved the local minimum of the BP neural network by introducing a timing sequence. Meanwhile, there was a problem with the gradient explosion in it [7]. So LSTM is proposed to solve the gradient problem by establishing a framework [8].At the same time, Volkan U¨lke and Afsin Sahin [1] found the impact of inflation on commodities through analysis and compared the application scope of common algorithms in various indicators reflecting inflation (CPI, PCE, etc.) in detail. It provides a new perspective for the quantitative decision model. Cicceri G and Inserra G proposed comparing the data sets obtained by the machine learning model and linear regression model in the forecast and analysis of Italian GDP, which also provided us with directions in using different forecasting methods [9].Professor Wu Taowu pointed out that a quantitative timing trading strategy should be selected for stock investment [10]. Professor Li Qinghan mentioned the periodicity of the stock market in reference [11], and Professor Jiang Xianling concluded that gold price fluctuation was cyclical in reference [12]. Therefore, we use the “five-day mean method,” commonly used in the stock market to invest in the forecast data.We know that the KNN algorithm, Ann algorithm, and LSTM algorithm all have good prediction effects [13]. We observe the inflation index from the perspective of the consumer price index, and we find that neural network has a better forecasting effect than other forecasting methods [14].Jiang Bailin pointed out that neural network (RNN) showed better than other neural networks, but as a result of neural network in the cycle of data operation, which may cause the gradient explosion or gradient diffusion problems [15]. The long short-term memory model recurrent neural network (LSTM) is introduced into the error computer based on a recurrent neural network. It introduces the input gate, forgetting gate, and output gate based on the recurrent neural network, which can effectively deal with the problems of data forgetting and gradient explosion in the recurrent neural network. The use of computer analysis ability to make certain predictions on the stock.Du Xin and Wang Tian et al. proposed in reference that machine learning techniques (such as logistic regression) were used to construct classification models with a set of software metrics and some labeled datasets for prediction and generalized K-kernel decomposition in class-dependence networks for prediction analysis [16].Weifeng Pan and Hua Ming proposed using the PageRank algorithm to visit each node of the document work to find the highest PageRank value and then rank the document work [17].Based on these theories, we introduce the index that best reflects inflation (CPI) and choose the method that best fits it. In addition, we establish a quantitative trading decision model based on LSTM and noise processing methods and compare them to determine the best quantitative decision model.


## 3. Data Preprocessing

Due to the influence of international policies, economic situation, and other factors, the price of bitcoin and gold is usually a nonlinear and unstable random time series, which makes the price data present two characteristics of high noise and nonlinear. Therefore, it is particularly important to preprocess price data.The steps of data preprocessing in our model are shown in Figure1.Figure 1
The steps of data preprocessing.We choose to use VMD (Variational Mode Decomposition) to denoise the data. This method can reduce the instability of time series with high complexity and strong nonlinearity and obtain relatively stationary subseries with multiple different frequency scales.Taking Bitcoin as an example, the denoising results of all data are shown in Figure2.Figure 2
The reduction of data noise.


## 4. Model I: Quantitative Trading Decision Model

We divided the QTDM (Quantitative Trading Decision Model) into three small models as shown in Figure3.Figure 3
The division of QTDM.


### 4.1. The Selection of the Prediction Model

The precious metals and scarcity of gold have been recognized as safe-haven assets since ancient times. When there are major changes or fluctuations in the market, the physical value and exchange rate of gold will remain relatively stable and have a stable investment value. At the same time, Bitcoin as an emerging monetary asset has similar properties to gold.On the supply side, gold mining and Bitcoin mining are decentralized, and their ownership is decentralized. Moreover, unlike traditional currencies, their supply cannot be created by decree or monetary policy. On the demand side, both assets are seen as hedging against inflation and hedging value. We can analyze gold and Bitcoin using the same influencing factors.Through the analysis of data indicators affecting the price of gold, it can be seen that it is an important macroeconomic indicator that reflects the changes in the price level of consumer goods and services related to the lives of residents-CPI is an important indicator of inflation. At the same time, we found that it can also be related to the price of gold. To unify the volume of spot gold, we chose the CPI data of the United States.If the data increase is too large, it means that inflation has become a factor of economic instability, and the state will adopt a tight fiscal policy or monetary policy to check and balance. At this point, the excessive increase in the data is not welcomed by the market, and the central bank must change it by adjusting interest rates. At this time, the hedging effect of gold appears, which has the effect of promoting the rise of spot gold prices. If the data rises moderately, indicating that the economy is good and the currency is appreciating, it is bearish for spot gold.We compared the data for gold, Bitcoin, and the US CPI from 2016 to 2020 and found that the R^2 on polynomial fitting was 0.9679 and 0.8685, respectively, as shown in Figures4 and 5.Figure 4
Chart of CPI and gold price historical trend.Figure 5
Chart of CPI and bitcoin price historical trend.In the reference paper [1], the author argues that KNN and ANN machine learning models may apply to CPI inflation forecasting when forecasting CPI (consumer price index) inflation. In addition, the methods currently widely used in investment forecasting mainly include time series analysis, grey forecast analysis, neural network analysis, and some other classical machine learning methods.Here we mainly use the grey predictive analytics method, KNN, ANN, and LSTM to predict the existing data. K-earest Neighbor (KNN) classification algorithm is a relatively mature method and is one of the machine learning algorithms. The K-nearest neighbor algorithm is that in feature space, if most of thek closest (i.e., the closest neighbors in feature space) samples near a sample belong to a certain category, the sample also belongs to that category. Although the KNN algorithm is one of the simplest methods in the data mining classification technology, KNN can do both classification and regression, and we have to predict future data through the previous data, so the KNN algorithm is suitable as our prediction method. The K value of the KNN algorithm is the only hyperparameter in the algorithm, and the selection of the K value will have an intuitively important impact on the prediction result of the final algorithm The small K value means that only the training instance close to the input instance will work on the prediction result, but it is easy to overfit. If the K value is large, the advantage is that the estimation error of the learning can be reduced, but the disadvantage is that the approximate error of the learning increases, and the training instance that is far away from the input instance will also have an effect on the prediction, causing the prediction to be wrong.The training setD has m samples, each sample corresponds to a category, and each sample has n features, wherein the eigenvector of the sample, the corresponding class of the sample, and the training dataset D can be expressed as follows:(1)D=x1,y1,x2,y2,…,xm,ym,xi=xi1,xi2,…,xin.In the KNN algorithm, there are three commonly used distances, namely, Manhattan distance, European distance, and Minkowski distance.Let the feature space be n-dimensional real vector spaceRn; xi, xj∈X, xi=xi1,xi2,…,xinT, xj=xj1,xj2,…,xjnT, and xi, xj, whose distance is defined as Lp.(2)p≥1,Lpxi,xj=∑l=1n|xil−xjl|p1/p.p=1, called the Manhattan distance(3)L1xi,xj=∑l=1nxil−xjl.p=2, called Euclidean distance(4)L2xi,xj=∑l=1n|xil−xjl|21/2.p=∞, it is the maximum value of the distance of each coordinate, calculated as(5)L∞xi,xj=maxlxil−xjl.ANN refers to a complex network structure formed by a large number of processing units (neurons) connected to each other, which is a certain abstraction, simplification, and simulation of the human brain’s organizational structure and operating mechanism. An Artificial Neural Network (ANN), which simulates neuronal activity with mathematical models, is an information processing system established by mimicking the structure and function of brain neural networks. The method is also widely used in financial and economic research. The process is as follows:(6)gz=11+e−z,g′z=gz1−gz.(1)
Design activation function(2)
Calculate the cost function(7)JΘ=−1m∑i=1m∑k=1Kykilog1−hΘxik+−ykilog1−hΘxik+λ2m∑l=1L−1∑i=1sl∑j=1sl+1Θj,il2,JΘ=−1m∑YT.∗logΘA+log1−ΘA.∗1−YT.(3)
Design the forward propagation process(8)a2=gz2,z3=Θ3a3,a3=gz3,hΘx=a3.(4)
Design the backpropagation process(9)δl=al−y,l=L,Θlδl+1T.∗g′zl,l=2,3,…,L−1.Δl=δl+1alT,Di,jl=1mΔi,jl+λΘi,jl,j≠0,1mΔi,jl,j=0.(i)
Considering the nonlinear and strong time sequence characteristics of price data, we also consider the grey prediction analysis method and LSTM (Long Short-Term Memory Networks) to predict the price data of the next day. The LSTM structure diagram is shown in Figure6.(10)xi0=xi01,xi02,…,xi0n,xi1k=zi12,zi13,…,zi1k,k=2,2,3,…,n,a=BTB−1BTYm,dxi1dt+ax1=u,xi=xi1,xi2,…,xin+1,…,xin+m.Figure 6
Structure chart of LSTM.As an example, we adjusted the proportion of the training set and test set to 3 : 1 and constructed the K-Nearest Neighbor model, Artificial Neural Network model, the grey prediction model, and multi-layer LSTM model, respectively, as shown in Figures7–14.Figure 7
KNN prediction of gold.Figure 8
KNN prediction of bitcoin.Figure 9
ANN prediction of gold.Figure 10
ANN prediction of bitcoin.Figure 11
Grey prediction of gold.Figure 12
Grey prediction of bitcoin.Figure 13
LSTM prediction of gold.Figure 14
LSTM prediction of bitcoin.From these figures, the KNN algorithm is simple and easy to use, KNN is a nonparametric and lazy algorithm model, which requires high memory of the device, because the algorithm stores all the training data, and the prediction phase may be slow and sensitive to irrelevant data, so the prediction result of this algorithm is not ideal for a large number of data.Although the ANN algorithm has strong distributed storage and learning ability, strong parallel distribution processing ability, strong robustness, and fault tolerance ability, ANN algorithm needs a large number of parameters, such as network topology, weight, and threshold initial value. Unable to observe the learning process, the output results are difficult to interpret, which will affect the credibility and acceptability of the results.Training takes a long time and may not even be successful.Although grey prediction can process data with fewer characteristic values through a small number of samples, thus generating sequences with strong regularity can be obtained from irregular original data. But this method is only suitable for short-term forecasts, and the forecast trend is approximate exponential growth.The LSTM model selects and adjusts the transmitted information by adding gating states to the general recurrent neural network, to remember the information that needs long-term memory, and forget the unimportant information. This mechanism can predict complex nonlinear data well. Therefore, we choose the LSTM model as the prediction model.The training process is shown in Figure15.Figure 15
The training process of LSTM.All data prediction results are shown in Figures16 and 17 below:Figure 16
The predicted values of gold by LSTM.Figure 17
The predicted values of bitcoin by LSTM.As can be seen from Figures16 and 17 LSTM model can better predict the development trend of gold. But its forecasts for bitcoin’s late-stage numbers are generally low. This is because the concept of bitcoin has become widely known due to the development of science and technology. The public is more optimistic about the future of bitcoin, making the market more inclined to invest in bitcoin. This also suggests that investors should not only pay attention to the change in market value itself but also pay attention to the impact of the international situation, science and technology, and other macro factors. Because we assume that the subjectivity of investors and the market is not taken into account and the development trend predicted by the LSTM model is roughly consistent with the actual trend. Therefore, we still choose the bitcoin data predicted by the LSTM model as the prediction result.


### 4.2. The Selection of Index Analysis Model

Before determining the decision scheme, we should design appropriate indicators to standardize the decision selection. Through consulting the data, we select the indicators of quantitative trading strategy as shown in the following table:Ri means the price increase compared to the previous day, PVi which means the prediction of daily price. The calculation formula of Ri is as follows:(11)Ri=PVi−PVi−1.AVPn means the average price of n-days. The calculation formula of AVPn is as follows:(12)AVPn=∑i=1nPVin.BIASn means the difference between the daily price and the average price, The calculation formula of BIASn is(13)BIASn=PVi−AVPnAVPn∗100%.When the market trend is stable,BIASn should fluctuate within a normal range.(14)MIi=ω∗∑i=1nRin+1−ω∗BIASn.If it goes beyond the normal range, it can be regarded as excessive convergence divergence and the price will move closer to the moving average. If we’re looking at a short-term trend,n is usually 5, and if we’re looking at a long-term trend, n is usually 15. MIi means determine whether the current market is bullish or bearish. MIi means weight. The calculation formula of MIi are as follows:Usually, whenMIi > 0.57 the market is doing well and prices are going up, we call it ‘a bull market’, and when MIi < 0.57 the market is not doing well and prices are going down, we call it ‘a bear market’. HRi means the risk probability of buying the next day. The calculation formula of HRi is(15)HRi=ω∗MIi+1−ω∗BIASn.Among the five indicators mentioned above, the n-day convergence and divergence ratio, market quotation index and purchase risk ratio will determine investors’ trading action, trading time, and trading volume. And market indicators, buying risk rates will determine investors in gold and bitcoin investment preference.As Figures18 and 19 shows, bitcoin is growing faster and more dangerous overall, while gold is relatively safe but has limited upside. Therefore, the ratio of bitcoin to gold investment determines the risk and feasibility of the final strategy.Figure 18
Market condition.Figure 19
Market risk.


### 4.3. The Selection of Decision Model

According to the basic idea of a “5-day moving average”, we design trading strategies as follows:(1)
Observe the existing data and take the five-day line as the benchmark. If the price is above the five-day line, we choose to look at the short-term trend and choose to buy. If the price is below the five-day line, we will not participate in the transaction.(2)
Shares bought above the five-day line should also be sold above the five-day line.(3)
The share should be sold higher than the cost at least to ensure the premise of not losing money.(4)
Consider selling when the price deviates too much from the bias of 5 days and the price is 7–15% above the 5-day line.(5)
Consider buying when there is a bear market and prices are 7–15% below the 5-day line.(6)
Trade up to five times a day.(7)
Sell at least 50% shares when you can gain huge profits.Based on the above strategy, Monte Carlo simulated a maximum return of $245,046.1 on an initial investment of $1,000 through October 9, 2021.


## 4.1. The Selection of the Prediction Model

The precious metals and scarcity of gold have been recognized as safe-haven assets since ancient times. When there are major changes or fluctuations in the market, the physical value and exchange rate of gold will remain relatively stable and have a stable investment value. At the same time, Bitcoin as an emerging monetary asset has similar properties to gold.On the supply side, gold mining and Bitcoin mining are decentralized, and their ownership is decentralized. Moreover, unlike traditional currencies, their supply cannot be created by decree or monetary policy. On the demand side, both assets are seen as hedging against inflation and hedging value. We can analyze gold and Bitcoin using the same influencing factors.Through the analysis of data indicators affecting the price of gold, it can be seen that it is an important macroeconomic indicator that reflects the changes in the price level of consumer goods and services related to the lives of residents-CPI is an important indicator of inflation. At the same time, we found that it can also be related to the price of gold. To unify the volume of spot gold, we chose the CPI data of the United States.If the data increase is too large, it means that inflation has become a factor of economic instability, and the state will adopt a tight fiscal policy or monetary policy to check and balance. At this point, the excessive increase in the data is not welcomed by the market, and the central bank must change it by adjusting interest rates. At this time, the hedging effect of gold appears, which has the effect of promoting the rise of spot gold prices. If the data rises moderately, indicating that the economy is good and the currency is appreciating, it is bearish for spot gold.We compared the data for gold, Bitcoin, and the US CPI from 2016 to 2020 and found that the R^2 on polynomial fitting was 0.9679 and 0.8685, respectively, as shown in Figures4 and 5.Figure 4
Chart of CPI and gold price historical trend.Figure 5
Chart of CPI and bitcoin price historical trend.In the reference paper [1], the author argues that KNN and ANN machine learning models may apply to CPI inflation forecasting when forecasting CPI (consumer price index) inflation. In addition, the methods currently widely used in investment forecasting mainly include time series analysis, grey forecast analysis, neural network analysis, and some other classical machine learning methods.Here we mainly use the grey predictive analytics method, KNN, ANN, and LSTM to predict the existing data. K-earest Neighbor (KNN) classification algorithm is a relatively mature method and is one of the machine learning algorithms. The K-nearest neighbor algorithm is that in feature space, if most of thek closest (i.e., the closest neighbors in feature space) samples near a sample belong to a certain category, the sample also belongs to that category. Although the KNN algorithm is one of the simplest methods in the data mining classification technology, KNN can do both classification and regression, and we have to predict future data through the previous data, so the KNN algorithm is suitable as our prediction method. The K value of the KNN algorithm is the only hyperparameter in the algorithm, and the selection of the K value will have an intuitively important impact on the prediction result of the final algorithm The small K value means that only the training instance close to the input instance will work on the prediction result, but it is easy to overfit. If the K value is large, the advantage is that the estimation error of the learning can be reduced, but the disadvantage is that the approximate error of the learning increases, and the training instance that is far away from the input instance will also have an effect on the prediction, causing the prediction to be wrong.The training setD has m samples, each sample corresponds to a category, and each sample has n features, wherein the eigenvector of the sample, the corresponding class of the sample, and the training dataset D can be expressed as follows:(1)D=x1,y1,x2,y2,…,xm,ym,xi=xi1,xi2,…,xin.In the KNN algorithm, there are three commonly used distances, namely, Manhattan distance, European distance, and Minkowski distance.Let the feature space be n-dimensional real vector spaceRn; xi, xj∈X, xi=xi1,xi2,…,xinT, xj=xj1,xj2,…,xjnT, and xi, xj, whose distance is defined as Lp.(2)p≥1,Lpxi,xj=∑l=1n|xil−xjl|p1/p.p=1, called the Manhattan distance(3)L1xi,xj=∑l=1nxil−xjl.p=2, called Euclidean distance(4)L2xi,xj=∑l=1n|xil−xjl|21/2.p=∞, it is the maximum value of the distance of each coordinate, calculated as(5)L∞xi,xj=maxlxil−xjl.ANN refers to a complex network structure formed by a large number of processing units (neurons) connected to each other, which is a certain abstraction, simplification, and simulation of the human brain’s organizational structure and operating mechanism. An Artificial Neural Network (ANN), which simulates neuronal activity with mathematical models, is an information processing system established by mimicking the structure and function of brain neural networks. The method is also widely used in financial and economic research. The process is as follows:(6)gz=11+e−z,g′z=gz1−gz.(1)
Design activation function(2)
Calculate the cost function(7)JΘ=−1m∑i=1m∑k=1Kykilog1−hΘxik+−ykilog1−hΘxik+λ2m∑l=1L−1∑i=1sl∑j=1sl+1Θj,il2,JΘ=−1m∑YT.∗logΘA+log1−ΘA.∗1−YT.(3)
Design the forward propagation process(8)a2=gz2,z3=Θ3a3,a3=gz3,hΘx=a3.(4)
Design the backpropagation process(9)δl=al−y,l=L,Θlδl+1T.∗g′zl,l=2,3,…,L−1.Δl=δl+1alT,Di,jl=1mΔi,jl+λΘi,jl,j≠0,1mΔi,jl,j=0.(i)
Considering the nonlinear and strong time sequence characteristics of price data, we also consider the grey prediction analysis method and LSTM (Long Short-Term Memory Networks) to predict the price data of the next day. The LSTM structure diagram is shown in Figure6.(10)xi0=xi01,xi02,…,xi0n,xi1k=zi12,zi13,…,zi1k,k=2,2,3,…,n,a=BTB−1BTYm,dxi1dt+ax1=u,xi=xi1,xi2,…,xin+1,…,xin+m.Figure 6
Structure chart of LSTM.As an example, we adjusted the proportion of the training set and test set to 3 : 1 and constructed the K-Nearest Neighbor model, Artificial Neural Network model, the grey prediction model, and multi-layer LSTM model, respectively, as shown in Figures7–14.Figure 7
KNN prediction of gold.Figure 8
KNN prediction of bitcoin.Figure 9
ANN prediction of gold.Figure 10
ANN prediction of bitcoin.Figure 11
Grey prediction of gold.Figure 12
Grey prediction of bitcoin.Figure 13
LSTM prediction of gold.Figure 14
LSTM prediction of bitcoin.From these figures, the KNN algorithm is simple and easy to use, KNN is a nonparametric and lazy algorithm model, which requires high memory of the device, because the algorithm stores all the training data, and the prediction phase may be slow and sensitive to irrelevant data, so the prediction result of this algorithm is not ideal for a large number of data.Although the ANN algorithm has strong distributed storage and learning ability, strong parallel distribution processing ability, strong robustness, and fault tolerance ability, ANN algorithm needs a large number of parameters, such as network topology, weight, and threshold initial value. Unable to observe the learning process, the output results are difficult to interpret, which will affect the credibility and acceptability of the results.Training takes a long time and may not even be successful.Although grey prediction can process data with fewer characteristic values through a small number of samples, thus generating sequences with strong regularity can be obtained from irregular original data. But this method is only suitable for short-term forecasts, and the forecast trend is approximate exponential growth.The LSTM model selects and adjusts the transmitted information by adding gating states to the general recurrent neural network, to remember the information that needs long-term memory, and forget the unimportant information. This mechanism can predict complex nonlinear data well. Therefore, we choose the LSTM model as the prediction model.The training process is shown in Figure15.Figure 15
The training process of LSTM.All data prediction results are shown in Figures16 and 17 below:Figure 16
The predicted values of gold by LSTM.Figure 17
The predicted values of bitcoin by LSTM.As can be seen from Figures16 and 17 LSTM model can better predict the development trend of gold. But its forecasts for bitcoin’s late-stage numbers are generally low. This is because the concept of bitcoin has become widely known due to the development of science and technology. The public is more optimistic about the future of bitcoin, making the market more inclined to invest in bitcoin. This also suggests that investors should not only pay attention to the change in market value itself but also pay attention to the impact of the international situation, science and technology, and other macro factors. Because we assume that the subjectivity of investors and the market is not taken into account and the development trend predicted by the LSTM model is roughly consistent with the actual trend. Therefore, we still choose the bitcoin data predicted by the LSTM model as the prediction result.


## 4.2. The Selection of Index Analysis Model

Before determining the decision scheme, we should design appropriate indicators to standardize the decision selection. Through consulting the data, we select the indicators of quantitative trading strategy as shown in the following table:Ri means the price increase compared to the previous day, PVi which means the prediction of daily price. The calculation formula of Ri is as follows:(11)Ri=PVi−PVi−1.AVPn means the average price of n-days. The calculation formula of AVPn is as follows:(12)AVPn=∑i=1nPVin.BIASn means the difference between the daily price and the average price, The calculation formula of BIASn is(13)BIASn=PVi−AVPnAVPn∗100%.When the market trend is stable,BIASn should fluctuate within a normal range.(14)MIi=ω∗∑i=1nRin+1−ω∗BIASn.If it goes beyond the normal range, it can be regarded as excessive convergence divergence and the price will move closer to the moving average. If we’re looking at a short-term trend,n is usually 5, and if we’re looking at a long-term trend, n is usually 15. MIi means determine whether the current market is bullish or bearish. MIi means weight. The calculation formula of MIi are as follows:Usually, whenMIi > 0.57 the market is doing well and prices are going up, we call it ‘a bull market’, and when MIi < 0.57 the market is not doing well and prices are going down, we call it ‘a bear market’. HRi means the risk probability of buying the next day. The calculation formula of HRi is(15)HRi=ω∗MIi+1−ω∗BIASn.Among the five indicators mentioned above, the n-day convergence and divergence ratio, market quotation index and purchase risk ratio will determine investors’ trading action, trading time, and trading volume. And market indicators, buying risk rates will determine investors in gold and bitcoin investment preference.As Figures18 and 19 shows, bitcoin is growing faster and more dangerous overall, while gold is relatively safe but has limited upside. Therefore, the ratio of bitcoin to gold investment determines the risk and feasibility of the final strategy.Figure 18
Market condition.Figure 19
Market risk.


## 4.3. The Selection of Decision Model

According to the basic idea of a “5-day moving average”, we design trading strategies as follows:(1)
Observe the existing data and take the five-day line as the benchmark. If the price is above the five-day line, we choose to look at the short-term trend and choose to buy. If the price is below the five-day line, we will not participate in the transaction.(2)
Shares bought above the five-day line should also be sold above the five-day line.(3)
The share should be sold higher than the cost at least to ensure the premise of not losing money.(4)
Consider selling when the price deviates too much from the bias of 5 days and the price is 7–15% above the 5-day line.(5)
Consider buying when there is a bear market and prices are 7–15% below the 5-day line.(6)
Trade up to five times a day.(7)
Sell at least 50% shares when you can gain huge profits.Based on the above strategy, Monte Carlo simulated a maximum return of $245,046.1 on an initial investment of $1,000 through October 9, 2021.


## 5. Model II: Description of the Best Strategy

In the design of the Quantitative Trading Decision Model, we split the large model into three small models, in which the selection of indicators is obtained by quantitative investment theory without verification.


### 5.1. Validation of Prediction Model

Common measurement model error indicators (RMSE, R2) are selected to predict the accuracy of the model.RMSE means root mean square error, yi means real value, yi means predicted value, R2 means coefficient of determination.(16)RMSE=1n∑i=1nyi−yi^2,R2=1−∑iyi−yi^2∑iyi−yi¯2.The parameter results of gold prediction and Bitcoin prediction are shown in the following Table1.Table 1
Parameter results.
RMSER2Gold22.300.99Bitcoin7882.870.92It can be seen that the gold model predicted by the LSTM algorithm is more accurate, but there is a certain gap in the Bitcoin model. By comparing the actual data with the predicted data, it can be found that the actual data has risen significantly since October 2020 as shown in Figure20.Figure 20
Prediction data of bitcoin.Through reference, it was found that the price of bitcoin fell sharply in early 2020 due to the outbreak of COVID-19. However, after more than half a year, people began to have a preliminary understanding of the epidemic and no longer panicked investment. At the same time, the advent of the epidemic has made people change their investment philosophy. The public is becoming more aware of bitcoin’s technology and the value behind it, and more optimistic about its future. In the hypothesis, we assume that the global situation is stable and COVID-19 is an atypical factor. In addition, the general trend of predicted data changes is close to the actual data, so we think it is appropriate to choose the LSTM model.


### 5.2. Validation of Decision Model

Here, we introduce the “greedy algorithm” as a comparison strategy. The core idea of the algorithm is to take the US dollar, Bitcoin, and gold as three nodes and convert the investment strategy into a combination mode. Buy the state that sells according to 3 nodes can be divided into the following 8 kinds of investment means.Bt means the unit price of bitcoin at t day, Gt means the unit price of gold at t day, bt means hold bitcoin at t day, ct means cash holdings at t day, gt means gold holdings at t day. α1 means gold transaction cost, α2 means bitcoin transaction costs.The quantities of the dollar, bitcoin, and gold are unchanged.(17)ft=ct−1+Bt∗bt−1+Gt∗gt−1.Convert dollars into bitcoins and gold stays put.(18)ft=ct−1∗1−α2Bt+1∗Bt+Gt∗gt−1.Convert gold into dollars and then convert it into bitcoin along with the original dollars.(19)ft=bt−1∗Bt−1∗1−α2+ct−1∗1−α1Gt−1∗Gt.Convert dollars into gold and bitcoin stays the same.(20)ft=ct−1∗1−α1Gt+Bt∗bt−1.Convert bitcoins into dollars and then convert them into gold along with the original dollars.(21)ft=gt−1∗Gt−1∗1−α1+ct−1∗1−α1Bt−1∗Bt.Sell gold and convert it into dollars.(22)ft=gt−1∗Gt−1∗1−α1+ct−1+bt−1∗Bt.Sell the original bitcoins and convert them into dollars.(23)ft=gt−1∗Gt−1∗1−α1+ct−1+bt−1∗Bt.Sell the old gold and bitcoin together and convert it into dollars.(24)ft=bt−1∗Bt−1∗1−α1+gt−1∗Gt−1∗1−α1+ct−1.Then, we simulated the two strategies using actual and forecast data as shown in Figure21.Figure 21
Comparison of different strategies.It can be seen from the figure that the average return of the actual data is 19.20% higher than the expected data, which is caused by the rapid increase of the influence of uncontrollable factors in the late-stage of Bitcoin. The average return result of the 5-day moving average method is 20.32% higher than that of the greedy algorithm, indicating that the 5-day moving average method has significant advantages.


## 5.1. Validation of Prediction Model

Common measurement model error indicators (RMSE, R2) are selected to predict the accuracy of the model.RMSE means root mean square error, yi means real value, yi means predicted value, R2 means coefficient of determination.(16)RMSE=1n∑i=1nyi−yi^2,R2=1−∑iyi−yi^2∑iyi−yi¯2.The parameter results of gold prediction and Bitcoin prediction are shown in the following Table1.Table 1
Parameter results.
RMSER2Gold22.300.99Bitcoin7882.870.92It can be seen that the gold model predicted by the LSTM algorithm is more accurate, but there is a certain gap in the Bitcoin model. By comparing the actual data with the predicted data, it can be found that the actual data has risen significantly since October 2020 as shown in Figure20.Figure 20
Prediction data of bitcoin.Through reference, it was found that the price of bitcoin fell sharply in early 2020 due to the outbreak of COVID-19. However, after more than half a year, people began to have a preliminary understanding of the epidemic and no longer panicked investment. At the same time, the advent of the epidemic has made people change their investment philosophy. The public is becoming more aware of bitcoin’s technology and the value behind it, and more optimistic about its future. In the hypothesis, we assume that the global situation is stable and COVID-19 is an atypical factor. In addition, the general trend of predicted data changes is close to the actual data, so we think it is appropriate to choose the LSTM model.


## 5.2. Validation of Decision Model

Here, we introduce the “greedy algorithm” as a comparison strategy. The core idea of the algorithm is to take the US dollar, Bitcoin, and gold as three nodes and convert the investment strategy into a combination mode. Buy the state that sells according to 3 nodes can be divided into the following 8 kinds of investment means.Bt means the unit price of bitcoin at t day, Gt means the unit price of gold at t day, bt means hold bitcoin at t day, ct means cash holdings at t day, gt means gold holdings at t day. α1 means gold transaction cost, α2 means bitcoin transaction costs.The quantities of the dollar, bitcoin, and gold are unchanged.(17)ft=ct−1+Bt∗bt−1+Gt∗gt−1.Convert dollars into bitcoins and gold stays put.(18)ft=ct−1∗1−α2Bt+1∗Bt+Gt∗gt−1.Convert gold into dollars and then convert it into bitcoin along with the original dollars.(19)ft=bt−1∗Bt−1∗1−α2+ct−1∗1−α1Gt−1∗Gt.Convert dollars into gold and bitcoin stays the same.(20)ft=ct−1∗1−α1Gt+Bt∗bt−1.Convert bitcoins into dollars and then convert them into gold along with the original dollars.(21)ft=gt−1∗Gt−1∗1−α1+ct−1∗1−α1Bt−1∗Bt.Sell gold and convert it into dollars.(22)ft=gt−1∗Gt−1∗1−α1+ct−1+bt−1∗Bt.Sell the original bitcoins and convert them into dollars.(23)ft=gt−1∗Gt−1∗1−α1+ct−1+bt−1∗Bt.Sell the old gold and bitcoin together and convert it into dollars.(24)ft=bt−1∗Bt−1∗1−α1+gt−1∗Gt−1∗1−α1+ct−1.Then, we simulated the two strategies using actual and forecast data as shown in Figure21.Figure 21
Comparison of different strategies.It can be seen from the figure that the average return of the actual data is 19.20% higher than the expected data, which is caused by the rapid increase of the influence of uncontrollable factors in the late-stage of Bitcoin. The average return result of the 5-day moving average method is 20.32% higher than that of the greedy algorithm, indicating that the 5-day moving average method has significant advantages.


## 6. Model III: Cost Impact Model

According to the strategy and return result obtained in the above question, different return results can be obtained by changing the commission cost of gold and the commission cost of bitcoin.d means descent rate.(25)d=yi−1−yiyi−1∗100%.Change the commission cost of gold and the commission cost of bitcoin to see what happens to returns. For each 1% increase in the cost of bitcoin commissions, total returns will decrease by 7% to 8% each time the gold commission cost remains unchanged. Figures22–25 show the change in returns for each 1% increase in gold commissions.Figure 22
Gold commissions cost 1%.Figure 23
Gold commissions cost 2%.Figure 24
Gold commissions cost 3%.Figure 25
Gold commissions cost 4%.With the bitcoin commission cost unchanged, the total return decreases by 24% to 25% for each 1% increase in the gold commission cost. It can be seen from the data just released that the change of gold commission cost has a great impact on the total income, because when choosing gold and bitcoin to invest in, we should pay attention to the portfolio investment. However, the price of gold is relatively stable compared with the price of Bitcoin. Although there are small fluctuations sometimes, it can be seen from the overall forecast data. The price of gold is rising steadily and the baseline of the gold price is also rising, so gold investment will account for a large part of the total investment and have a great influence on the total income. Figures26–29 show the change in returns for each 1% increase in bitcoin commissions.Figure 26
Gold commissions cost 1%.Figure 27
Gold commissions cost 2%.Figure 28
Gold commissions cost 3%.Figure 29
Gold commissions cost 4%.The price of Bitcoin rose sharply in October 2020. Under the impact of COVID-19, capital would choose digital currency whose intrinsic value is completely decoupled from industry to hedge against inflation. Bitcoin, which continues to rise in the face of the pandemic, is now considered the best safe-haven asset after gold. But the rise in the currency is rising and institutional demand-driven, selling pressure to reduce, the spot market rebound, the American institutions such as grey COINS continued to increase and supply reduction, the digital currency has increasingly become the mainstream of payment options, the spot price plays a leading role, the spot market-leading derivatives market is very important, the financial industry, and more and more people for approval. The dwindling number of Bitcoins and other factors.


## 7. Sensitivity Analysis

Sensitivity analysis is a method to study and analyze the sensitivity of state or output changes of a system (or model) to changes in system parameters or surrounding conditions. Sensitivity analysis is often used in optimization methods to study the stability of the optimal solution when the original data is inaccurate or changes. Sensitivity analysis can also determine which parameters have a greater impact on the system or model. Therefore, sensitivity analysis is important in almost all operations research methods and the evaluation of various scenarios. Special attention should be paid to the influence of heat radiation, heat conduction and heat convection on the temperature field in heat transfer.The advantage of sensitivity analysis is that it can measure the influence range of various uncertain factors on the benefit of the original decision scheme, which is conducive to the decision maker understanding the risk source and degree of the scheme. The most sensitive factors can be found from all kinds of uncertainties, so that the assessor can focus on these key factors. Sensitivity analysis can be used to optimize investment schemes in multi-scheme comparison. However, sensitivity analysis is subjective and speculative to a certain extent. It is unable to determine the true variation range of a certain uncertainty factor and the possibility of variation within this range, as well as the degree of risk to investment returns. The sensitivity analysis of more factors also has some difficulties in technical and practical work, which need to be discussed and solved. All these indicate that sensitivity analysis has some limitations.To conduct sensitivity analysis, we changed the original real data every four data to change the original data. LSTM neural network prediction model was used to predict the data again. The reliability of the model was compared by comparing the value of the reliability coefficientR2. Through the test, the reliability coefficient R2 of the data predicted by the variation data is 0.96, and that of the real data is 0.99. By contrast, the volatility is still very small and the reliability coefficient is still very high, indicating that our model is very reliable. The simulated prediction chart of variation data is shown in Figure 30.Figure 30
Test image of variation data.


## 8. Model Evaluation

LSTM neural network prediction model can only remember 100 order of magnitude sequences, not 1000 order of magnitude or longer sequences. LSTM training has high hard conditions for equipment, so it may take a long time for large data sets. For the known data, dynamic programming is not the optimal solution. LSTM neural network prediction model can accurately predict the data by inputting the number of iterations. We also realize the data preprocessing function through noise reduction, which can be better predicted. LSTM neural network is a kind of RNN, which is especially suitable for processing and predicting important data related to time series events, in line with the meaning of this topic.


## 9. Conclusion

LSTM neural network prediction model can only remember 100 order of magnitude sequences, not 1000 order of magnitude or longer sequences. LSTM training has high hard conditions for equipment, so it may take a long time for large data sets. For the known data, dynamic programming is not the optimal solution. LSTM neural network prediction model can accurately predict the data by inputting the number of iterations. We also realize the data preprocessing function through noise reduction, which can be better predicted. LSTM neural network is a kind of RNN, which is especially suitable for processing and predicting important data related to time series events, in line with the meaning of this topic. In this paper, we seek the best investment strategy through several prediction models and investment algorithms. We use the long-term and short-term memory model based on variational modal decomposition, cyclic neural network model as the core prediction model, and combine the algorithm of the “five-day moving average trading method” to make a combined investment, and finally get the best investment strategy. After that, we also changed the data of the training set of the long-term and short-term memory model cyclic neural network model by changing the original data, and predicted again. It was found that the decisive coefficient was only slightly lower than the original decisive coefficient. Therefore, it can be seen that the accuracy of the data predicted by the long-term and short-term memory model cyclic neural network model further verified the rationality of the model where the innovation of this paper lies in.Before the prediction of the long-term and short-term memory model and cyclic neural network model, noise reduction is carried out five times to make the predicted data more accurate. We also compare the other models to show the superiority of the model used in this paper. Investment trading has increasingly become a popular industry in people’s minds, especially in the gold and bitcoin investment industries, so the investment algorithms and models are worthy of our in-depth study. We formulate the portfolio investment method according to the predicted data, which may not be the best and can be improved.



---

*Source: 4185974-2022-10-07.xml*