This paper is based on covariance and expected return, building portfolio risk optimization model. Using Genetic Algorithm and Quadratic Programming, three securities portfolio Optimization model is resolved, and we find that Genetic Algorithm having priority for Restraint Conditions is not a linear model.
The number of securities transactions is generally limited in the capital market. For example, the minimum number of regular trading stocks is 100 shares, and trading less than 100 shares is not accepted in Shanghai Stock Exchange and Shenzhen Stock Exchange. On the other hand, for various considerations, investment institutions and investors often set certain requirements for funds allocation, and portfolio needs to meet these requirements. In order to adapt the need for capital market and practical operation, it is necessary to research portfolio decision problem under risk constraint. But it is difficult to express the portfolio optimization model under numeric constraint from existing literature [
Consider investment institution (e.g. Fund Company) or investors invest in n kinds of risky assets. We denote the expected returns and portfolio weights of risky assets by the vectors
However, it is difficult to obtain the optimal analytical expression for this problem, so we try to solve this problem by genetic algorithms.
1) Determine population size M, crossover probability pc, mutation probability pm, maximum evolution generation maxgen, the vector of upper and lower bounds
2) Use real-code, each chromosome contains n gene loci which represent insecurities, the genevaluation represents the proportion in securities portfolio.
3) It is easy to know the following super geometry contains feasible set from the constraints. Consider
normalize
If the result does not satisfy the constraint, reject it. Then we need to use the third step to generate a new chromosome, if the chromosome is feasible, we can accept it as a member of population, then we use the notation
4) Calculate the fitness value of
5) Set k = 0.
1) According to the principle that the more adaptable the chromosomes are, the more chance they would be selected to reproduce. Breeding probabilities for each
j = 1means that the chromosome is the best, j = M explains the chromosome is the worst.
2) Calculate the cumulative probability
3) Generate a random number r in
4) Repeat step 2 and 3 for m times in total, then we can obtain m replicated chromosomes denoted by
1) Define
2) We use the notation
3) We can use hybridization on the other group as the same way.
1) First, define the mutation probability pm. For the individuals through crossover operation mutate from j = 1 to M, repeat the following step: generate a random number r from [0,1], if
2) Generate random integer i and j from [1,n], random r1 and r2 are generated from (0,1), the mutation result value r that is the valuation of aij, aij represents the gene which is number I on the chromosome aij. Similarly, aij represents the gene which is number j on the chromosome aij. If the constraints are not satisfied, refuse the result. Follow step 2 to generate a new chromosome, if this one is feasible, accept it as a population member. It will generate s new mutated individuals after finite sampling.
3) Consider s new individuals by mutation operation and L-s new individuals that are not selected from hybridization in step 2, calculate their valuation. And then put them back simultaneously. There are M-L remaining individuals by choosing operation. All of them consist of a new generation denoted by
4) Termination test
If reach the maximum number of evolution, evolution is terminated, otherwise set k = k + 1, turn to the selection operation.
Obtain three monthly securities’ returns from financial database [
Serial number | Historical data | ||
---|---|---|---|
Stock 1 | Stock 2 | Bond | |
1 | 0 | 0.07 | 0.06 |
2 | 0.04 | 0.13 | 0.07 |
3 | 0.13 | 0.14 | 0.05 |
4 | 0.19 | 0.43 | 0.04 |
5 | −0.15 | 0.67 | 0.07 |
6 | −0.27 | 0.64 | 0.08 |
7 | 0.37 | 0 | 0.06 |
8 | 0.24 | −0.22 | 0.04 |
9 | −0.07 | 0.18 | 0.05 |
10 | 0.07 | 0.31 | 0.07 |
11 | 0.19 | 0.59 | 0.1 |
12 | 0.33 | 0.99 | 0.11 |
13 | −0.05 | −0.25 | 0.15 |
14 | 0.22 | 0.04 | 0.11 |
15 | 0.23 | −0.11 | 0.09 |
16 | 0.06 | −0.15 | 0.1 |
17 | 0.32 | −0.12 | 0.08 |
18 | 0.19 | 0.16 | 0.06 |
19 | 0.05 | 0.22 | 0.05 |
20 | 0.17 | −0.02 | 0.07 |
Calculate covariance matrix for three securities with function corvar() in Excel
Calculate expected return on three securities, denoted by R, with function average,
Consider the minimum expected return on the three securities is 0.13, calculate the optimal proportion and lowest risk under the condition of no short sale.
We use genetic function GA in Matlab, the program is as follows.
The M file by Genetic Algorithm denoted by tzga.m
Obj = @tzfitness;
Nvars = 3; % Number of variables
A = [−0.1130, −0.1850, −0.0755];
b = [−0.13]; Aeq = [1,1,1]; beq = [
LB = [0 0 0]; % Lower bound
UB = [1 1 1]; % Upper bound
% Constraint Function = @tzconstraint;
[x,fval] = ga(Obj,nvars,A,b,Aeq,beq,LB,UB,[
The function by genetic algorithm denoted by tzfitness.m
function y =tzfitness(x)
The results are running as the above program in Matlab as follows:
>> tzga
x = 0.5044 0.3245 0.1718
fval = 0.0143
Compare the above results and the results get by quadratic programming with Matlab function quadprog() [
As shown in
The result of Genetic Algorithm with function ga() in Matlab, | The result of quadratic programming with function quadprog() in Matlab | The result with solver tool for quadratic programming in excel | |
---|---|---|---|
Optimal proportion (x1, x2, x3) | (0.5044, 0.3245, 0.1718) | (0.5063, 0.3243, 0.1694) | (0.5063, 0.3243, 0.1693) |
The lowest risk of portfolio | 0.0143 | 0.0143 | 0.0151 |
adapted to linear and quadratic programming model. In addition to Quadratic Programming under liner, genetic algorithm can solve quadratic programming under nonlinear constraint, even to the complex model in which the objective function is a Nonlinear model that is not quadratic programming and the constraint is nonlinear, genetic algorithm also can solve it. Therefore, the advantages of genetic algorithms are incomparable in modeling complex social and economic life.
In order to make the portfolio optimization problems close to reality, we often need to study the portfolio optimization problem under numeric constraint. This paper is based on this model to calculate the optimal portion by code; selection, crossover and mutation are adapted to portfolio decisions successfully, and optimal solution can be obtained. In order to prove the reliability of the genetic algorithm, we use quadratic programming with function quadprog() in Matlab and solver tool for quadratic programming in excel to solve this problem. This paper shows that the genetic algorithm is better than quadratic programming, because the genetic algorithm can solve non-quadratic programming problems. It is foreseeable that in the future genetic algorithms will be used widely for practical application in portfolio optimization.
Zhu, S.Q. (2016) Research on the Portfolio Optimization Model under Quantitative Constraint Based on Genetic Algorithm. Journal of Mathematical Finance, 6, 465-470. http://dx.doi.org/10.4236/jmf.2016.64037
*This paper is supported by Guangdong Provincial Scientific Plan Project (Soft Science, No.: 2015-A070704058), Guangdong Provincial Universities’ Social Science Fund Project (No.: 2015WTSCX031), The Natural Science Foundation of Guangdong (No.: 2015A030313629), The Graduate Student Education Innovation Projects in Guangdong (No. 2-2015), and the National Natural Science Foundation of China.