# Research on Securities Portfolio Model Based on Genetic Optimization Neural Network

Authors: Puming Zhang
Journal: Security and Communication Networks
 (2022)

---

## Abstract

Portfolio is an investment management concept different from individual asset management. This consideration leads to an interesting result, that is, investors should buy a variety of securities at the same time instead of one kind of securities for diversified investment. Aiming at the limitations of BPNN (BP neural network) in traditional artificial neural network and its shortcomings such as many iterations, low convergence accuracy, and poor generalization, a portfolio method based on GA_BPNN (Genetic Optimization Neural Network) was proposed. The setting of GA (genetic algorithm) parameters and BPNN parameters are discussed in detail, and the implementation steps of genetic BP algorithm are described. The results show that the evaluation indexes of GA_BPNN prediction model are obviously better than those of the comparison prediction model, with the coincidence rate of 77.96% and the average absolute error of 12.451. The combination of GA and BPNN can effectively solve this problem. The simulation results of optimizing securities portfolio show that its optimization scheme is better than quadratic programming method, and this method is more correct, efficient, and practical.


---

## Body

## 1. Introduction

Investors always hope to get as high a return as possible and take as little risk as possible during the period of holding securities, and with the increase of return, the risk of securities also increases. How to make the securities investors get as high a return as possible at a certain level of risk or make the risk of securities investment as small as possible at a certain level of return? The most sensible way is to diversify the funds into a number of securities to form a portfolio. Due to the inherent speculative and high-risk characteristics of the securities market, in the trading of the securities market, the holders of the securities share a certain investment income but also conditionally bear the investment risks caused by the production risks. Using intelligent algorithms to solve portfolio problems has attracted more and more attention of academic researchers. The advantages of intelligent algorithm in solving portfolio optimization problems are becoming more and more obvious. The research of modern portfolio theory has proved that GA (genetic algorithm) can effectively solve portfolio optimization problems.Optimization technology is based on mathematics and widely used in industry, agriculture, economy, medicine, and other fields to solve various engineering problems. BPNN (BP neural network) in artificial neural network is based on the optimization technology. It has the characteristics of simple structure, intelligence, strong self-adaptive ability, and strong self-learning ability and has been widely used in signal prediction and combination optimization [1]. However, the traditional BPNN adopts gradient descent method to solve the optimal problem, which is easy to fall into local extremum, and its network convergence speed is slow [2]. Todea and Pleşoianu summarized and studied the overconfidence theory in detail and established a behavioral financial model of overconfidence [3]. Wu et al. established a capital asset pricing model to accurately describe the return and risk of assets and studied the relationship between the expected return of assets and risky assets in the securities market, as well as the formation of equilibrium prices [4]. Hanafizadeh et al. effectively solved the time adaptability problem of portfolio optimization model by establishing genetic network programming model [5]. Moeen used cultural gene algorithm to improve the utility of portfolio in static and dynamic trading environment and solved the problem of time adaptability of portfolio [6].Generally, investors analyze the price of securities through two analysis techniques, namely basic analysis and technical analysis. Because their assumptions are often far from reality, they have only theoretical significance, and the effect of practical application is poor [7, 8]. With the gradual establishment of chaos and fractal theory in the securities market, people began to use neural network to predict the changes of the securities market. The learning of BPNN has the weakness of weak global searchability and easy to fall into local minima, while GA does not require the continuity of the objective function, so it has good global searchability. On the basis of obtaining the effective solution, this paper provides a method to obtain the optimal solution. By using this method, we can obtain the optimal portfolio of securities that satisfies investors with specific preferences. The validity of the model is verified by the actual historical data of the securities market, and a good conclusion is obtained.


## 2. Related Work

### 2.1. Research on the Portfolio Model

The investment theory has developed with the development of the securities market. The purpose of investment portfolio is to allocate assets in unrelated multi-markets and to reduce and avoid the risks caused by market uncertainty by diversifying investment. With the establishment and improvement of China’s socialist market economic system and the continuous development of the financial market, the research on securities portfolio has become more and more extensive.Lee et al. explained the Black-Litterman model step by step by combining the insights from some articles related to the model and made an empirical analysis of the model with eight types of assets such as US Treasury bonds [9]. The author also puts forward a new method to restrain the excessive bias caused by investors’ views and increase the usability of the model. Goddard and Marcum introduced liquidity risk measurement constraints on the basis of Black-Litterman model, put forward a new model and method for optimizing asset allocation, and improved the portfolio selection model based solely on historical returns and historical volatility [10]. Delong proposed to use Bayesian moving average method to simulate and predict investors' subjective returns, and substituted it into Black-Litterman model to get the asset allocation weight [11].Clouse proposed a particle swarm optimization algorithm with symbiotic multipopulation to solve the portfolio optimization problem. A portfolio model of energy adaptability under new assets is proposed [12]. Tsai et al. put forward a new risk function based on semiabsolute deviation risk function and minimax principle-minimax semiabsolute deviation risk function [13]. Zhang introduced the application strategies of neural networks in financial fields such as investment, portfolio decision-making, and stock forecasting [14]. However, due to the noisy and unstable characteristics of the stock market, these predictions still have not achieved satisfactory results.


### 2.2. Neural Network-Related Research

Neural network is a mathematical model that aims to simulate the processing mechanism of the brain nervous system to the outside complex information. It has shown good intelligent characteristics in the fields of pattern recognition, intelligent robots, and automatic control. Neural network composed of many adaptive elements connected by parallel computing, which can process information in the same way as biological neural network.Neural network can be used for large-scale parallel processing and distributed information storage. It has good self-learning, self-adaptation, self-organization, strong associative memory, and fault-tolerance functions and can fully approximate any complex nonlinear relationship. Bhutto et al. showed that the neural network method is helpful to improve the prediction accuracy by comparing the neural network method with the traditional statistical prediction method [15]; Wang and Chuang used BPNN to predict and analyze the fluctuation law of public utility index and achieved ideal prediction results [16]. Alimoradi et al. modeled and predicted the stock price based on sparse Bayesian extreme learning machine [17]. Chan et al. put forward a stock price prediction model based on BPNN and grey model [18] in view of the shortcomings of the existing algorithms such as low prediction accuracy and large lag. Zhang et al. used normalization and principal component analysis methods to preprocess the historical data of a listed company’s stock trading, designed a BP learning algorithm training parameter with multilayer network structure based on driving quantity term, and used the activation function ReLU (Rectified Linear Units) and the weight initialization method to modify the deeply sparse neural network model [19].GA is the product of the intersection and penetration of life science and engineering science. There are five elements involved in GA: parameter coding, setting of initial population, design of fitness function, design of genetic operation, and setting of control parameters. Patra et al. proposed that each gene value should be represented by anN-based floating-point number, then divided into an integer part and a decimal part, and the new GA based on N-based partial coding operator was re-coded to make it have strong global searchability in the early stage and avoid falling into local extremum [20]. Sulkow et al. proposed a variable population size GA based on generation gap information [21]. Using the difference information of the optimal solution between adjacent generations of population, the population size was changed according to the logistic model when the premature phenomenon occurred in GA, and the diversity of the population was maintained. Balamurugan et al. proposed a crossover operator based on evolutionary algebra and individual fitness, which adaptively adjusted the crossover operation according to the fitness of each generation of individuals and the change of evolutionary algebra, so that the crossover was carried out in a direction conducive to the convergence of the algorithm [22].


## 2.1. Research on the Portfolio Model

The investment theory has developed with the development of the securities market. The purpose of investment portfolio is to allocate assets in unrelated multi-markets and to reduce and avoid the risks caused by market uncertainty by diversifying investment. With the establishment and improvement of China’s socialist market economic system and the continuous development of the financial market, the research on securities portfolio has become more and more extensive.Lee et al. explained the Black-Litterman model step by step by combining the insights from some articles related to the model and made an empirical analysis of the model with eight types of assets such as US Treasury bonds [9]. The author also puts forward a new method to restrain the excessive bias caused by investors’ views and increase the usability of the model. Goddard and Marcum introduced liquidity risk measurement constraints on the basis of Black-Litterman model, put forward a new model and method for optimizing asset allocation, and improved the portfolio selection model based solely on historical returns and historical volatility [10]. Delong proposed to use Bayesian moving average method to simulate and predict investors' subjective returns, and substituted it into Black-Litterman model to get the asset allocation weight [11].Clouse proposed a particle swarm optimization algorithm with symbiotic multipopulation to solve the portfolio optimization problem. A portfolio model of energy adaptability under new assets is proposed [12]. Tsai et al. put forward a new risk function based on semiabsolute deviation risk function and minimax principle-minimax semiabsolute deviation risk function [13]. Zhang introduced the application strategies of neural networks in financial fields such as investment, portfolio decision-making, and stock forecasting [14]. However, due to the noisy and unstable characteristics of the stock market, these predictions still have not achieved satisfactory results.


## 2.2. Neural Network-Related Research

Neural network is a mathematical model that aims to simulate the processing mechanism of the brain nervous system to the outside complex information. It has shown good intelligent characteristics in the fields of pattern recognition, intelligent robots, and automatic control. Neural network composed of many adaptive elements connected by parallel computing, which can process information in the same way as biological neural network.Neural network can be used for large-scale parallel processing and distributed information storage. It has good self-learning, self-adaptation, self-organization, strong associative memory, and fault-tolerance functions and can fully approximate any complex nonlinear relationship. Bhutto et al. showed that the neural network method is helpful to improve the prediction accuracy by comparing the neural network method with the traditional statistical prediction method [15]; Wang and Chuang used BPNN to predict and analyze the fluctuation law of public utility index and achieved ideal prediction results [16]. Alimoradi et al. modeled and predicted the stock price based on sparse Bayesian extreme learning machine [17]. Chan et al. put forward a stock price prediction model based on BPNN and grey model [18] in view of the shortcomings of the existing algorithms such as low prediction accuracy and large lag. Zhang et al. used normalization and principal component analysis methods to preprocess the historical data of a listed company’s stock trading, designed a BP learning algorithm training parameter with multilayer network structure based on driving quantity term, and used the activation function ReLU (Rectified Linear Units) and the weight initialization method to modify the deeply sparse neural network model [19].GA is the product of the intersection and penetration of life science and engineering science. There are five elements involved in GA: parameter coding, setting of initial population, design of fitness function, design of genetic operation, and setting of control parameters. Patra et al. proposed that each gene value should be represented by anN-based floating-point number, then divided into an integer part and a decimal part, and the new GA based on N-based partial coding operator was re-coded to make it have strong global searchability in the early stage and avoid falling into local extremum [20]. Sulkow et al. proposed a variable population size GA based on generation gap information [21]. Using the difference information of the optimal solution between adjacent generations of population, the population size was changed according to the logistic model when the premature phenomenon occurred in GA, and the diversity of the population was maintained. Balamurugan et al. proposed a crossover operator based on evolutionary algebra and individual fitness, which adaptively adjusted the crossover operation according to the fitness of each generation of individuals and the change of evolutionary algebra, so that the crossover was carried out in a direction conducive to the convergence of the algorithm [22].


## 3. Research Method

### 3.1. GA BPNN Thought

The topology of BPNN model includes IL (input layer), HL (hidden layer), and OL (output layer). Figure1 shows the structure model of BPNN.Figure 1
BPNN structure model.The relationship between the input and output of each HL is as follows:(1)nk=WkVk−1+bk,k=1,2,…,M−1,Vk=fkWkVk−1+bk,k=1,2,…,M−1.The input and output of the network are(2)Y=fMWMVM−1+bM,k=1,2,…,M−1.The learning process of BPNN can be divided into two parts: forward propagation of working signal and backward propagation of error signal:(1)
From IL to OL through HL, the weight of the network is constant in the process of signal forward transmission, and the state of each layer of neurons only affects the state of the next layer of neurons, which is called working signal forward propagation [18]; if the OL cannot get the desired output, the error signal will be transmitted back.(2)
The difference between the actual output and the expected output of the neural network is called error signal [19].At present, in the practical application of artificial neural network, most neural network models adopt neural networks and their variations. It is also the core part of feedforward network, which embodies the essence of artificial neural network. BPNN has the ability to optimize calculation. However, there are local minimum problems in its optimization calculation, which must be improved.At present, investors’ expectations for investment decisions are constantly changing, and the same portfolio may not be universally applicable to different investors. It is also important to establish a corresponding portfolio optimization model for specific investors' preferences. According to the actual situation of the securities market, when the market share price index goes up, the prices of most stocks also go up; conversely, when the market share price index goes down, the prices of most stocks go down. That is, the factors that can affect the stock price index of the securities market; microfactors refer to the specific internal environment of the company, such as the introduction of new products, major personnel changes, and other factors that affect the company’s operations.No matter in application, algorithm design, or basic theory, GA has made great progress and has become a hot research field concerned by many disciplines such as information science, computer science, operational research, and applied mathematics.The structure of GA is open and has nothing to do with the problem, so it is easy to improve the execution strategy. The improvement of GA execution strategy includes hybrid GA, parallel GA, cooperative evolutionary algorithm, and chaotic GA. Figure2 shows GA thoughts.Figure 2
GA thought.The stopping conditions in GA are generally determined in different ways according to different problems. For example, one of the following criteria can be used as a judgment condition: the maximum fitness of individuals in a population exceeds a preset value; the average fitness of individuals in the population exceeds the preset value; the generation number exceeds the preset value.GA is a robust search algorithm that can be used for complex system optimization. Compared with the traditional optimization algorithm, it has the following characteristics:(1)
Some coding forms of GA dealing with decision variables enable us to learn from the concepts of chromosomes and genes in biology, imitate the genetic and evolutionary mechanism of natural organisms, and also enable us to conveniently apply genetic operators.(2)
The genetic manipulation of this population produces a new generation of population, which includes a lot of population information.(3)
GA increases the flexibility of its search process.(4)
GA filtering process is a parallel filtering mechanism.


### 3.2. Portfolio Model Design

#### 3.2.1. Application of BPNN in Security Investment Portfolio

To make a portfolio investment, you must first select the securities for investment. When choosing the securities to invest in, we must first go through careful analysis. At present, there are two main types of analysis methods used in securities investment analysis: basic analysis and technical analysis. Basic analysis is a method to analyze the basic factors that determine the price of securities according to the basic principles of economics, finance, financial management, and investment. Technical analysis is to explore some typical laws and predict the future trend of the securities market by applying mathematical and logical methods to the past and present behavior of the market.The single index model only considers a single factor that can affect the yield of securities, which is not in line with the actual securities market environment. Therefore, it is more reasonable to use the multi-index model to explain the factors that affect the yield of securities. The structure is divided into stock market, bond market, fund market and derivatives market according to the types of securities, and the submarkets are interrelated. The object of bond market transactions is bonds. Because of the fixed coupon rate and maturity, the market price of bonds is stable relative to the stock price. Therefore, it represents the ownership or creditor’s right of a certain amount of property and the related right of income. In fact, the securities market is the place where property rights are directly exchanged.BPNN securities portfolio allows individual samples in learning samples to have large errors or even complete errors. This is because every time the weights and thresholds of BPNN are corrected according to the characteristics of the whole learning sample, and the errors of individual samples will not affect the training process of BPNN. In the process of error signal back propagation, the weights of the network are adjusted by error feedback, and the actual output of the network is closer to the expected output through constant correction of the weights.In the process of securities investment, investors and investment institutions all hope that they can invest the same amount of money in the securities market to obtain the maximum return while taking the minimum investment risk. However, according to the investment theory [2], it is impossible to have a portfolio that requires the minimum risk and the maximum investment return in theory or in practice.To forecast the stock price is to use historical data to predict the future, but the securities system is a nonlinear and complex system, and some traditional forecasting methods, such as statistical methods, have poor results. GA is used to optimize the initial weights and thresholds of BPNN, and then the securities portfolio is carried out [12]. The research shows that genetic optimization can improve the efficiency and accuracy of BPNN's portfolio.


#### 3.2.2. Implementation of Genetic Neural Network Optimization

To establish a portfolio model based on GA_BPNN, we must first analyze the invested assets, analyze the risk factors of assets, extract the indicators through factor analysis, screen the indicators by cluster analysis, establish the risk index system of stock assets, establish the weight set of indicators, objectively analyze the influence degree of each indicator on the risk of assets, establish the membership matrix, and judge the category of assets by the value of membership degree.The main idea is to construct the so-called evaluation function with the help of the intuitive background in geometry or application, so as to transform the multiobjective optimization problem into a single-objective optimization problem.In the process of GA execution, coding will directly affect genetic operations such as selection, crossover, and mutation. According to the above analysis, the objective function of this paper can be expressed as(3)minT=1−μ∑xiβiδm2−μ∑xiAis.t.∑xi=1,xi represents the weight of the i th asset; xi≥0 means that short selling of securities is not allowed in China.In GA_BPNN algorithm, each chromosome is decomposed into connecting gene and parameter gene, and the two parts are coded by different coding methods. The code string consists of binary “0” and “1.” Each binary number in the code string represents an HL neuron, “1” means that the neuron exists, and “0” means that it does not exist. Therefore, there are as many binary numbers of 0 or 1 as there are HL neurons, that is, the length of the binary code is equal to the number of HL nodes.In GA, the fitness function value is used to measure the excellence degree of each individual in the group that can reach or approach or help to find the optimal solution in the optimization calculation. The fitness function of GA_BPNN algorithm is based on the total error of neural network, that is, the fitness function of each chromosome is taken as follows:(4)f=11+E,where E is the total error in the neural network.The selection operator of GA used to optimize BPNN usually chooses the fitness ratio selection method, and the probability of individual being selected in a population is directly proportional to its fitness value.For the population whose fitness function isf, the probability of individual being selected is(5)Psi=fi∑i=1nfi.In the above formula,Psi represents the probability that the ith individual is selected, n represents the number of training samples, and fi represents the fitness value of the ith individual.The arithmetic crossover operator is used to crossover the temporary population. Assuming that arithmetic crossover is performed between two individualsXAt,XBt, the two new individuals generated after the crossover operation are(6)XAt+1=PcXBt+1+1−PcXAt,XBt+1=PcXAt+1−PcXBt,where Pc is a parameter, which can usually be set as a constant or a variable determined by evolutionary algebra. In order to improve the diversity of the population and ensure that there is no premature phenomenon in the later stage of the algorithm, Pc is an adaptive cross parameter.Generally speaking, in GA, mutation operation acts on a single chromosome to generate a new chromosome. Specifically, in thekth iteration, the algorithm will generate another random number γk∈−1,1. Let xk be the chromosome selected from feaX or infeX set, and the algorithm uses the following rules to generate a new chromosome mk:(7)mk=xk+γk.In the mutation operation, all chromosomes selected with probabilitypk will participate in the operation. After that, the algorithm will check the feasibility of these new chromosomes mk and put them into feaX and infeX sets accordingly for the next iteration.After optimization, the learning samples are trained and fitted. The optimized BPNN makes GA and BPNN give full play to their respective advantages, and their strengths and weaknesses are avoided. Compared with the traditional BPNN, the nonlinear fitting ability is greatly improved. The flow of BP algorithm is shown in Figure3:Figure 3
GA_BPNN algorithm flow.GA_BPNN algorithm steps:(1)
Initialize algorithm parameters. Generate a random initial population (i.e. the initial weight thresholds ofN groups of neural networks).(2)
The weights and thresholds are given to BPNN in turn, and the global error of each chromosome is calculated for the given input set and output set. Calculate the population fitness.(3)
Evaluate fitness. The probability of individual selection is allocated, and individuals are selected by roulette wheel selection method.(4)
The arithmetic crossover operator is used to crossover the temporary population.(5)
The temporary population is mutated by mutation operator. The author adopts the adaptive uniform mutation operation, that is, the original gene value in the individual coding string is replaced by the adaptive probability.(6)
Global optimal convergence. Calculate the global error of the new individual.(7)
Output the individual with the best fitness value in the population. The optimized network connection weight coefficient and threshold can be obtained by decoding the optimal individual.


## 3.1. GA BPNN Thought

The topology of BPNN model includes IL (input layer), HL (hidden layer), and OL (output layer). Figure1 shows the structure model of BPNN.Figure 1
BPNN structure model.The relationship between the input and output of each HL is as follows:(1)nk=WkVk−1+bk,k=1,2,…,M−1,Vk=fkWkVk−1+bk,k=1,2,…,M−1.The input and output of the network are(2)Y=fMWMVM−1+bM,k=1,2,…,M−1.The learning process of BPNN can be divided into two parts: forward propagation of working signal and backward propagation of error signal:(1)
From IL to OL through HL, the weight of the network is constant in the process of signal forward transmission, and the state of each layer of neurons only affects the state of the next layer of neurons, which is called working signal forward propagation [18]; if the OL cannot get the desired output, the error signal will be transmitted back.(2)
The difference between the actual output and the expected output of the neural network is called error signal [19].At present, in the practical application of artificial neural network, most neural network models adopt neural networks and their variations. It is also the core part of feedforward network, which embodies the essence of artificial neural network. BPNN has the ability to optimize calculation. However, there are local minimum problems in its optimization calculation, which must be improved.At present, investors’ expectations for investment decisions are constantly changing, and the same portfolio may not be universally applicable to different investors. It is also important to establish a corresponding portfolio optimization model for specific investors' preferences. According to the actual situation of the securities market, when the market share price index goes up, the prices of most stocks also go up; conversely, when the market share price index goes down, the prices of most stocks go down. That is, the factors that can affect the stock price index of the securities market; microfactors refer to the specific internal environment of the company, such as the introduction of new products, major personnel changes, and other factors that affect the company’s operations.No matter in application, algorithm design, or basic theory, GA has made great progress and has become a hot research field concerned by many disciplines such as information science, computer science, operational research, and applied mathematics.The structure of GA is open and has nothing to do with the problem, so it is easy to improve the execution strategy. The improvement of GA execution strategy includes hybrid GA, parallel GA, cooperative evolutionary algorithm, and chaotic GA. Figure2 shows GA thoughts.Figure 2
GA thought.The stopping conditions in GA are generally determined in different ways according to different problems. For example, one of the following criteria can be used as a judgment condition: the maximum fitness of individuals in a population exceeds a preset value; the average fitness of individuals in the population exceeds the preset value; the generation number exceeds the preset value.GA is a robust search algorithm that can be used for complex system optimization. Compared with the traditional optimization algorithm, it has the following characteristics:(1)
Some coding forms of GA dealing with decision variables enable us to learn from the concepts of chromosomes and genes in biology, imitate the genetic and evolutionary mechanism of natural organisms, and also enable us to conveniently apply genetic operators.(2)
The genetic manipulation of this population produces a new generation of population, which includes a lot of population information.(3)
GA increases the flexibility of its search process.(4)
GA filtering process is a parallel filtering mechanism.


## 3.2. Portfolio Model Design

### 3.2.1. Application of BPNN in Security Investment Portfolio

To make a portfolio investment, you must first select the securities for investment. When choosing the securities to invest in, we must first go through careful analysis. At present, there are two main types of analysis methods used in securities investment analysis: basic analysis and technical analysis. Basic analysis is a method to analyze the basic factors that determine the price of securities according to the basic principles of economics, finance, financial management, and investment. Technical analysis is to explore some typical laws and predict the future trend of the securities market by applying mathematical and logical methods to the past and present behavior of the market.The single index model only considers a single factor that can affect the yield of securities, which is not in line with the actual securities market environment. Therefore, it is more reasonable to use the multi-index model to explain the factors that affect the yield of securities. The structure is divided into stock market, bond market, fund market and derivatives market according to the types of securities, and the submarkets are interrelated. The object of bond market transactions is bonds. Because of the fixed coupon rate and maturity, the market price of bonds is stable relative to the stock price. Therefore, it represents the ownership or creditor’s right of a certain amount of property and the related right of income. In fact, the securities market is the place where property rights are directly exchanged.BPNN securities portfolio allows individual samples in learning samples to have large errors or even complete errors. This is because every time the weights and thresholds of BPNN are corrected according to the characteristics of the whole learning sample, and the errors of individual samples will not affect the training process of BPNN. In the process of error signal back propagation, the weights of the network are adjusted by error feedback, and the actual output of the network is closer to the expected output through constant correction of the weights.In the process of securities investment, investors and investment institutions all hope that they can invest the same amount of money in the securities market to obtain the maximum return while taking the minimum investment risk. However, according to the investment theory [2], it is impossible to have a portfolio that requires the minimum risk and the maximum investment return in theory or in practice.To forecast the stock price is to use historical data to predict the future, but the securities system is a nonlinear and complex system, and some traditional forecasting methods, such as statistical methods, have poor results. GA is used to optimize the initial weights and thresholds of BPNN, and then the securities portfolio is carried out [12]. The research shows that genetic optimization can improve the efficiency and accuracy of BPNN's portfolio.


### 3.2.2. Implementation of Genetic Neural Network Optimization

To establish a portfolio model based on GA_BPNN, we must first analyze the invested assets, analyze the risk factors of assets, extract the indicators through factor analysis, screen the indicators by cluster analysis, establish the risk index system of stock assets, establish the weight set of indicators, objectively analyze the influence degree of each indicator on the risk of assets, establish the membership matrix, and judge the category of assets by the value of membership degree.The main idea is to construct the so-called evaluation function with the help of the intuitive background in geometry or application, so as to transform the multiobjective optimization problem into a single-objective optimization problem.In the process of GA execution, coding will directly affect genetic operations such as selection, crossover, and mutation. According to the above analysis, the objective function of this paper can be expressed as(3)minT=1−μ∑xiβiδm2−μ∑xiAis.t.∑xi=1,xi represents the weight of the i th asset; xi≥0 means that short selling of securities is not allowed in China.In GA_BPNN algorithm, each chromosome is decomposed into connecting gene and parameter gene, and the two parts are coded by different coding methods. The code string consists of binary “0” and “1.” Each binary number in the code string represents an HL neuron, “1” means that the neuron exists, and “0” means that it does not exist. Therefore, there are as many binary numbers of 0 or 1 as there are HL neurons, that is, the length of the binary code is equal to the number of HL nodes.In GA, the fitness function value is used to measure the excellence degree of each individual in the group that can reach or approach or help to find the optimal solution in the optimization calculation. The fitness function of GA_BPNN algorithm is based on the total error of neural network, that is, the fitness function of each chromosome is taken as follows:(4)f=11+E,where E is the total error in the neural network.The selection operator of GA used to optimize BPNN usually chooses the fitness ratio selection method, and the probability of individual being selected in a population is directly proportional to its fitness value.For the population whose fitness function isf, the probability of individual being selected is(5)Psi=fi∑i=1nfi.In the above formula,Psi represents the probability that the ith individual is selected, n represents the number of training samples, and fi represents the fitness value of the ith individual.The arithmetic crossover operator is used to crossover the temporary population. Assuming that arithmetic crossover is performed between two individualsXAt,XBt, the two new individuals generated after the crossover operation are(6)XAt+1=PcXBt+1+1−PcXAt,XBt+1=PcXAt+1−PcXBt,where Pc is a parameter, which can usually be set as a constant or a variable determined by evolutionary algebra. In order to improve the diversity of the population and ensure that there is no premature phenomenon in the later stage of the algorithm, Pc is an adaptive cross parameter.Generally speaking, in GA, mutation operation acts on a single chromosome to generate a new chromosome. Specifically, in thekth iteration, the algorithm will generate another random number γk∈−1,1. Let xk be the chromosome selected from feaX or infeX set, and the algorithm uses the following rules to generate a new chromosome mk:(7)mk=xk+γk.In the mutation operation, all chromosomes selected with probabilitypk will participate in the operation. After that, the algorithm will check the feasibility of these new chromosomes mk and put them into feaX and infeX sets accordingly for the next iteration.After optimization, the learning samples are trained and fitted. The optimized BPNN makes GA and BPNN give full play to their respective advantages, and their strengths and weaknesses are avoided. Compared with the traditional BPNN, the nonlinear fitting ability is greatly improved. The flow of BP algorithm is shown in Figure3:Figure 3
GA_BPNN algorithm flow.GA_BPNN algorithm steps:(1)
Initialize algorithm parameters. Generate a random initial population (i.e. the initial weight thresholds ofN groups of neural networks).(2)
The weights and thresholds are given to BPNN in turn, and the global error of each chromosome is calculated for the given input set and output set. Calculate the population fitness.(3)
Evaluate fitness. The probability of individual selection is allocated, and individuals are selected by roulette wheel selection method.(4)
The arithmetic crossover operator is used to crossover the temporary population.(5)
The temporary population is mutated by mutation operator. The author adopts the adaptive uniform mutation operation, that is, the original gene value in the individual coding string is replaced by the adaptive probability.(6)
Global optimal convergence. Calculate the global error of the new individual.(7)
Output the individual with the best fitness value in the population. The optimized network connection weight coefficient and threshold can be obtained by decoding the optimal individual.


## 3.2.1. Application of BPNN in Security Investment Portfolio

To make a portfolio investment, you must first select the securities for investment. When choosing the securities to invest in, we must first go through careful analysis. At present, there are two main types of analysis methods used in securities investment analysis: basic analysis and technical analysis. Basic analysis is a method to analyze the basic factors that determine the price of securities according to the basic principles of economics, finance, financial management, and investment. Technical analysis is to explore some typical laws and predict the future trend of the securities market by applying mathematical and logical methods to the past and present behavior of the market.The single index model only considers a single factor that can affect the yield of securities, which is not in line with the actual securities market environment. Therefore, it is more reasonable to use the multi-index model to explain the factors that affect the yield of securities. The structure is divided into stock market, bond market, fund market and derivatives market according to the types of securities, and the submarkets are interrelated. The object of bond market transactions is bonds. Because of the fixed coupon rate and maturity, the market price of bonds is stable relative to the stock price. Therefore, it represents the ownership or creditor’s right of a certain amount of property and the related right of income. In fact, the securities market is the place where property rights are directly exchanged.BPNN securities portfolio allows individual samples in learning samples to have large errors or even complete errors. This is because every time the weights and thresholds of BPNN are corrected according to the characteristics of the whole learning sample, and the errors of individual samples will not affect the training process of BPNN. In the process of error signal back propagation, the weights of the network are adjusted by error feedback, and the actual output of the network is closer to the expected output through constant correction of the weights.In the process of securities investment, investors and investment institutions all hope that they can invest the same amount of money in the securities market to obtain the maximum return while taking the minimum investment risk. However, according to the investment theory [2], it is impossible to have a portfolio that requires the minimum risk and the maximum investment return in theory or in practice.To forecast the stock price is to use historical data to predict the future, but the securities system is a nonlinear and complex system, and some traditional forecasting methods, such as statistical methods, have poor results. GA is used to optimize the initial weights and thresholds of BPNN, and then the securities portfolio is carried out [12]. The research shows that genetic optimization can improve the efficiency and accuracy of BPNN's portfolio.


## 3.2.2. Implementation of Genetic Neural Network Optimization

To establish a portfolio model based on GA_BPNN, we must first analyze the invested assets, analyze the risk factors of assets, extract the indicators through factor analysis, screen the indicators by cluster analysis, establish the risk index system of stock assets, establish the weight set of indicators, objectively analyze the influence degree of each indicator on the risk of assets, establish the membership matrix, and judge the category of assets by the value of membership degree.The main idea is to construct the so-called evaluation function with the help of the intuitive background in geometry or application, so as to transform the multiobjective optimization problem into a single-objective optimization problem.In the process of GA execution, coding will directly affect genetic operations such as selection, crossover, and mutation. According to the above analysis, the objective function of this paper can be expressed as(3)minT=1−μ∑xiβiδm2−μ∑xiAis.t.∑xi=1,xi represents the weight of the i th asset; xi≥0 means that short selling of securities is not allowed in China.In GA_BPNN algorithm, each chromosome is decomposed into connecting gene and parameter gene, and the two parts are coded by different coding methods. The code string consists of binary “0” and “1.” Each binary number in the code string represents an HL neuron, “1” means that the neuron exists, and “0” means that it does not exist. Therefore, there are as many binary numbers of 0 or 1 as there are HL neurons, that is, the length of the binary code is equal to the number of HL nodes.In GA, the fitness function value is used to measure the excellence degree of each individual in the group that can reach or approach or help to find the optimal solution in the optimization calculation. The fitness function of GA_BPNN algorithm is based on the total error of neural network, that is, the fitness function of each chromosome is taken as follows:(4)f=11+E,where E is the total error in the neural network.The selection operator of GA used to optimize BPNN usually chooses the fitness ratio selection method, and the probability of individual being selected in a population is directly proportional to its fitness value.For the population whose fitness function isf, the probability of individual being selected is(5)Psi=fi∑i=1nfi.In the above formula,Psi represents the probability that the ith individual is selected, n represents the number of training samples, and fi represents the fitness value of the ith individual.The arithmetic crossover operator is used to crossover the temporary population. Assuming that arithmetic crossover is performed between two individualsXAt,XBt, the two new individuals generated after the crossover operation are(6)XAt+1=PcXBt+1+1−PcXAt,XBt+1=PcXAt+1−PcXBt,where Pc is a parameter, which can usually be set as a constant or a variable determined by evolutionary algebra. In order to improve the diversity of the population and ensure that there is no premature phenomenon in the later stage of the algorithm, Pc is an adaptive cross parameter.Generally speaking, in GA, mutation operation acts on a single chromosome to generate a new chromosome. Specifically, in thekth iteration, the algorithm will generate another random number γk∈−1,1. Let xk be the chromosome selected from feaX or infeX set, and the algorithm uses the following rules to generate a new chromosome mk:(7)mk=xk+γk.In the mutation operation, all chromosomes selected with probabilitypk will participate in the operation. After that, the algorithm will check the feasibility of these new chromosomes mk and put them into feaX and infeX sets accordingly for the next iteration.After optimization, the learning samples are trained and fitted. The optimized BPNN makes GA and BPNN give full play to their respective advantages, and their strengths and weaknesses are avoided. Compared with the traditional BPNN, the nonlinear fitting ability is greatly improved. The flow of BP algorithm is shown in Figure3:Figure 3
GA_BPNN algorithm flow.GA_BPNN algorithm steps:(1)
Initialize algorithm parameters. Generate a random initial population (i.e. the initial weight thresholds ofN groups of neural networks).(2)
The weights and thresholds are given to BPNN in turn, and the global error of each chromosome is calculated for the given input set and output set. Calculate the population fitness.(3)
Evaluate fitness. The probability of individual selection is allocated, and individuals are selected by roulette wheel selection method.(4)
The arithmetic crossover operator is used to crossover the temporary population.(5)
The temporary population is mutated by mutation operator. The author adopts the adaptive uniform mutation operation, that is, the original gene value in the individual coding string is replaced by the adaptive probability.(6)
Global optimal convergence. Calculate the global error of the new individual.(7)
Output the individual with the best fitness value in the population. The optimized network connection weight coefficient and threshold can be obtained by decoding the optimal individual.


## 4. Result Analysis

In stock trading, the benefits and risks coexist. Maximizing the benefits and minimizing the risks are the goals pursued by all stock investors. The stock price fully reflects all relevant information, and the price changes are subject to random walk, while the prediction of the stock price is meaningless. However, the biggest controversy in classical literature focuses on the predictability of stock returns. The market efficiency itself cannot be tested, and the test of whether the price properly reflects the information must be carried out in an asset pricing model. Even if an abnormal case of earnings behavior is found, it may be due to the inefficiency of the market or the problem of the adopted equilibrium model.This paper takes Markowitz’s securities investment theory as the basic framework and capital asset pricing theory as the theoretical basis of securities portfolio, so as to simplify the model parameters and reduce the calculation workload [16]. Using MATLAB simulation software to analyze the data, the relationship between the ratio of securities investment, the rate of return and the risk loss rate are obtained (see Table 1 and Figure 4).Table 1
Average securities yield and investment ratio.
Securities name numberCoefficient 1Coefficient 2Average yield10.0360.56−0.0532−0.0210.130.0133−0.0260.44−0.0214−0.0220.19−0.0115−0.0270.31−0.086Figure 4
Average return rate of securities and investment ratio chart.The rate of return increases with the increase of risk loss rate and will remain unchanged when the rate of return increases to a certain level. Therefore, the rate of return does not increase indefinitely with the risk loss rate. Through the above experimental analysis, it can be seen that a reasonable investment scheme can be selected according to investors’ preferences by positioning a suitable expected value and risk loss value [18].The selection of parameters in the model directly affects the solution effect and efficiency. For example, if the mutation probability is too small, the search space will be reduced, while if it is too large, it will degenerate into random search, which will reduce the stability of the population. If the evolution algebra is too large, the solution efficiency will be affected. In the mutation operation, the individuals to be mutated are randomly selected according to the mutation probability, then the mutated bits are randomly selected, and the weights of the two basic points are exchanged.Although the solution obtained by this algorithm is only the suboptimal solution, it can be used as the optimal solution to some extent, because the optimization process characteristics of this solution are in line with the changing characteristics of the securities market and have certain fuzzy optimization characteristics, so it can be used as a portfolio allocation scheme.Through the error comparison of many experiments, it is found that the GA-optimized BPNN has better initial weights and thresholds than the general BPNN. The former’s initial weights and thresholds are close to the optimal solution, and it has a faster convergence speed and can reduce the occurrence of network oscillation, nonconvergence, too long training time, and falling into local minima caused by improper initial connection weight thresholds. In this paper, 15 groups of test data are predicted by the trained network using test samples, and the results are shown in Figure5:Figure 5
Prediction result.GA can effectively solve the nonlinear multiobjective optimization problem and avoid falling into local optimum. After each operator of GA is determined and the corresponding operation method is selected, GA is executed to search. In the developed market economy environment, the securities market is an important part of the complete market system. The securities market can reflect and adjust the movement of monetary funds and affect the development and operation of the whole economy. Securities market mainly includes participants, instruments, and places of securities market.Because it has been transformed into a quadratic programming problem, there are many realized methods to obtain its optimal solution. In this research, we design and implement a model called parametric dual neural network to obtain its optimal solution. Therefore, the GA uses the objective function of the upper-level problem as the fitness function. It also provides guidance and suggestions on how to choose good initialization parameters when using this algorithm to solve other quadratic bilevel programming problems.The stock market is a dynamic system that is constantly changing. As time goes by, the network system must be retrained in combination with the new data generated by the stock market to adapt to the changing situation, so as to get a better effect.Now the problem is transformed into solving the indifference curve. It is assumed that investors’ preferences are consistent, that is, regardless of the number of securities included in the portfolio, the determined indifference curve is the same. When the portfolio has the same risk, the more conservative the investor, the higher the return, otherwise he would rather give up his investment. Therefore, the calculation of the indifference curve is also subjective, and it is difficult for investors to determine the indifference curve that is really suitable for them, so they consider another way to obtain the best advantage.In this case, the problem to be considered changes from the relationship betweenR and σ to the relationship between S,a.Different investors will take differentS,a values. On the one hand, the value of S should be as large as possible, and on the other hand, the probability that the rate of return is lower than S should be controlled, and the result is shown in Figure 6:Figure 6
GA calculation results.Among them, combination l–4 is the concrete combination of the four best advantages in the case of risk-free assets obtained above. Because the effective boundary is generated by fitting numerous discrete points by the method of fitting the effective solution set, it will also lead to a certain error between the best point obtained by tangency between the indifference curve and the effective boundary curve and the best point calculated by GA, but as long as this error is within a certain range, it will be considered reasonable and can be ignored.When the capital invested in a certain security is less than the specified value, it means that there is an error in the calculation of this item, and it needs to be corrected, whereas the opposite is not required, so it only needs to be reduced by 0. Therefore, no difference in yield is shown in Table2:Table 2
Yield error.
Combination 1Combination 2Combination 3Combination 4ER (%)2.30162.66873.34273.9655Error (%)0.220.020.0010.03From the above table, we can know that after ignoring the transaction cost in GA calculation, there may be errors in the obtained income, that is, the obtained optimal combination is not always exactly what investors need but may be less than the income generated by the combination required by investors. However, after analysis, the error is small, so this error is ignored here, that is, it is considered that this portfolio is the optimal portfolio required by investors.This section compares and analyzes the expected return, variance, and Sharpe ratio of the two models according to the experimental results. The comparison of the expected return, variance, and Sharpe ratio of the two models is shown in Figure7.Figure 7
Model comparison diagram.It can be seen that the return of this model is higher than that of ref [15] model when the risk level is basically the same, and it can be seen from the Sharpe ratio that this portfolio optimization model is obviously better than ref [15] model. Considering the transaction costs in the actual securities market, under the same conditions of risk and return, the fewer the assets in the portfolio, the less the transaction costs. Therefore, the portfolio optimization model in this paper is effective.In order to compare the GA_BPNN prediction model with other neural network models, this paper selects the two most commonly used static neural networks, namely BPNN model and RBF (Radial Basis Function) neural network model. Comparison of prediction results is shown in Figure8:Figure 8
Comparison of prediction effects of three prediction models.The evaluation indexes of GA_BPNN prediction model are obviously superior to RBF prediction model, which shows that the convergence speed of GA_BPNN prediction model system is fast, and the accuracy is higher. The coincidence rate is 77.96%, and the average absolute error is 12.451. This is because the initial weight of GA_BPNN is composed of randomly generated uniform real numbers between -1 and 1, and it has the ability of “memory.”The factors that affect the stock price are complex and changeable. How to select the appropriate quantity from these complicated data factors directly affects the effective optimization and simplification of the network structure of the final forecast result. It is also the key of forecasting, which can not only improve the forecasting accuracy but also increase the operation speed.The fluctuation of stock price is not completely random, it seems random and messy, but behind its complex surface, there is a deterministic mechanism, so there is a predictable component. The reason why an investor wants to sell his stock is because he thinks that the current price has reached its peak and will soon fall, or even if it rises, the increase will be limited and will not bring great profits. If there is no big change in the stock price as before after a certain news is published, it means that the news is not a factor affecting the stock market. If one day we see that the price jumps up a lot and the volume of transactions increases sharply, there must be one or several bullish news. What news is it, there is absolutely no need to ask, because it has already been reflected in the market behavior, and vice versa.Many factors that affect the stock market include not only some quantitative data such as historical data, technical indicators, macro variables but also some qualitative data. If these factors are effectively quantified into the forecasting model and comprehensively analyzed, the forecasting accuracy will definitely be improved and more credible guidance will be provided for investors. The amount of sample data selected is mostly determined by experience, and it lacks theoretical guidance to predict the stock. How to select training samples as completely as possible to include the change pattern of the stock and provide the most effective data for online training is also a subject worth studying.


## 5. Conclusion

Since the portfolio theory was put forward, more and more scholars have devoted themselves to the research of portfolio model, especially the Black-Litterman model. The optimal portfolio can guide the company to choose the right investment object and its proportion when entering the capital market, so as to minimize the investment risk at a certain rate of return. According to the current situation of China’s securities investment market, this paper puts forward the objective model of securities portfolio optimization based on GA_BPNN. Using the method of combining GA with neural network to solve complex optimization calculation problems can overcome the individual premature phenomenon caused by GA alone and the shortcomings of BPNN that are easy to converge locally. The optimal combination meeting the investment requirements of investors with specific preferences is obtained, which achieves a certain balance between maximizing the expected return and minimizing the uncertainty of the return rate. Therefore, the training samples of the network should be constantly adjusted with time. The research proves that it is an effective method to apply this model to the stock market forecast.



---

*Source: 6476168-2022-08-29.xml*