Prediction of the Future Price Trend for Users Based on BP Neural Network

. Since the last century, the method of quantitative trading has begun to emerge. It is very meaningful to study the formulation of the best trading strategy. The future price trend is predicted based on BP Neural Network time series model, and a Quantitative Decision Model is established by using BIAS and RSI indicators and transaction cost, so as to describe a more complete market situation. We use the Nonlinear Least Square method to fit the BP neural network model and investigate the difference between the prediction model and the actual value. After modeling, we also carried out sensitivity analysis, which revealed the stability of our model for some parameters.


Introduction
In the context of Internet & big data &AI, how to better integrate human and technology in the investment process becomes the key to the investment in future. Under this background, quantitative investment is increasingly valued by banks, brokerages and fund companies. With a strong desire to contribute to the development of financial quantitative markets, we try to develop a model that uses only the daily price flow so far to determine whether traders should buy, hold or sell their portfolio assets every day.
As a P2P digital currency officially released in 2009, the price of bitcoin has soared with the passage of time, becoming the digital currency with the highest value in the market, known as "digital gold". As the earliest currency, gold is also an important financial asset. Its hedging function is difficult to be replaced by other currencies. Some time ago, gold entered the adjustment period of rising and falling prices, and the price of bitcoin hit a record high. Therefore, the voice of "bitcoin will replace gold" continued to spread [1], and the relationship between gold and bitcoin has become an increasingly hot topic. Many investors believe that bitcoin is a new type of gold, which may replace gold as a hedge against inflation and become a new hedge asset for risk management. Therefore, the research on the relationship between bitcoin and gold has important theoretical research value and practical significance [2]. For this, our quantitative trading model takes bitcoin and gold as trading objects, it is of great significance to explore and study the price development trend of bitcoin and gold and the best portfolio of bitcoin and gold.

The structure of BP neural network
BP neural network is a multi-layer network with error reverse propagation, which is composed of input layer nodes, hidden layer nodes and output layer nodes. This process has been reduced to an acceptable level of error to the network output, or to a predetermined number of learning times. The network structure is shown in Figure 1 [3]. Based on the price of gold and bitcoin in the five-year period from 2016 to 2021 as the historical value, we believe that the price of gold and bitcoin is related to time t, that is, they meet the following relationship: (1) Where n represents n values before time t. Input variable: (2) Expected value output vector: Output weight inner product: (4) Activation function: Minimum mean square error loss function: Among ω And B are parameters that need to be updated.
H (i) is the mathematical expression of any intermediate layer I of BP neural network. Since the model structure of time series prediction model can be used as the input structure of BP neural network, formula (1) can be obtained.

The solution of model
(1)Data normalization processing.
(2)Create network: Determine the number of neurons and the number of network layers: according to the empirical formula, (input + output) / 2, we can get that the number of layers in this model is 3.
Empirical formula for the number of neurons in the hidden layer: Where m is the input, n is the output, and is a constant from 1 to 10. I.e. L = 8.

Results
The above figure reflects the prediction accuracy of our BP neural network time series prediction model, from which we can clearly see that the prediction effect is not much different from the real value.

Quantitative Decision Model
First, we begin to process the initial two data sets. First, we "align" the gold price list with the special currency price list, that is, we supplement the gold price list with complete price data on non trading days. Here we use interpolation method for processing. Here we use Python to adjust the initial table. The adjustment results are as follows: (the amount of data is too large. For the sake of the aesthetics of the paper, we will show some data) After data processing, the trend chart of gold and bitcoin in the past five years is drawn: Trend chart of gold and bitcoin over the past five years.
According to the general financial law, when the price of financial products falls, we carry out position adding operation. Through the image, we can also see that bitcoin fluctuates greatly and is suitable for short-term. On the contrary, the price of gold is relatively stable and suitable for medium and long-term. Comparing the two figures, we find that on the premise of ensuring the risk, the proportion of buying bitcoin is higher than that of gold, which is easier to obtain greater benefits.
We have BP Neural Network -time series prediction model, which can accurately predict the price of gold and bitcoin on that day and in the next few days.
Based on our research on current stock investment, gold fluctuates slightly up and down. We use the 20 day moving average method, while bitcoin fluctuates greatly up and down. We use the fiveday moving average method. Next, we give a universal overweight trading strategy.
That is, when the price of bitcoin stands at the five-day moving average, short-term investors can consider buying. When the share price continues to rise and is suppressed by the 20 day moving average, or when the price of bitcoin falls below the five-day moving average, investors can consider selling; When the gold price stands at the 20 day moving average, you can consider buying. When the gold price falls below the 20 day moving average, you can sell [4].
According to the five-day moving average method and the 20 day moving average method: , are the price of bitcoin and gold at a certain time t. In order to better instruct traders to judge the trend of gold and bitcoin, we introduce the concept of deviation rate (bias) in Financial Economics: It is easy to conclude from the image that the position is increased when the deviation rate of gold and bitcoin is low. However, due to the long time span and certain transaction costs, it is unreasonable to buy and sell only according to the deviation rate. Therefore, we introduce another parameter RSI to reflect the price trend [5].
According to the definition of RSI index in financial circles: A is the increase in n days and B is the decrease in n days. As mentioned above, the trend of bitcoin is relatively volatile, which is suitable for short-term trading, and RSI index is relatively sensitive to short-term trading. RSI value divides the overall results into four regions: extremely weak, weak, strong and extremely strong. Generally speaking, when RSI is in the [80100] range, it believes that the market is hot and suitable for selling, and there is a possibility of rising in the [50, 80] range. [20,50] shows that the short side strength is greater than the multi-party strength, which is lower than 20. The market representation is very weak, which is suitable for adding positions to buy.
According to BP Neural Network time Series Prediction Model, calculate the deviation rate of gold or bitcoin price on that day, and we design a standard to judge when to buy and when to sell.

(14)
According to the data given in the python simulation topic, we buy gold when u is greater than 5.28, sell it when u is less than 3.21, buy bitcoin when u is greater than 9.45 and sell it when u is less than 4.26: To sum up, we have a real judgment model that is to predict the price of the day according to the neural network prediction time series, and calculate the deviation rate of the day and the increase on the 5th or 20th day according to the historical price data, so as to determine the general trend of the day. However, whether the day continues to rise or fall needs another RSI index. According to the neural network training data sample, we determine the weight of the three measurement indicators, and finally determine the trading strategy according to the joint action of the three indicators. (16) We assume that we buy a bitcoin on the first day and all the remaining amount buys gold, so that the initial gold and bitcoin components can be determined. With the trading operation of the model, their shares change continuously. However, they are two completely different financial products with low internal correlation. Therefore, this paper will not study the changes of gold and bitcoin shares, from the price trend of gold and bitcoin over the past five years, we can also roughly speculate that the share of bitcoin will be higher in the end.

Sample training regression simulation
We use the neural network toolbox in MATLAB to carry out sample regression training simulation. The so-called training network is to make the forward propagation and back propagation go back and forth continuously, constantly update the parameters of the network, and finally make the network approach the real relationship. Taking the value data of bitcoin and Gold in the pricing document as training and test samples respectively, the final fitting result diagram is obtained, as shown in the figure: The analysis results show that the goodness of fit of bitcoin and gold is close to 1, indicating that the fitting effect is good.

Sensitivity analysis of transaction strategy to transaction cost
Firstly, we assume that the transaction is completed at this time, and the traders use the model strategy provided by us to obtain high and stable returns. Next, we will analyze the impact of transaction costs on this model.
When the transaction is completed, the price of gold and bitcoin is fixed, and the holding amount of gold and bitcoin is fixed. Because the model believes that x (gold, bitcoin price) is closely related to time, the above formula can consider the functional relationship between dollar holding amount y and time t. namely: Expanded: When changing the Commission, gold observes the change of final assets between [1% and 10%], and bitcoin observes the change of final assets between [2% and 12%]. The interval step size is 0.01, so different commission combinations have: (20) In our model code, this part is achieved by using two-layer for loop. After calculation and statistics, the impact of different commissions on the final assets is as follow Figure 8. Impact of different commissions on final assets.
Moreover, due to the sharp rise in the price of bitcoin in the later stage, the size of bitcoin Commission has a greater impact than that of gold Commission.

Conclusion
In this paper, we first normalize the price data of bitcoin and gold. Then, we establish our model to provide traders with the best trading strategy and complete income changes. In the process of analysis, we use BP neural network model to predict the future daily prices of bitcoin and gold, and draw the price trend chart of bitcoin and gold. At the same time, we use the Nonlinear least square method for regression fitting to verify that our model provides the best strategy, and then use the deviation rate and RSI index and transaction cost to establish a quantitative decision model to finally determine the best trading strategy. By changing the Commission, this paper explores the impact of transaction costs on this model, and obtains the impact of different commissions on the final assets. In order to make our model more rigorous and accurate, we carried out sensitivity analysis and risk analysis.