Stock investment portfolio optimization method and system based on artificial intelligence
By dynamically adjusting the learning factors in the particle swarm algorithm and combining historical market risks, optimizing the particle speed and position update formula, the problem that traditional algorithms are difficult to balance global and local search capabilities in stock portfolio optimization is solved, and optimization efficiency and risk control capabilities are improved.
Patent Information
- Application Number
- CN202510244433.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-06-20
AI Technical Summary
Traditional particle swarm algorithms are difficult to balance global search capabilities and local search capabilities in stock portfolio optimization, resulting in the inability to fully explore the global solution space in the early stage of iteration, and it is difficult to conduct a fine search of local optimal solutions in the later stage of iteration, which affects the convergence speed and accuracy of the algorithm.
By dynamically adjusting individual learning factors and global learning factors in the particle swarm algorithm, combining historical market risks and iteration times, constructing iteration coefficients and optimizing the particle speed and position update formulas to improve the algorithm's global and local search capabilities.
The improved particle swarm algorithm can quickly explore the possible range of global optimal solutions in the early stage of iteration, and search for local optimal solutions more carefully in the later stage of iteration, improve the efficiency and accuracy of portfolio optimization, and effectively control the overall risks of the portfolio.
Smart Images

Figure CN120181998A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of financial investment, and particularly to an artificial intelligence-based method and system for optimizing stock portfolios. Background Art
[0002] As a financial product traded on a stock exchange, stocks are an important choice for many investors' financial management. The returns on stock investments mainly come from two aspects: one is the dividends and bonuses distributed by the company, which depend on the company's profitability and distribution policies; the other is the capital spread obtained by buying stocks at a low price and selling them at a high price in the trading market. However, stock investment is also accompanied by relatively high risks, especially non-systematic risks. To reduce non-systematic risks, investors usually do not choose to invest in a single stock, but adopt a diversified investment strategy, allocate funds to companies in different industries and of different scales, and construct an investment portfolio of multiple stocks, so as to improve the stability and security of the investment portfolio.
[0003] In recent years, with the development of artificial intelligence technology, its application in stock portfolios has become increasingly widespread. Artificial intelligence has efficient and massive data collection capabilities as well as fast data information extraction capabilities, and can process and analyze a large amount of financial data, including market conditions, company financial statements, macroeconomic indicators, etc. Through machine learning algorithms, artificial intelligence can identify patterns and trends in the data, predict market trends, and thus help investors make more informed investment decisions.
[0004] In traditional technologies for optimizing stock portfolios, optimization algorithms are usually used to calculate the optimal portfolio. However, when using the Particle Swarm Optimization (PSO) algorithm for optimization, traditional methods use fixed learning factors, which makes it difficult for the algorithm to balance global search capabilities and local search capabilities during the iteration process. In the initial stage of optimization, the fixed learning factor may cause the algorithm to be unable to fully explore the global solution space, and in the later stage of optimization, it is difficult to conduct a fine search for the local optimal solution, thus affecting the convergence speed and accuracy of the algorithm. Summary of the Invention
[0005] In order to solve the above technical problems, the purpose of this application is to provide an artificial intelligence-based method and system for optimizing stock portfolios, and the specific technical solutions adopted are as follows:
[0006] In the first aspect, an embodiment of this application provides an artificial intelligence-based method for optimizing stock portfolios, and the method includes the following steps:
[0007] Obtain the daily return rate of each stock within a preset time;
[0008] For all stocks, preset the initial states of all the stocks as the particles of the particle swarm algorithm, where each element in a particle is the preset initial state of a corresponding stock.
[0009] Calculate the historical market risk of each stock based on the beta coefficient of each stock and the degree of dispersion of the daily returns of all days.
[0010] When the particle swarm algorithm performs the current iteration, based on the values of the individual learning factor and the global learning factor in previous iterations, and the current iteration number, construct the iteration coefficients of the individual learning factor and the global learning factor for the current iteration.
[0011] Based on the historical market risk and the values of each stock in the individual best position of each particle in the current iteration, construct the average individual risk for the current iteration; based on the historical market risk of each stock, the elements in the global best position in the current iteration, and the average individual risk, calculate the proportion of the individual best risk to the global best risk in the current iteration.
[0012] Based on the current iteration number, the iteration coefficients of the individual learning factor and the global learning factor in the current iteration, the proportion of the individual best risk and the proportion of the global best risk, construct the individual learning factor and the global learning factor for the current iteration.
[0013] Based on the velocities of each particle, the individual learning factor and the global learning factor in the current iteration, combined with the best positions of each particle before the current iteration, the global best position of the particles in the current iteration and the positions of each particle after the current iteration, as well as the overall situation of each element in each particle and the daily returns of all days of each stock, determine the velocities of each particle and the positions after iteration for the next iteration, and the fitness of each particle in the current iteration; combine with the particle swarm algorithm to optimize the stock investment portfolio.
[0014] In one embodiment, the expression for the historical market risk of each stock is:
[0015] In the formula, F i represents the historical market risk of the i-th stock; B i , B j respectively represent the beta coefficients of the i-th and j-th stocks; σ i represents the degree of dispersion of the daily returns of all days of the i-th stock; n represents the number of stocks.
[0016] In one embodiment, the expressions for the iteration coefficients of the individual learning factor and the global learning factor in the current iteration are:
[0017] Denote the iteration coefficient of the individual learning factor in the current iteration as Co1, and the expression of Co1 is: In the formula, C 1,max represents the maximum value of the individual learning factor in all historical iterations; C 1,MC represents the range of the individual learning factor in all historical iterations; t represents the current iteration number; T represents the maximum iteration number;
[0018] Based on the maximum value and range of the global learning factor in all historical iterations, by using the same acquisition method as the iteration coefficient of the individual learning factor, the iteration coefficient of the global learning factor under the current iteration is obtained.
[0019] In one embodiment, the acquisition process of the individual risk mean under the current iteration:
[0020] Calculate the product of the values of each stock in the individual best position of each particle under the current iteration and the historical market risk of each stock, and calculate the sum value of the products of all particles; the individual risk mean of the particles under the current iteration is positively correlated with the sum value.
[0021] In one embodiment, the expressions of the individual best risk ratio and the global best risk ratio under the current iteration are:
[0022]
[0023] In the formula, cl1 and cl2 respectively represent the individual best risk ratio and the global best risk ratio under the current iteration; P1 represents the individual risk mean of the particles under the current iteration; F k represents the historical market risk of the kth stock; G k represents the kth element in the global best position under the current iteration.
[0024] In one embodiment, the acquisition process of the individual learning factor and the global learning factor under the current iteration is:
[0025] Calculate the ratio of the current iteration number to the maximum iteration number; denote the individual learning factor adjustment coefficient under the current iteration as β, and β is proportional to the ratio; denote the global learning factor adjustment coefficient under the current iteration as α, where α + β = 1; the expressions of the individual learning factor and the global learning factor under the current iteration are:
[0026] C1 = α × Co1 + β × cl1
[0027] C2 = α × Co2 + β × cl2
[0028] In the formula, C1 represents the individual learning factor under the current iteration; Co1 and cl1 respectively represent the iteration coefficient of the individual learning factor and the individual best risk ratio under the current iteration;
[0029] $C_2$ represents the global learning factor in the current iteration; $C_{o2}$ and $C_{l2}$ respectively represent the iteration coefficient of the global learning factor and the individual best risk proportion in the current iteration.
[0030] In one embodiment, the expressions for the velocity of each particle in the next iteration and the position after iteration are as follows:
[0031] $V$ y (t + 1) = ω × $V$ y (t) + $r_1$ × $C_1$(t) × ($P$ y −$X$ y (t)) + $r_2$ × $C_2$(t) × ($G$ t −$X$ y (t)) $X$ y (t + 1) = $X$ y (t) + $V$ y (t + 1)
[0032] In the formula, $V$ y (t + 1), $V$ y (t) respectively represent the velocity of particle $y$ in the $(t + 1)$-th and $t$-th iterations; ω represents the preset inertial weight; $r_1$, $r_2$ are both random numbers within the range of [0, 1]; $C_1$(t), $C_2$(t) respectively represent the individual learning factor and the global learning factor calculated in the $t$-th iteration; $P$ y represents the best position of particle $y$ after the $(t - 1)$-th iteration; $G$ t represents the global best position of the particle in the $t$-th iteration; $X$ y (t), $X$ y (t + 1) respectively represent the particle positions of particle $y$ after the $t$-th and $(t + 1)$-th iterations.
[0033] In one embodiment, the process of obtaining the fitness of each particle in the current iteration is as follows:
[0034] Calculate the reciprocal of the standard deviation of the daily returns of all stocks; Denote the ratio of the reciprocal of the standard deviation of the $k$-th stock to the sum of the reciprocals of the standard deviations of all stocks as $U$ k , and denote the fitness of the $y$-th particle in the current iteration as $L$ y , and the expression of $L$ y is: In the formula, represents the $k$-th element in the $y$-th particle in the current iteration; $Z$ k represents the mean of the daily returns of the $k$-th stock, and $n$ represents the number of stocks.
[0035] In one embodiment, the stock portfolio optimization is specifically as follows:
[0036] The dimension of the particles, the fitness of each particle, the number of iterations, the inertia weight, the initial position and the initial velocity of the particles are used as the inputs of the particle swarm optimization algorithm. Each iteration is carried out through the velocity of each particle in the next iteration, the position after iteration and the acquisition method of the fitness, and the output is the global optimal solution. The probability of each stock being selected in the global optimal solution is regarded as the investment proportion, which is used as the optimized stock investment portfolio.
[0037] In a second aspect, an embodiment of the present application further provides a stock investment portfolio optimization system based on artificial intelligence, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of the method described in any one of the above.
[0038] The embodiments of the present application have at least the following beneficial effects:
[0039] 1) The present application efficiently processes and analyzes a large amount of financial data, including the historical returns of stocks and market risks. Compared with traditional methods, the improved particle swarm optimization algorithm can better balance the global search ability and the local search ability by dynamically adjusting the individual learning factor and the global learning factor. This enables the algorithm to quickly explore the possible range of the global optimal solution in the initial stage of iteration, and to search for the local optimal solution more precisely in the later stage of iteration, thereby improving the efficiency and accuracy of portfolio optimization. This optimization method can more accurately identify stock portfolios that can bring higher returns on the premise of controllable risks, and provide more valuable investment suggestions for investors.
[0040] 2) In the process of optimizing the investment portfolio, the present application particularly focuses on the historical market risks of stocks, and dynamically adjusts the learning factor of the particles by calculating the individual best risk proportion and the global best risk proportion. This mechanism enables the algorithm to actively avoid stocks with high historical risks during the optimization process, reduce their weights in the investment portfolio, and increase the weights of stocks with low historical risks at the same time. In this way, the overall risk of the investment portfolio is effectively controlled, and investors can better balance the relationship between risk and return while pursuing returns. This risk control mechanism not only improves the safety of the investment portfolio, but also provides a more stable investment strategy for investors, further enhancing the practicality and reliability of the investment portfolio optimization scheme. Description of the Drawings
[0041] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0042] Figure 1 The flowchart of steps of the artificial intelligence-based stock portfolio optimization method provided by an embodiment of the present application;
[0043] Figure 2 It is a schematic diagram of the process of stock portfolio optimization. Detailed implementation manners
[0044] In order to further elaborate on the technical means and effects adopted by the present application to achieve the predetermined invention purpose, the following combines the accompanying drawings and preferred embodiments to specifically describe the artificial intelligence-based stock portfolio optimization method and system proposed according to the present application, its specific implementation manners, structures, features and their effects as follows. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures or characteristics in one or more embodiments can be combined in any suitable form.
[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which this application belongs.
[0046] The following specifically describes the specific solutions of the artificial intelligence-based stock portfolio optimization method and system provided by the present application with reference to the accompanying drawings.
[0047] Please refer to Figure 1 , which shows the flowchart of steps of the artificial intelligence-based stock portfolio optimization method provided by an embodiment of the present application. The method includes the following steps:
[0048] Step S1: Obtain the daily return rate of each stock within a preset time.
[0049] Obtain the daily return rate of each stock in the most recent month through the data of the stock portfolio system. When investing in stocks, low risk and high interest are pursued. Therefore, when the daily return rate of a stock fluctuates greatly, it indicates that the stock is greatly affected by other factors and the risk level of the stock is relatively high. Therefore, calculate the average value of the daily return rate of each stock in the most recent month and the standard deviation of the return rate.
[0050] Step S2: For all stocks, preset the initial states of all the stocks as each particle of the particle swarm algorithm, where each element in the particle is the preset initial state of each stock.
[0051] In the process of selecting stocks, the value range [0, 1] is used as the selection probability of stocks. The value 0 means a 0% chance of selecting the stock, and the value 1 means a 100% chance of selection. The initial state of a stock is only 0 or 1. The initial state of stocks is generated by a random generator, and the generated initial states of stocks form the particles of the particle swarm algorithm. To prevent the problem that too few particles in the particle swarm algorithm may lead to poor convergence effect, and too many particles may result in too long calculation time and low practicality, the number of particles in the particle swarm algorithm is set to [100, 1000], and the value in this application is 100. That is, for all stocks, 100 initial states of all the stocks are randomly generated. Among them, the random generator and the particle swarm algorithm are both well-known technologies, and the specific processes will not be elaborated here. Denote the number of stocks as n, and a particle is a vector of length n, where each element in the vector is the randomly generated initial state of various stocks.
[0052] In the process of selecting the best through particle swarm optimization, an initial velocity needs to be added to the particles. Since in the process of particle iterative movement, the velocity of particles will be updated through the best position of an individual in the iterative process and the global best position of all particles in the current iteration, and the velocity update of particles requires the velocity of particles in the previous iteration. Therefore, in the first particle iteration, there is no previous iteration process. Thus, in the embodiments of this application, the initial velocity of each particle is set to 0.
[0053] Step S3: Calculate the historical market risk of each stock based on the beta coefficient of each stock and the degree of dispersion of all-day returns.
[0054] In the process of investing in stocks, the higher the investment risk of a stock, the less it should be invested. Regarding the risk of stocks, when the historical returns of a stock have relatively large fluctuations, it indicates that the stock has a greater risk. When selecting stocks for investment, the probability of selecting this stock should be smaller.
[0055] First, the data of each stock is processed through the beta coefficient algorithm to obtain the risk degree of each stock. The calculation of the beta coefficient is a well-known technology, and the specific process will not be elaborated here. Thus, the historical market risk of each stock is calculated, and the expression is:
[0056] In the formula, F i represents the historical market risk of the i-th stock; B i , B j represent the beta coefficients of the i-th and j-th stocks; σ iIt represents the degree of dispersion of the return of the i-th stock in the past month. The degree of dispersion can be represented by standard deviation, variance, coefficient of dispersion, etc. In this embodiment, the standard deviation is selected to measure the degree of dispersion; n represents the number of stocks.
[0057] When the historical market risk of a stock is greater, when constructing a stock investment portfolio, the selection probability of this stock should be reduced, or the proportion of investment in stocks with market risk should be reduced, so that investors can effectively control the overall risk of the investment portfolio while pursuing returns and achieve a balance between risk and return.
[0058] Step S4, when the particle swarm algorithm performs the current iteration, based on the values of the individual learning factor and the global learning factor in each historical iteration, and the current iteration number, construct the iteration coefficients of the individual learning factor and the global learning factor in the current iteration.
[0059] In the process of optimizing the stock investment portfolio by the particle swarm algorithm, the learning factors c1 and c2 are used to control the degree to which the particles approach the individual best position and the global best position. As the iteration progresses, all the particles will gather towards one position. In the later stage of the iteration, almost all the particles gather at one position. Therefore, in the later stage of the iteration, it is necessary to reduce the velocity of the particles to maintain a better global convergence state. At the same time, when updating the velocity of the particles through the learning factors c1 and c2, it is necessary to reduce the learning factors c1 and c2 to reduce the velocity of the particles. Calculate the iteration coefficients of the individual learning factor and the global learning factor of the particles. The expression is:
[0060]
[0061] In the formula, Co1 and Co2 respectively represent the iteration coefficients of the individual learning factor and the global learning factor in the current iteration; C 1,max 、C 2,max respectively represent the maximum values of the individual learning factor and the global learning factor in all historical iterations; C 1,MC 、C 2,MC respectively represent the ranges of the individual learning factor and the global learning factor in all historical iterations; t represents the current iteration number; T represents the maximum iteration number. For the iteration number of the particle swarm algorithm in the portfolio optimization problem, the value range is [500, 2000]. Preferably, in the embodiment of the present application, the maximum iteration number is taken as 1000. As other embodiments of the present application, the implementer can set the maximum iteration number according to the actual situation.
[0062] In an optimized stock portfolio, since there is only one global optimal solution for the optimized stock portfolio, during the process of using the particle swarm algorithm to optimize the stock portfolio, in order to ensure that the algorithm converges to the global optimal solution in the final iteration, it is necessary to continuously update the iteration coefficients of the individual learning factor and the global learning factor according to the change of the iteration times, so that in the initial stage of iteration, the particles of the particle swarm algorithm can traverse the whole to find the optimal solution, and in the later stage of iteration, focus on the local area of the global optimal solution.
[0063] Step S5: Based on the historical market risks and the values of each stock in the individual best positions of each particle in the current iteration, construct the individual risk mean in the current iteration; Based on the historical market risks of each stock, the elements in the global best position in the current iteration, and the individual risk mean, calculate the individual best risk ratio and the global best risk ratio in the current iteration.
[0064] For ordinary portfolio optimization, when using the particle swarm algorithm, only the individual best position and the global best position of the particles need to be considered. However, in the process of optimizing the stock portfolio, due to certain risks in stock investment, there should be certain motion risks during the movement of the particles. The higher the risk level of the individual best position of the particles, the less they should move towards the individual best position, but instead should move towards the global best position to improve the accuracy of the particle swarm algorithm. Therefore, the expressions for the individual best risk ratio and the global best risk ratio in the particle swarm algorithm are:
[0065]
[0066] In the formula, P1 represents the individual risk mean of the particles in the current iteration; m represents the number of particles; n represents the number of stocks; represents the value of the k-th stock in the individual best position of the x-th particle in the current iteration; F k represents the historical market risk of the k-th stock;
[0067] cl1 and cl2 respectively represent the individual best risk ratio and the global best risk ratio in the particle swarm algorithm in the current iteration; G k represents the k-th element in the global best position in the current iteration.
[0068] When updating the velocity of the particles in the particle swarm algorithm, the greater the risk level of the individual best position of the particles, the lower the selection probability of the stock in the stock selection, and instead, the global best position should be focused on. When the particles move, they should move towards the global best position to reduce the risk that the selected stocks have a relatively high risk.
[0069] Step S6: Based on the current iteration number, the iteration coefficients of the individual learning factor and the global learning factor in the current iteration, the individual best risk ratio, and the global best risk ratio, construct the individual learning factor and the global learning factor in the current iteration.
[0070] Therefore, for the learning factors of stock particles during the iteration process, the iteration number and the return risk during the iteration process need to be considered. So, through the above indicators, calculate the individual learning factor and the global learning factor of the particles in the current iteration. The expressions are as follows:
[0071]
[0072] C1 = α × Co1 + β × cl1
[0073] C2 = α × Co2 + β × cl2
[0074] In the formula, β represents the adjustment coefficient of the individual learning factor in the current iteration; O represents the adjustment factor, and its value range is between [0, 1]. This value can balance the adjustment amplitude of the learning factor and adapt to the dynamic changes in the iteration process. In this application, the value is 0.5; C1 and C2 respectively represent the individual learning factor and the global learning factor of the particles in the current iteration; α represents the adjustment coefficient of the global learning factor in the current iteration, and α + β = 1;
[0075] At the end of the iteration of the particle swarm optimization algorithm, the particles gradually gather in a relatively small local area. At this time, the gap between the individual best position and the global best position of the particles becomes small, and the historical risks of each stock particle are relatively close. For this situation, the adjustment coefficient of the global learning factor and the adjustment coefficient of the individual learning factor should become smaller and smaller to reduce the influence degree of the stock particle risk on the particles, so that the particles can search more carefully in the local area, thereby avoiding oscillations caused by excessive adjustment and ensuring that the algorithm can converge stably to the global optimal solution. This fine adjustment helps to improve the accuracy of the solution and ensure that the final result of portfolio optimization is both stable and efficient.
[0076] Step S7: Based on the velocities of each particle, the individual learning factor, and the global learning factor in the current iteration, combined with the best positions of each particle before the current iteration, the global best position of the particles in the current iteration, and the positions of each particle after the current iteration, as well as the overall situation of each element in each particle and the daily returns of all stocks in the current iteration, determine the velocities of each particle and the positions after the iteration in the next iteration, and the fitness of each particle in the current iteration; combine the particle swarm algorithm to optimize the stock portfolio.
[0077] Update the velocities of the particles in the particle swarm algorithm in the current iteration through the above steps.
[0078] The velocity update formula is as follows:
[0079] V y (t + 1) = ω × V y (t) + r1 × C1(t) × (P y ―X y (t)) + r2 × C2(t) × (G t ―X y (t))
[0080] In the formula, V y (t + 1) and V y (t) respectively represent the velocity of particle y at the (t + 1)-th and t-th iterations; ω represents the inertia weight, and the default value range of the algorithm is [0.1, 0.9], and the value in this application is 0.5; r1 and r2 respectively represent random numbers in the range of [0, 1], which are used to introduce randomness and improve the diversity of the algorithm; C1(t) and C2(t) respectively represent the individual learning factor and the global learning factor calculated in the t-th iteration; P y represents the best position of particle y after the (t - 1)-th iteration; G t represents the global best position of the particle at the t-th iteration; X y (t) represents the position of particle y after the t-th iteration.
[0081] The position update formula is as follows:
[0082] X y (t + 1) = X y (t) + V y (t + 1)
[0083] In the formula, X y (t + 1) represents the particle position of particle y after the (t + 1)-th iteration.
[0084] The fitness update formula is as follows:
[0085]
[0086] In the formula, L y represents the fitness of the y-th particle in the current iteration; represents the k-th element in the y-th particle in the current iteration; Z k represents the mean of the daily returns of the k-th stock in the most recent month; U k represents the ratio of the reciprocal of the standard deviation of the daily returns of the k-th stock in the most recent month to the sum of the reciprocals of the standard deviations of the daily returns of all stocks in the most recent month, and n represents the number of stocks.
[0087] When pursuing returns, the historical risk level of the stock should be considered. Therefore, the greater the average daily return rate of the stock in the most recent month, the better the return of the stock. At the same time, the greater the ratio of the reciprocal of the standard deviation of the daily return rate of the stock in the most recent month to the sum of the reciprocals of the standard deviations of the daily return rates of all stocks in the most recent month, the lower the risk level.
[0088] The dimension of the particle, the fitness of each particle, the number of iterations, the inertia weight, the initial position and the initial velocity of the particle are used as the input of the particle swarm algorithm. Through continuous iterative calculations in the above steps, the output is the global optimal solution. Among them, the dimension of the particle refers to the type of stock. The elements in the global optimal solution indicate the probability of the stock being selected. The probability of the stock being selected directly reflects its importance in the investment portfolio. The higher the probability, the more investment value the stock has after comprehensively considering returns and risks. Therefore, the proportion of funds occupied by the stock in the investment portfolio is also larger. Thus, the probability of each stock being selected in the global optimal solution is regarded as the investment proportion, serving as the optimized stock investment portfolio to achieve the method for optimizing stock investment portfolio based on artificial intelligence.
[0089] For the system for optimizing stock investment portfolio based on artificial intelligence, it includes a data acquisition module, a data preprocessing module, an algorithm optimization module, and an algorithm optimization processing module. The data acquisition module is used to acquire the historical return information of stocks. The data preprocessing module is used to generate particles and the initial velocities of the particles. The algorithm optimization module is used to calculate the individual learning factor and the global learning factor of the particles. The algorithm optimization processing module is used to calculate the optimal solution of the stock investment portfolio.
[0090] The schematic diagram of the process of optimizing the stock investment portfolio is as Figure 2 shown.
[0091] Based on the same inventive concept as the above method, the embodiment of the present application further provides a system for optimizing stock investment portfolio based on artificial intelligence, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of any one of the above methods for optimizing stock investment portfolio based on artificial intelligence.
[0092] In summary, the embodiments of the present application provide an artificial intelligence-based stock portfolio optimization method, which efficiently processes and analyzes a large amount of financial data, including the historical returns of stocks and market risks. Compared with traditional methods, the improved particle swarm optimization algorithm can better balance the global search ability and the local search ability by dynamically adjusting the individual learning factor and the global learning factor. This enables the algorithm to quickly explore the possible range of the global optimal solution in the initial stage of iteration, and to search for the local optimal solution more precisely in the later stage of iteration, thereby improving the efficiency and accuracy of portfolio optimization. This optimization method can more accurately identify stock portfolios that can bring higher returns on the premise of controllable risks, and provide more valuable investment suggestions for investors. During the process of optimizing the portfolio, the present application particularly focuses on the historical market risks of stocks, and dynamically adjusts the learning factor of particles by calculating the individual best risk ratio and the global best risk ratio. This mechanism enables the algorithm to actively avoid stocks with high historical risks during the optimization process, reduce their weights in the portfolio, and increase the weights of stocks with low historical risks. In this way, the overall risk of the portfolio is effectively controlled, and investors can better balance the relationship between risk and return while pursuing returns. This risk control mechanism not only enhances the security of the portfolio, but also provides investors with a more stable investment strategy, further enhancing the practicality and reliability of the portfolio optimization solution.
[0093] It should be noted that the above sequence of the embodiments of the present application is only for description and does not represent the superiority or inferiority of the embodiments. And the above specific embodiments of the present application have been described. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0094] The embodiments in the present application are all described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and the key point of each embodiment is to illustrate the differences from other embodiments.
[0095] The above are only the preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principle of the present application shall be included in the protection scope of the present application.
Claims
1. A stock portfolio optimization method based on artificial intelligence, characterized in that: The method comprises the following steps: Get the daily rate of return of each stock within a preset period of time; For all stocks, various initial states of all the stocks are preset as particles of the particle swarm algorithm, wherein each element in the particle is the initial state preset for various stocks; Calculate the historical market risk of each stock based on its beta coefficient and the dispersion of all daily returns; When the particle swarm algorithm is performing the current iteration, the iteration coefficients of the individual learning factor and the global learning factor in the current iteration are constructed based on the values of the individual learning factor and the global learning factor in each historical iteration and the current number of iterations; Based on the historical market risk and the value of each stock in the individual best position of each particle in the current iteration, construct the individual risk mean in the current iteration; based on the historical market risk of each stock, each element in the global best position in the current iteration and the individual risk mean, calculate the individual best risk proportion and the global best risk proportion in the current iteration; Based on the current number of iterations, the iteration coefficients of the individual learning factor and the global learning factor in the current iteration, the individual optimal risk ratio and the global optimal risk ratio, construct the individual learning factor and the global learning factor in the current iteration; Based on the speed of each particle in the current iteration, the individual learning factor and the global learning factor, combined with the best position of each particle before the current iteration, the global best position of the particle in the current iteration and the position of each particle after the current iteration, as well as the overall situation of all elements in each particle and all daily returns of each stock in the current iteration, the speed of each particle in the next iteration and the position after the iteration, as well as the fitness of each particle in the current iteration are determined; the stock investment portfolio is optimized in combination with the particle swarm algorithm.
2. The method for optimizing stock investment portfolio based on artificial intelligence according to claim 1, characterized in that: The expression of the historical market risk of each stock is: In the formula, F i represents the historical market risk of the i-th stock; B i , B j Respectively represent the beta coefficients of the i-th and j-th stocks; σ i represents the dispersion of the returns of all days of the i-th stock; n represents the number of stocks.
3. The method for optimizing stock investment portfolio based on artificial intelligence according to claim 1, characterized in that: The expressions of the iteration coefficients of the individual learning factor and the global learning factor under the current iteration are: The iteration coefficient of the individual learning factor in the current iteration is recorded as Co1, and the expression of Co1 is: In the formula, C 1,max represents the maximum value of the individual learning factor in all historical iterations; C 1,MC represents the range of individual learning factors in all historical iterations; t represents the current number of iterations; T represents the maximum number of iterations; Based on the maximum and range of the global learning factor in all historical iterations, the iteration coefficient of the global learning factor in the current iteration is obtained in the same way as the iteration coefficient of the individual learning factor.
4. The method for optimizing stock investment portfolio based on artificial intelligence according to claim 1, characterized in that: The process of obtaining the individual risk mean under the current iteration is: The product of the value of each stock in the individual best position of each particle in the current iteration and the historical market risk of each stock is calculated, and the sum of the products of all particles is calculated; the individual risk mean of the particles in the current iteration is positively correlated with the sum.
5. The method for optimizing stock investment portfolio based on artificial intelligence according to claim 1, characterized in that: The expressions of the individual optimal risk ratio and the global optimal risk ratio under the current iteration are: Where cl1 and cl2 represent the individual optimal risk proportion and the global optimal risk proportion in the current iteration respectively; P1 represents the individual risk mean of the particle in the current iteration; F k represents the historical market risk of the k-th stock; G k Represents the kth element in the global best position at the current iteration.
6. The method for optimizing stock investment portfolio based on artificial intelligence according to claim 1, characterized in that: The process of obtaining the individual learning factor and the global learning factor in the current iteration is: Calculate the ratio of the current number of iterations to the maximum number of iterations; record the individual learning factor adjustment coefficient under the current iteration as β, which is proportional to the ratio; record the global learning factor adjustment coefficient under the current iteration as α, where α+β=1; the expressions of the individual learning factor and the global learning factor under the current iteration are: C1=α×Co1+β×cl1 C2=α×Co2+β×Cl2 In the formula, C1 represents the individual learning factor in the current iteration; Co1 and cl1 represent the iteration coefficient and individual optimal risk ratio of the individual learning factor in the current iteration respectively; C2 represents the global learning factor under the current iteration; Co2 and cl2 represent the iteration coefficient and individual optimal risk ratio of the global learning factor under the current iteration respectively.
7. The method for optimizing stock investment portfolio based on artificial intelligence according to claim 1, characterized in that: The expression of the velocity of each particle in the next iteration and the position after iteration is: V y (t+1)=ω×V y (t)+r1×C1(t)×(P y ―X y (t))+r2×C2(t)×(G t ―X y (t)) X y (t+1)=X y (t)+V y (t+1) Where V y (t+1), V y (t) represents the velocity of particle y at the t+1th and tth iterations respectively; ω represents the preset inertia weight; r1 and r2 are both random numbers in the range [0,1]; C1(t) and C2(t) represent the individual learning factor and the global learning factor calculated at the tth iteration respectively; P y represents the optimal position of particle y after the t-1th iteration; G t represents the global optimal position of the particle at the tth iteration; X y (t), X y (t+1) represents the particle position of particle y after the tth and t+1th iterations respectively.
8. The method for optimizing stock investment portfolio based on artificial intelligence according to claim 1, characterized in that: The process of obtaining the fitness of each particle in the current iteration is: Calculate the reciprocal of the standard deviation of all daily returns of each stock; record the ratio of the reciprocal of the standard deviation of the kth stock to the sum of the reciprocal of the standard deviations of all stocks as U k , the fitness of the yth particle in the current iteration is recorded as L y , L y The expression is: Where, X y,k represents the kth element in the yth particle in the current iteration; Z k represents the mean of all daily returns of the k-th stock, and n represents the number of stocks.
9. The method for optimizing stock investment portfolio based on artificial intelligence according to claim 1, characterized in that: The stock investment portfolio optimization is specifically as follows: The dimension of the particles, the fitness of each particle, the number of iterations, the inertia weight, the initial position and the initial speed of the particles are used as the input of the particle swarm algorithm. Each iteration is performed through the speed of each particle in the next iteration, the position after the iteration and the method of obtaining the fitness, and the output is the global optimal solution; the probability of each stock being selected in the global optimal solution is regarded as the investment proportion, which is used as the stock investment optimization combination.
10. A stock portfolio optimization system based on artificial intelligence, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.