Frontiers in Business, Economics and Management ISSN: 2766-824X | Vol. 4, No. 3, 2022 72 Bitcoin or Gold? -- A Financial Investment Model Based on LSTM Dongxue Han, Mingliang He, Longyu Wang Chengdu University of Technology School of Earth Sciences, Sichuan 610059, China Abstract: In the topic selection, we need to estimate the prices of bitcoin and gold according to the data given from 2001 to 2012. According to the estimated price, the initial amount is set as $1000, which is used as the principal for financial investment for a period of five years from 2016. In the whole modeling process, the main problems we need to solve are the following four points: the task 1 is the best investment strategy is given through the established model, and the investment value on October 9, 2021 is calculated. The task 2 is the best strategy of the model is proved. The task 3 is Determine the impact of transaction costs on transaction results. The last task is to Complete a memo with strategies, models, and results. In the whole modeling process, we first preprocess the data, which is arranged and classified in chronological order, and fill the data by interpolation fitting. LSMT algorithm is a neural network algorithm, which is suitable for the calculation of various long-term processes. The investment problem we study is a good application field. In the calculation process of the basic model, it is necessary to set the initial value, complete a series of processing, and process the hidden layer of LSTM unit. Take x as the output value, set the temporary hidden layer and new hidden layer, and verify that the size of the final output result is consistent with the label size. The hidden layer is transformed according to the sigmoid function proposed above. After calculating the hidden layer conversion, the error is back propagated, the input derivative of the file is obtained, and the overall error and record hidden layer are obtained. Then the calculated hidden layer difference is used to calculate the change of parameters and update parameters. Since bitcoin can be traded on any trading day, gold can only be traded on weekly trading days. For the convenience of calculation, we fix the transactions of bitcoin and gold as trading days every Friday. After receiving the benefits, the total assets of the cash flow as of the trading day are obtained by deducting the Commission to be paid. However, the model ignores the impact of bitcoin mining with different software and the fact that gold and bitcoin are not fixed on the same trading day, so there will be errors. Keywords: LSTM, Dynamic Programing, The Score of Buying. 1. Introduction In order to indicate the choice between bitcoin and gold, the following background is worth mentioning. 1.1. Development History 1.1.1. The Bitcoin The concept of bitcoin was put forward in 2009. After publicly providing the computing program of bitcoin, it has been pursued by many computer enthusiasts. Bitcoin is a computing program based on computer hardware, which is determined by evaluating the ratio of the contribution of miners to the contribution of all miners compared with the contribution of bitcoin manufacturing in a certain period of time. 1.1.2. The Gold Gold trading is the trading method with the lightest tax burden in the world. If there are gold trading businesses in commodity exchanges, represented by the New York Mercantile Exchange (Comex) and Chicago Mercantile Exchange (IMM), it can be called American gold trading. 1.2. Income Mode 1.2.1. The Bitcoin In terms of current development, bitcoin's revenue modes are divided into the following five types: PPS / PPLNs / PPS + / FPPS and solo. PPS The PPS mode is calculated according to the effective workload submitted by the miner in hand. The calculation formula is: revenue = block reward * workload / current network difficulty. In essence, the computational power is sold to the ore pool. No matter whether the ore pool can dig blocks or not, it will pay some theoretical income. PPS mode is the mode most people choose, and the income is stable. PPLNS PPLNs mode is to pay the income according to the past n shares, and we say that the currency of the block is allocated according to the number of shares contributed by each person. In PPLNs mode, the element of luck is very important. If multiple blocks can be found in the mine pool one day, everyone can receive a lot of dividends. On the contrary, there is no benefit. PPS+ PPS mode and PPLNs mode are combined to conduct PPS settlement for the procedures of bitcoin burst, and the transaction handling fee is calculated according to PPLNs mode. FPPS It refers to complete PPS, and the theoretical transaction fee income in this process is settled according to PPS. SOLO It means that miners dig independently. If the block explodes, the miner will be rewarded with all the blocks (after deducting the mining fee of the ore pool). If there is no explosion, there will be no profit. 1.2.2. The Gold The profit model of gold is relatively simple, which is mainly divided into long-term operation, medium-term operation and short-term operation. 73 Long line operation For gold, a precious metal with large price fluctuation, the profit model of long-term operation is generally not adopted. The risk of investment is high. Midline operation A middle line can have a position of 5%. Calculated according to the current gold market, you can harvest a certain amount of funds during each middle line operation. Short term operation As the average fluctuation of gold is between $10-20, there is a large profit space, and the trend is difficult to be artificially controlled. You can combine the resistance level and support level of gold for intraday operation to control the position. 1.3. Development Space 1.3.1. The Bitcoin Economists hold different opinions on the development of bitcoin. Bitcoin will face many difficulties while realizing the vital means of "Circulation". And according to the initial program setting, the total amount of bitcoin is 21 million. With the increase of the number of miners, the output efficiency of bitcoin will be reduced, and it will be more difficult to obtain bitcoin through mining. 1.3.2. The Gold The development of gold has been greatly impacted by the US dollar, but the development is relatively stable and the tax is the least. 1.4. Influence Factor 1.4.1. The Bitcoin Compared with traditional assets, the production and issuance mechanism of bitcoin is very special. The price level of bitcoin is prone to huge fluctuations in a short time. And there are many influencing factors. According to the research results of researchers on the influencing factors of bitcoin price in recent years, the influencing factors are divided into self factors and macro factors. Among them, the self factors are supply-demand relationship factors and operation efficiency factors, and the macro factors are financial market conditions and investment attraction. 1.4.2. The Gold The main factor affecting the price of gold is the relationship between supply and demand. As long as the supply exceeds the demand, the price of gold will decrease, otherwise it will rise. And in the short term, if the selling pressure is too large and the power of short selling is concentrated, it is easy to fall under pressure. On the contrary, it will rebound upward. 2. The Description of the Problem 2.1. What Are Our Tasks? Task1: The best investment strategy is given through the established model, and the investment value on October 9, 2021 is calculated. Task2: The best strategy of the model is proved. Task3: Determine the impact of transaction costs on transaction results. Task4: Complete a memo with strategies, models, and results. 2.2. How Do We Approximate the Whole Investment Process? Preprocess the data, including interpolation, division and conversion. Then, according to the existing data, analyze the data, calculate the price trend and test the correlation coefficient. Based on the existing models, a model is established to predict the price. Calculate the best return based on the principal of $1000. 2.3. How Do We Define the Optimal Choice? 1) In terms of daily price: According to the daily price of gold and bitcoin, choose the one with the highest price to buy. And throw out the existing content according to the predicted trend. 2) Investment risk When the price is equal or very close, take the stability of the price as the risk prediction index, and choose the one with relatively stable price to buy. 2.4. The Local Optimization and The Overall Optimization The overall optimization: From the perspective of the overall optimization of the price of gold and bitcoin, this paper constructs a three- dimensional price system optimization model, discusses the optimization methods of two typical investment currencies under the background of the global epidemic based on the LSTM model, and optimizes the whole price estimation model according to the principle from subsystem to overall system. The local optimization: As the price of bitcoin is affected by many external factors, its price fluctuates more obviously than gold. According to the autocorrelation model of bitcoin, the price of bitcoin should be locally optimized to make its change more flexible. 3. Models 3.1. Basic Model---LSTM Because the whole investment process can be long-term operation, short-term operation, etc. Therefore, when forecasting the price of bitcoin, the model based on LSTM network is used to simulate the price of bitcoin in the five years from 2016 to 2021. LSTM model is a special model that can learn long-term laws. It was first proposed in 1997 and has been refined and popularized in subsequent use. The application of LSTM model in many problems is very good. And the LSTM model clearly aims to avoid the problem of long-term dependence. In this recurrent neural network, it has the form of neural network repeated module chain, and the repeated module will have a relatively simple structure. Figure 1. The repeating module in a standard RNN contains a single layer 74 3.1.1. Terms, Definitions, Symbols and Explanation The structure of LSTM is the same as that of recurrent neural network, which is a chain link. However, during the internal input and output of information, the number of transmission states is changed. Each storage unit of LSTM is composed of forgetting part, input part and output part. Sigmoid function is the control unit of each part. When the function value is 0, all information is discarded, and when the function refers to 1, all information is left. Here, mf and bf are used to represent the weight and offset of the discard state. In the saving part, first of all, the input information should be selectively saved, and the proportion of important information is large. For unimportant information, you can appropriately choose to give up part. Tanh function is selected when the information can be output. In the output structure part of the function, it mainly controls whether the amount information obtained can be output as the current state, which is controlled by tanh function. The information state can be zoomed out relative to the information in the storage state. The formulas used in the calculation output part are: 3.1.2. Calculation Basis The calculated duration is from September 11, 2016 to September 10, 2021 The initial capital is $1000. The Commission for each transaction (purchase or sale) is% of the transaction amount α%. hypothesis α Gold = 1%, α Bitcoin = 2%. There is no cost to hold assets. 3.1.3. The Foundation of Model Software used: MATLAB Step1: Enter the derivative and get the overall error and record hidden layer. Read the excel table file of the given bitcoin date and value for data import, create a new script file in MATLAB, set the initial value, complete a sequence of processing, and process the hidden layer of LSTM unit. Take X as the output value, and set the temporary hidden layer and new hidden layer to verify that the dimension of the final output result is consistent with that of label. The hidden layer is transformed according to the sigmoid function proposed above. After calculating the hidden layer conversion, the error is back propagated, the input derivative of the file is obtained, and the overall error and record hidden layer are obtained. Figure 2. Calculation flow of the first step Step2: The calculated diff of the hidden layer is used to calculate the change of the parameters and update the parameters. The error is back propagated and the diff of the hidden layer and parameters are calculated. And infer the diff of the previous hidden layer according to the diff of the hidden layer of this layer, so as to complete the back propagation of the two hidden layers. Figure 3. Calculation flow of the second step 3.1.4. Existing Data Analysis The data in the given document is the bitcoin price and gold price from 2001 to 2012. The trend statistical line charts obtained after sorting and classification are as follows: 75 Figure 4. Statistical chart of bitcoin price trend Figure 5. Statistical chart of gold price trend 3.1.5. Profit Calculation Since gold trading is 7 × The 24-hour trading time limit is generally set to open and close positions of bitcoin every Friday, while the trading day of bitcoin can be every day. Here, for the convenience of calculation, the trading days of gold and bitcoin are set on Friday of each week. Because every time you trade bitcoin or gold, you have to pay a commission. The commission paid shall be deducted from the total assets. When selling this week's handheld currency for financial investment next week, compare the forecast trend of next week. The predicted prices of bitcoin and gold next week are predicted using LSTM model, and the average value is taken as the price prediction next week, and then compared. At the same time, when calculating the weekly benefits, it should be noted that the commission paid should be deducted and obtained after repeated comparison. Here, C represents the cash in hand every week, and the shareholding in hand every week can be invested as principal. Where G is the real value corresponding to the gold in hand and B is the real value corresponding to the bitcoin in hand. And the initial value of C is $1000, and the initial values of G and B are 0. 3.1.6. Solution and Result 1) The solution of the choice: On September 11, 2016, he bought gold with us $1000, sold it on September 6, 2017, bought all bitcoin. Until September 7, 2021, all gold was sold and no further buying was made. 2) Results: 11841.766 dollars 3.1.7. Analysis of the Result This model is only applicable to gold and bitcoin trading on a weekly basis in the same trading cycle. The revenue of bitcoin is not only related to the mode of operation, but also related to the mining software, network emotion and the policies of various countries for bitcoin. The model can’t adopt different mining websites and business methods. 3.1.8. Strength and Weakness Strength: In despite of this, the model has proved Investment mode. Different initial investment results can be calculated simply. Weakness: This model is only applicable to gold and bitcoin trading on a weekly basis in the same trading cycle. And the revenue of bitcoin is not only related to the mode of operation, but also related to the mining software, network emotion and the policies of various countries for bitcoin. For example, in September 2017, China's regulatory authorities characterized the ICO market as illegal fund-raising and issued the prohibition policy of cryptocurrency. As of October 31 of that year, all in China had proposed, as we said. This is exactly what we should do in improving the model. 3.2. Improved Model 3.2.1. Additional Assumptions Adopt different mining websites and business methods. Gold and bitcoin are not traded on the original hypothetical gold trading day, but traded separately. Bitcoin still follows that every day is a trading day, while gold follows every Friday. Assumptions concerning the anterior process are the same as the Basic Model. 3.2.2. The Foundation of Model How do we determine the optimal choice? As we have concluded from the Basic Model, according to the daily price of gold and bitcoin, choose the one with the highest price to buy. And throw out the existing content according to the predicted trend. Besides, we also consider the When the price is equal or very close, take the stability of the price as the risk prediction index, and choose the one with relatively stable price to buy. We should even consider that when trading, we should not only consider one way of selling, but also two ways of buying and selling at the same time. 3.2.3. Solution and Result 1) Functional assumptions that the algorithm can achieve ① Be able to take into account the impact of different mining websites, and give which website should be selected in the corresponding period in order to obtain the maximum profit. ②Be able to complete the work of buying and selling bitcoin and gold in the same period, and realize the investment method of "not putting eggs in one basket". 3. Be able to make a simple prediction of the possible risks. Based on the analysis above, we design our simulation arithmetic as follows. Step1: The initial funds are allocated in different proportions into two parts A and B, which are opposite to the operation profit calculation model. Finally, add the results of parts A and B. Step2: Summarize the various factors affecting the price of bitcoin, and calculate the correlation coefficient with the price respectively. And draw the corresponding scatter diagram to compare the influence degree Step3: Using LMST model to estimate price. Step4: The final method is give 2) Algorithm thought flow chart 76 Figure 6. Algorithm thought flow chart 3.2.4. Analysis of the Result The improved model can complete simple profit prediction and give the investment scheme The improved model is still incomplete for risk prediction. The improved model can’t complete the complex investment operation of multi-channel and multi purchase. 4. Conclusions 4.1. Conclusions of the Problem On September 11, 2016, he bought gold with us $1000, sold it on September 6, 2017, bought all bitcoin. Until September 7, 2021, all gold was sold and no further buying was made. 11841.766 dollars 4.2. Methods Used in Our Models Correlation coefficient method Classification calculation method Neural network method comparative law 5. Future Work 5.1. Policy Risks Cannot Be Avoided Whether it is bitcoin or gold, in addition to the factors that can be calculated, the policy factors are difficult to estimate and change rapidly. At the same time, this affects an important aspect of investment profit, but our model is difficult to predict this aspect. 5.2. Bitcoin Mining Software With the development of the Internet and the increase in the number of Internet users, the development of bitcoin has gradually accelerated. However, it may be due to network sentiment, government policies and other reasons. The development results of bitcoin are difficult to estimate, so the total assets are difficult to fix. 5.3. Buy and Sell More at The Same Time After the funds reach a certain condition, large-scale long- term or short-term two currencies can be purchased at the same time. However, because our model is relatively simple, it is difficult to get accurate results in calculation. References [1] Jing Pengfei Comparative study on bitcoin price prediction based on multi model [D] Shanxi University, 2021 DOI:10.27284/d.cnki. gsxiu. 2021.000592. [2] Grullon G, Ikenberry D L. What do we know about stock repurchases[J].Journal of Applied Corporate Finance, 2015,13(1):31-51. [3] Hakan Y.Testing the relationship between daily Bitcoin and gold prices: 2012-2013 Johansen Cointegration Test[J]. insan ve Toplum Bilimleri Arastirmalar1 Dergisi,2018,25(4):16-32. [4] Cheng C H, Chen T L, Wei L Y. A hybrid model based on rough sets theory and genetic algorithms for stock price forecasting[J]. Information Sciences, 2010,180(9):1610-1629. 77 [5] Wu K,Peng B, Xie H,et al. A Coefficient of Variation Method to Measure the Extents of Decentralization for Bitcoin and Ethereum Networks[J].InternationalJournal of Network Security, 2020,22(2):191-200. [6] Chen Zhei. Research on the influencing factors and prediction methods of Bitcoin price [D]. Harbin Institute of Technology, 2021.doi: 10.27061 / D.cnki.ghgdu.2021.000149. [7] Hongyang, Wang Li Song, Ge Chunpeng.Research on Mining Strategy and Yield of Bitcoin Platform [J] .Journal of Nanjing University of Information Science (Natural Science Edition), 2019, 11 (05): 532-540.Doi: 10.13878 /j.cnki.jnuist.2019.05.004. [8] Xiong Wei. Research on the dynamic optimization of energy price based on dynamic CGE [D]. North China Electric Power University (Beijing), 2014. [9] Meng Lili, Zhang Bohan. Primitive Risk Prediction and Control Based on Multi - linear Regression [J]. Green Technology, 2021,23 (16): 263-265 + 269.DOI: 10.16663 / j.cnki.lskj.2021.16. 070. [10] Padungsaksawasdi Chaiyuth. On the dynamic relationship between gold investor sentiment index and stock market:A sectoral analysis[J]. International Journal of Managerial Finance,2019,ahead-of-print(ahead-of-print):