Risk and Return: An Empirical Analysis of the Optimal Trading Strategies of Gold and Bitcoin from the Perspective of Market Traders with Three Decision Types

This paper uses the daily prices of gold and bitcoin from September 2016 to September 2021 to discuss the optimal decision of market traders. LSTM algorithm is used to predict the future price trend of bitcoin and gold. Then, calculate the risk coefficient of Bitcoin and gold trading. Next, the expected returns of gold and bitcoin are obtained according to the determined price forecast value, and combined with the risk coefficient to construct the transaction function. Finally, because the objective function and constraint conditions are linear functions, the results are calculated by using the idea of linear programming. In the whole paper, considering the attitude of market traders in decision-making, three types of decision makers are discussed. Firstly, the time series model is used to predict the data of the same gold and bitcoin. Then, the data predicted by the LSTM model and the time series model are used to calculate the MAE and MSE. By comparing the numerical values, the LSTM model is significantly superior to the time series model, so that the optimal prediction method is proved. Next, for three different decision types of traders, respectively, using the decision model established in 6.1 to find whether the optimal decision point exists and meaningful. The results show that all three types of decision makers can make optimal decisions under the influence of the risk of the predicted data, that is, the risk of the decision model is controllable. Secondly, to demonstrate the sensitivity of transaction costs. Firstly, the fixed commission ratio in the requirements is adjusted, and the commission ratios of bitcoin and gold are adjusted respectively, floating up and down within 20 %. Then, it is brought into 6.1 to calculate the optimal decision-making profit value of traders of three decision-making types. Finally, it is found that the profit value of the optimal decision-making point is very stable. Compared with the profit value calculated by the given commission ratio, the deviation is less than 0.4 %, and the sensitivity analysis of transaction cost is well completed. Finally, but not the most important, it is hoped that the model studied in this paper can help market traders make optimal strategies when making decisions.


Introduction
The financial industry has now become an indispensable existence in modern society. When you think of finance, what comes to your mind? Warren Buffett? stock? gold? More likely to be wealth and risk.
You know that in the huge market, there is a group to help employers or companies to buy and sell financial assets in order to maximize investment returns. And they can earn a commission proportional to their investment income. They are market traders. Every transaction will bring certain benefits to market traders. There are many well-known market traders in the world today. For example, the legendary short-term trader Martin Schwartz, who once used technical analysis and excellent trading analysis skills, brought him huge wealth. From the initial $40,000, Schwartz's wealth quickly grew to 2,000. Ten thousand U.S. dollars. In addition, there are many legendary traders like Martin.
However, high returns are always accompanied by high risks. In the face of high risks in the financial market and fluctuations in asset prices, it is necessary to carefully consider how to make decisions to maximize investment returns. Market traders have different decision-making methods, and their ultimate goal is to use a variety of tools and models to calculate and make the best strategy.

Literature Review
Statistical research on financial asset price volatility is very important. The literature review part of this paper mainly studies the related research of several scholars using LSTM model to process financial futures data.Hu Yeshuai (2021) mentioned in his paper the application of deep learning to quantitative trading strategies. The feature of deep learning is to bring a large number of data sets into the designed model, and at the same time, it can perform image recognition well. , but there is not much processing of time series financial data. [1] Wang Xin (2018) applied the LSTM recurrent neural network in the deep learning neural network to the system fault prediction, and proved the feasibility of LSTM processing time series data. [2] Li Ying and other scholars (2020) found that the LSTM model optimized by genetic algorithm processes complex and nonlinear time series data in the futures market for forecasting. The results showed that the prediction effect of the model was good and had universal applicability. [3] Wang Yuqian (2021) predicted futures by building an LSTM model under the framework of deep learning, and found that the recurrent neural network has a good performance in futures price prediction and has great potential for development. compared three arbitrage strategy models based on LSTM neural network, BP neural network and convolutional neural network. The results show that the black metal futures arbitrage strategy model based on LSTM neural network is more feasible and effective than the other two models. [6]By studying the above scholars in the use of LSTM model for financial product data processing and research, obtained some reference and model ideas.

Assumptions
In order to simplify the model and facilitate analysis and understanding, we put forward the following assumptions during the model establishment process: Assumption 1, in the decision-making process, always keep gold as a trading termination period of 2 days and a trading cycle of 5 days, without considering the interference of other factors on the trading cycle.
Assumption 2, when traders make trading strategies, according to the research of statistics and decision theory, we have unified the attitudes of different traders towards risk into three types: conservative, aggressive and ordinary. The definition of the three personalities is explained in detail in 4. Therefore, other human subjective factors are not considered. Assumption 3, market traders do not buy and sell the same commodity on the same day during the trading process. And the investment habits of market traders will not change at will. Assumption 4. During the transaction process, the transaction will not fail due to other objective factors.

Notations
The key mathematical notations used in this paper are listed in Table 1. The gold standard deviation obtained based on the data of the Nth day before k The standard deviation of Bitcoin obtained based on the data of the Nth day before k The average gold obtained based on data from the N days before k The average bitcoin is obtained based on the data of the Nth day before the kth Day K gold trading volume Bitcoin trading volume on day k

Data Cleaning
The data used to build the models in this study are all provided by traders and include five years of data from September 11, 2016 to September 10, 2021. The bitcoin value here represents the price of a single bitcoin in dollars on the indicated date. There are a total of 1826 data about bitcoin in the data set. The price data of gold is the price of a troy cup of gold in U.S. dollars on the indicated date.
There are 1255 data about gold in the data set. By observing the data in the dataset, it is not difficult to find that gold has a 5-day trading cycle every 2 days. However, there are certain data missing in the data set of gold prices provided by traders, and the date format in the table is not uniform. A total of 50 missing values were screened out by processing through an excel sheet.
Therefore, in the data cleaning part, the supplement of missing values of gold prices and the unification of the table date format are carried out. First, we used SPSS 23.0 to supplement missing values, and performed "Replace Missing Values" through the "Transform" menu, and the replacement standard was "Linear Trend of Adjacent Data". Second, the data date format in the table is unified as (year/month/day). The supplementary missing values are shown in Table 2. Finally, we can get the value data of 1826 bitcoins and the price data of 1305 gold, and use these data to build the model and calculate the results.

Descriptive Statistical Analysis
In this section, a descriptive statistical analysis is performed on the complete 1826 bitcoin value and 1305 gold price data obtained from the cleaning. By calculating the mean and variance these two simple statistics are shown in Tables 3 and 4  The average of simple arithmetic is calculated in Table 3. In statistics, the average of simple arithmetic is often used to represent the average level of a set of data. From the mean fluctuations in Table 3, we can roughly judge that the value of Bitcoin is rising rapidly, almost doubling in value between 2017 and 2018, but falling sharply between 2020 and 2021. Bitcoin prices are volatile. And in terms of the value of a single bitcoin, the value is higher; for gold, its price volatility and price are lower than bitcoin. Therefore, traders should fully consider these factors when specifying a trading strategy.  Table 4 shows the variance calculated for the data in units of years. Variance can effectively reflect the changes within a set of data. First of all, the variance of Bitcoin is very large, and the variance of Bitcoin is very large, all greater than 2000; in contrast, the variance and variance of gold are much smaller. To sum up, it can be roughly considered that Bitcoin has more uncertainties and higher risks in the transaction process, but gold is more stable in comparison. Combining Table 3 and Table 4, it can be proved that the sentence, "behind high returns is high risk".

Visualization Analysis of Sample Data
In this section, the sample data for gold and bitcoin is plotted by year, as shown in Figure 1. Visually more intuitively feel the fluctuations and changes in the price and value of two financial assets in the financial market.   The first setting: Forget gate The role of Forget gate is to control the proportion of information that cells selectively forget, the input is the output of the previous moment and the input of the current moment, and the value processed by the function is 0 to 1, where 1 means all retention, and 0 means all forgetting.
(1) The second setting: Input gate The role of the Input gate is to calculate what information remains in the state unit. The function of the expression xxx can represent how much of the current input information can be finally determined to be saved to the cell state.
= ( ℎ −1 + + ) (2) The function of the expression xxx represents adding new information generated by the current input to the cell state. � = ℎ( ℎ −1 + + ) (3) For Cell, the cell state at the current moment consists of the product of the forgotten gate input and the state of the previous moment plus the product of the two parts of the input gate, as follows: = ℎ( * −1 + * � ) (4) Third setting: Output gate The role of the output gate is to determine how much information is output. The function first learns what information is to be output, and then multiplies the output information by the unit state at the current moment and outputs it through the function.
function and ℎ function, are as flows:

Figure 3. function and function
The above is the construction and calculation method of the LSTM internal network. For sequential data, because it is time-series, that is, the previous data has an impact on the later data, the memory of LSTM can be suitable for prediction scenarios. Then, read in Bitcoin price and gold price data from 2016 to 2021 for LSTM forecasts.
Step 1, Process the dataset and ordinaryize the data to between 0 and 1.
Step 2, Construct data characteristics, the model uses the price of the previous 2 days to predict the price of the current day, and build the dataset.
Step 3, Divide the dataset into training sets and test sets in a 3:1 ratio.
Step 4, Build LSTM. LSTM is divided into two layers: one is LSTM and the other is linear, mainly the forward propagation part.
Finally, 2000 times were trained using Adam, and the results shown in Figure 4. and Figure 4. were obtained, where red is the predicted data and blue is the real data.

Trading function construction and calculation
In this section we use a linear programming model to determine the trading strategy. Linear programming is a more classic programming model in operations research, because its objective function and constraints are linear functions, so it has the advantage of being easy to analyze and easy to solve. In particular, we can also linearize nonlinear problems in practical problems.
[7] Therefore, the choice of trading strategy using linear programming ideas in the text is very reliable.
When formulating a trading strategy in economics, factors such as investment risk, expected returns and personal habits need to be fully considered. In this article we measure investment risk using the variance of historical data and calculate the expected return using the forecasted value. As for personal habits, statistics roughly divides decision-makers into aggressive, conservative and ordinary types. Based on the above discussion, we can get the following formulation principles.
= ℎ eight of gold * Expected profit of gold + The weight of bitcoin * Expected benefits of bitcoin + The weight of cash * Expected income of cash where cash weighting is a measure of investment habits. In order to get the weights of gold and Bitcoin in the formula, the respective price mean and price standard deviation of gold and Bitcoin is calculated based on the data of N days before day K, are as follows: After calculating the mean and standard deviation of the price of gold and Bitcoin, we use the mean and standard deviation to calculate the weight values of gold, Bitcoin and reserved cash ( , , ) respectively, and the calculation formula is as follows: Among them, C (0 < < 1) represents investors ' investment habits. We picked values of C as 0.4, 0.2 and 0.1 for conservative investors, ordinary investors, and aggressive investors, respectively.
Then, combining the trading volume of gold and Bitcoin to get the expected return on gold and Bitcoin, the formula is as follows: (12) Finally we can easily get the expression of the trading function:

Constraints
In fact, in addition to the trading function according to the target, in the real trading decision, the interval between the total asset situation and the commission should also be considered. Since gold is not traded every day, we introduce the following 0-1 variable to characterize the gold trading cycle.
We then give the formula for calculating the total assets that can be traded on the kth day = + + (15) Finally, combined with the total assets and commissions on the kth day, the following restrictions are obtained, which is the maximum amount of gold (Bitcoin) can be purchased on the (k+1th) day.

Solution of optimal trading strategy models
In this section, combining trading functions and constraints, the optimal trading strategy can be expressed as: The final solution based on the Matlab software yields the capital position of the three types of market traders as of September 10, 2021 as shown in Table 5.

Proof of model optimality
In this section, we need to prove that the strategy made in 4.1 is the optimal strategy. Two aspects of the 4.1 solution that are extremely important are the predicted outcomes and the assessment of risk. Furthermore, the results of the prediction are closely related to the forecasting method, and the selection of N in the risk assessment is crucial. Therefore, in order to verify the optimality of our results, we will discuss prediction method and the selection of N separately. (N refers to the days of forward reference)

Time series forecasting
Time series is a statistical analysis method commonly used for series data with certain volatility and time series. For comparison with LSTM predictions, here we select two commonly used comparison indicators, MAE and MSE. Based on the final results (see Part V for details): The results obtained by using LSTM models for prediction are more realistic. In summary, the decision-making model established by 4.1 is better in the choice of prediction methods and the feasibility of prediction results is higher. In particular, the fitted graphs of the true and predicted values obtained by using time series predictions on Bitcoin and gold are charts, respectively. Readers can see that the fit is poor compared to LSTM predictions.

Proof of optimal decision-making
In 6.1.1, LSTM predictions proved to be a better approach. In this section, we adjust the value of N to change the risk factor to get the best return results for investors of three different personalities as shown in the figure below: (e) (f) (g) Figure 8. optimal strategy for ordinary (e), aggressive (f) and conservative(g) Investors In summary, the model established in 6.1 selects a better forecasting method, and at the same time can obtain the N value of the trader who achieves the optimal decision of the three types of decisions meaningfully, so it is believed that the decision made by the decision model in 6.1 is the optimal decision.

Sensitivity analysis for commission percentages
The percentage of commissions and in the actual question of the transaction amount will change over time. Therefore, in order to make our model more realistic, in this part we will do a sensitivity analysis of and to get the sensitivity of the trading strategy to transaction costs.

Sensitivity analysis results
Consider the following trading optimal trading strategy model: . Adjusting and to make them float within the range of 20 % above and below, and substituting them into the optimal transaction decision model established in 4.1, the results are shown in the form of three-dimensional graphs. The X axis and Y axis in the figure represent the fluctuation of the 20% commission ratio between Bitcoin and gold, and the Z axis represents the commission ratio according to the floating.  From the three graphs, we can clearly see that the optimal return obtained when and float in the range of 20% above and below the result of question one does not exceed 0.4%. And the three types of decision makers, in the face of the commission ratio adjustment process to make a more real response. Therefore, our results have strong stability. This completes the sensitivity analysis of transaction costs.

Testing the Model
The model test in this paper is mainly to test the prediction effect of the two prediction models in the text. The two forecasting models are the LSTM model in 6.1.1 and the time series model in 6.2.1.
Here we compare the pros and cons of the model through the calculation of MSE and MAE. Among them, the comparison principle of the two indicators is: the smaller the indicator value, the better the model. The MSE and MAE calculated using the predicted values of the LTSM and time series models, respectively, are shown in Table 7. It can be clearly seen that both the MAE and MSE indicators show that the LSTM model is better than the time series model when it comes to forecasting gold and Bitcoin. The superiority of the LSTM model also echoes in Section 6.2, which is used to prove the superiority of the model built in 6.1. Make several parts of the article model appear more related

Memorandum
The optimal decision and decision results obtained through the establishment of the model are shown in three forms, representing the results of the attitudes of the three decision makers. (In the table below, the date is represented in the format (month/day/year)). The values in the following table are the optimal policy points calculated by the model.