Study on the optimal investment strategy based on single target PSO

. With the development of science, technology and popularity of electronic transactions, quantitative investment transactions have become the focal point in the field of investment. In order to maximize returns during the investment period, we will build a single-objective PSO-based decision model based on asset price trend forecast data to develop a daily investment strategy. At first, we use price volatility as a risk factor and determine the risk level in combination with the application principle of ROC. Then, combined with the prediction results, we distinguish the gold market trading days and non-trading days, establish a single-objective programming model with the maximum daily net income as the goal. Finally, we use PSO algorithm to optimize the solution process. And we can get the daily optimal investment strategy and the final asset is $ 226648.42.


Introduction
With the rapid development of the global capital market and the gradual improvement of the income level of residents, the capital market has attracted more and more investors. And investors might choose appropriate assets to invest according to their risk preferences, operational preferences and so on [1,2]. Meanwhile, with the development of science and technology and popularity of electronic transactions, quantitative investment transactions have become the focal point in the field of investment all over the world by virtue of the ad-vantages of market size, high investment returns and moderate risks, etc.
As financial assets with large price fluctuations, gold and bitcoin are often favored by some market traders. In order to maximize investment returns, market traders will choose the optimal investment strategy. However, some investors have irrational speculative tendencies in the transaction, blindly chasing after the rise and killing the fall, resulting in serious losses [3]. Therefore, if we can use technical means to predict the daily price trend of financial assets, provide reference for investors' investment strategy to enhance returns, it is of great significance to the healthy development of the capital market.

Model assumptions and notation 2.1 Assumptions
Assumptions 1: We assume that there is no major turmoil or collapse in financial markets during the investment period.
Assumptions 2: We assume that the investment strategy and related laws of gold and bitcoin remain unchanged during the investment period.
Assumptions 3: We assume that investment decisions of investors during the investment period are only related to daily prices and risk preferences and are not affected by individual preferences.

Notations
Important notations used in this paper are listed in Table 1.

Gold and Porter Coin Price Forecast
In this paper, we use the prediction performance of the improved stochastic forest algorithm to make predictions, and the overview of the predictions is shown in Figure 1. Firstly, Calculate the variance of the distance between each prediction point and the actual point of each decision tree on the training set, which is used as the error of the decision tree and its reciprocal.
Secondly, the reciprocal of each decision tree error is divided by the sum of the reciprocals of all decision tree errors and fixed as the weight of the decision tree.
Finally, Obtain the final prediction results by weighting according to the output results of each decision tree. The weight formula is expressed as follows.  unstable in the prediction and the corresponding weight of the decision tree is smaller. When 2 () i  is smaller, it indicates that the decision tree is relatively stable in the prediction and the corresponding weight of the decision tree is larger.
Meanwhile, the weighted parameters satisfy normalization.
At first, we resample the sample set using bootstrap method and randomly generate k training sets 12 , , , k    , then, generate further decision trees based on k training sets Secondly, we randomly generate a features from all A features and make them as the feature set of the current decision tree splitting. The splitting method selects the optimal splitting method of these A features, so that it can grow to the maximum extent.
Thirdly, calculate the variance of the distance from all the prediction points to the actual point in the decision tree when training the i decision tree.
Finally, the predicted value of random forest regression algorithm is expressed as.
Where i Y is the predictive value of the i decision tree. According to the requirements of the problem, the data available in the formulation of the daily optimal investment strategy are only the daily prices of the day and before [4]. Therefore, when we use Python to implement Price Prediction Model Based on Improved Random Forest Algorithm, we add a loop program and constantly update the prediction data, making the prediction value more in line with the requirements of the problem and reality. The schematic diagram of the forecast results is shown in Figure 2 and Figure 3.

Investment Strategy Decision Model Based on Single-objective PSO
In order to solve the optimal return as of October 9, 2021 under the premise of given initial investment amount, it is necessary to give the optimal investment strategy per day according to the prediction results obtained by Prediction Model Based on Improved Random Forest Algorithm. Our paper establishes a Investment Strategy Decision Model Based on Single-objective PSO (Particle Swarm Optimization) [5].

Constraint Conditions
(1) Bitcoin and gold must be sold less than or equal to their holdings.
(2) Trading return must be greater than transaction cost.
(3) The purchase value of bitcoin and gold must be less than or equal to the total assets of the day of the investor.

Objective Function
(a) Risk factor Different investors have different risk preferences, risk is an important factor affecting investor decision-making. Therefore, our paper takes risk factor into account in our model. In the investment market, the main indicators to measure the risk of financial assets such as stocks are β coefficient, price volatility, Sharpe index, etc. Considering the requirements of the problem and the availability of data, our paper uses price volatility to measure investment risks.
Price fluctuation refers to the change form of daily price of financial assets, which shows the fluctuation state of the opposite small trend movement in the main trend. There are three main trends in stock price volatility: upward trend volatility, downward trend volatility and no trend volatility. The main reason for price fluctuation is the change in the supply-demand relationship of financial assets. The factors that change the supply-demand relationship of financial assets mainly come from politics, economy, finance and market and so on. Our paper uses ROC to represent price volatility to measure investment risk.
The rate of change indicator (ROC) is based on the comparison between the closing price of the day and the closing price n days ago. By calculating the proportion of the closing price changes of the stock price in a certain period of time, the price momentum is measured by the moving comparison of the price, so as to detect the strength of the supply and demand forces of the stock price in advance, and then analyze the trend of the stock price and its willingness to change [6].
The application principles of ROC in investment strategy are as follows [7,8]: (1) ROC fluctuates in the ' normal range ' and should sell financial assets when it rises to the first overbooking line. When falling to the first hypermarket, financial assets should be bought.
(2) After ROC breaks through the first Over-Bought line upward, it is very likely that the index will continue to rise towards the second Over-Bought line. When the index touches the second Over-Bought line, the increase will mostly end.
(3) After ROC drops below the first Over-Sold line, the index is likely to continue to fall toward the second Over-Sold line. When the index touches the second Over-Sold line, the decline will mostly stop.
(4) When ROC crosses the third Over-Bought line upward, it belongs to a crazy bull market and should not sell financial assets as easily as possible.
(5) When ROC crosses the third Over-Sold line downward, it belongs to a devastating short market and should refrain from buying financial assets easily.
Based on the empirical results of relevant literature on investment using ROC, our paper sets three risk levels according to different application scenarios, and gives the corresponding value to the risk factor  , which is included in the programming model.
(b) Single-objective programming We can know that bitcoin can be traded every day and gold can only be traded in a specific trading day. According to the above prediction results, we establish a single objective programming model when the gold market does not trade. The objective function and constraint conditions are as follows.
When the gold market is traded, we establish another single-objective programming model. The objective function and constraint conditions are as follows.
Where, a = predicted gold price of tomorrow, b = gold price of today, c = current gold holdings, d =predicted bitcoin prices of tomorrow, e =bitcoin price of today, f = current bitcoin holdings, w = current total assets, 1 x = the buying volume or selling volume of gold, 2 x = the buying volume or selling volume of bitcoin.
After calculation, the daily gold, bitcoin trading volume, which can calculate the day total assets w . Among them, current total assets = total assets of yesterday + net income of today.

Model Solving
In order to optimize the solution process, this paper uses PSO (Particle Swarm Optimization) algorithm to solve the programming model. PSO uses a simple mechanism to imitate bird foraging behavior to guide particles to move in the solution space, so as to achieve the purpose of searching the optimal solution of the optimization problem [9].
The PSO algorithm first initializes a group of particles in the feasible solution space, and each particle represents a potential optimal solution of the extreme value optimization problem. The particle characteristics are represented by three indicators: position, velocity and adaptive value. Particles move in the solution space and update individual positions by tracking personal best ( Pbest ) and group best (Gbest).
Personal best refers to the optimal position of adaptive value calculated in the position experienced by individuals. Group best refers to the optimal position of adaptation degree searched by all particles in the population. Each particle updates its position, the adaptive value is calculated once, and the position of Pbest and Gbest is updated by comparing the adaptive value of new particles with Pbest and Gest [10]. The schematic diagram of PSO algorithm is shown Figure 4. ( ) Where 1 in ,1 dD  (b) Evaluate the adaptation degree of each particle For each particle, the adaptation degree is compared with the adaptation degree of the best position (Pbest) passed by the individual. If it is better, it is regarded as the current best position. The definition of Pbest is as follows.
For each particle, the adaptation degree is compared with the adaptation degree of the best position (Gbest) passed by the population, and if better, it is used as the best position for the current population. The definition of Gbest is as follows.
(c) Optimal solution search According to the following formulas, adjust the particle velocity and position. The position of particles will change with iteration, so the optimal solution searched in particle motion is stored in Pbest.
where, 12 2 cc == in Formula 9, which is called as acceleration coefficient, 1 r and 2 r are two random variables that obey uniform distribution in the interval [0,1], which are called learning factors.
And in formula 16,  is a linear decreasing variable called inertia weight. Since no data are available for forecasting the first day of the investment period, we set the investment period in the decision model for the first 30 days without investment. And we set the initial investment ratio of 4 : 6 ( Gold : Bitcoin ).

BCP Business & Management
We use Python to implement the model. The daily trading strategy diagram of gold and bitcoin is shown in Figure 5. We know that the total assets of the trading strategy developed using our model were $226648.42 on September 10, 2021.

Profitability
In order to prove that the investment strategy established in our paper is optimal, we changes the original investment proportion and substitutes the proportion of different initial values into the decision-making model to obtain the daily investment decision under each proportion and the final assets on October 9, 2021. And we compare the final assets in different situations, as shown in Figure  6.

Robustness
We adjust the initial investment amount to $2000 and compare the final assets obtained by different initial investment ratios again. When the initial investment ratio is gold : bitcoin = 4 : 6, it is still significantly better than other investment strategies, which proves that Investment Strategy Decision Model Based on Single-objective PSO proposed in our paper is robust. The comparison of finals assets in different situations is shown in Figure 7.

Sensitivity Analysis
In order to evaluate the sensitivity of Investment Strategy Decision Model Based on Singleobjective PSO to transaction costs, our paper adjusts the transaction costs of gold and bitcoin respectively. Then, we use our model to solve it to obtain the optimal invest-ment strategy and final assets under different transaction costs.
Firstly, we set that each transaction costs 0.01 of the gold amount traded and take the bitcoin transaction cost as 0.01, 0.02, ……0.19, 0.2 of the amount traded respectively. Then, we adjust the constraint conditions and objective function, and use particle swarm optimi-zation algorithm to get the corresponding daily optimal investment strategy and obtain the final total assets. The results are shown in Figure 6.
Secondly, we set that each transaction costs 0.02 of the bitcoin amount traded and take the gold transaction cost as 0.01, 0.02, ……0.09, 0.1 of the amount traded respective-ly. Then, we adjust the constraint conditions and objective function, and use particle swarm optimization algorithm to get the corresponding daily optimal investment strategy and ob-tain the final total assets. The results are shown in Figure 8.
According to the results, when the gold transaction cost remains unchanged, each transaction costs increases form 0.01 to 0.1 of the bitcoin amount traded, resulting in a decrease of $ 270048.1 in total assets to $ 143642, a year-on-year decrease of 46.81 %. When bitcoin transaction costs remain unchanged, each transaction costs increases form 0.01 to 0.1 of the gold amount traded, resulting in a decrease in total assets from $ 252424.7 to $ 20090.77, a decrease of 92.04% per cent year on year.
Therefore, the optimal investment strategy and investment income formulated by Investment Strategy Decision Model Based on Single-objective PSO in our paper are significantly affected by transaction costs.

Conclusion
We establish Investment Strategy Decision Model Based on PSO to make the optimal investment strategy according to the forecast data of daily price of financial assets. Considering that investors have risk preference, we quantify ROC as a risk factor and incorporate it into the objective function and constraint conditions, making the model more realistic. In addition, we use PSO algorithm to solve the single-objective programming model, which improves the accuracy of strategy formulation. We evaluate the model which we established. For Prediction Model, the fitting degree is good and R 2 is as high as 0.997. Decision model is more realistic. We consider risk factors in investment decision, making the model closer to reality.
Comprehensive application of multiple methods. We use Price Prediction Model Based on Improved Random Forest Algorithm to predict daily prices of financial assets. We use the singleobjective programming and PSO algorithm to make the optimal investment decision.