7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
1/17
PORTFOLIO ALLOCATIONPORTFOLIO ALLOCATION
FOR THE ACTIVE TRADERFOR THE ACTIVE TRADERUsing Genetic Algorithm TechnologyUsing Genetic Algorithm Technology
PERRY J . KAUFMANPERRY J . KAUFMAN
SpecialistSpecialist ininproductproduct developmentdevelopmentandandfinancialfinancial engineeringengineering
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
2/17
Proper Allocation is ImportantProper Allocation is Important
The amount allocated can change failure toThe amount allocated can change failure to
successsuccess or success to failureor success to failure
It considers the risk of each marketIt considers the risk of each market
It considers the correlation in returnsIt considers the correlation in returnsbetween each pair of marketsbetween each pair of markets
20%
Microsoft
25%
U.S.
notes
15%
Crude oil
5%
Gold
stocks
35%
Cisco
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
3/17
Allocation ObjectivesAllocation Objectives
In general, equalizing the risk of eachIn general, equalizing the risk of each
market maximizes diversificationmarket maximizes diversification
In general, allocating equally acrossIn general, allocating equally across
correlated groups maximizes diversificationcorrelated groups maximizes diversification
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
4/17
Everyone Uses MarkowitzEveryone Uses Markowitz Markowitz is the creator of MPTMarkowitz is the creator of MPT
Modern Portfolio TheoryModern Portfolio Theory
Expected risk is the portfolio varianceExpected risk is the portfolio variance
RR
22 = = wwii22ii
22 + + wwiiwwjjCCijij
Note thatNote thatis theis thestandard deviation (risk)standard deviation (risk)
Note thatNote thatCCijij
are theare thecrosscross--correlationscorrelations
Note thatNote that wwii are theare theweighting factorsweighting factors
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
5/17
Most Traders Have Disjoint ReturnsMost Traders Have Disjoint Returns MPT is intended to use continuous returns, such as stockMPT is intended to use continuous returns, such as stock
prices expressed as a percentage return seriesprices expressed as a percentage return series
Real trading is not always in the market; returns areReal trading is not always in the market; returns aredisjointdisjoint separated by periods of zero (no activity)separated by periods of zero (no activity)
Periods of zero returns artificially makePeriods of zero returns artificially make smaller andsmaller andcreate suspicious covariance valuescreate suspicious covariance values
-0.5
0
0.5
1
1.5
2
2.5
3
3.5
4
%Returns
No market positions
Risk is grea ter w hen
there are positions
in both markets
Risk is less
whe n only one
market has an
oen position
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
6/17
The Genetic AlgorithmThe Genetic Algorithm
If MPT does not show the true risk ofIf MPT does not show the true risk of
trading, then another method is neededtrading, then another method is needed
A Genetic Algorithm solves this problemA Genetic Algorithm solves this problem
It is a very powerful search method that isIt is a very powerful search method that isbased on the concepts ofbased on the concepts ofreproductionreproduction andand
survival of the fittestsurvival of the fittest
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
7/17
Genetic Algorithm ProcessGenetic Algorithm Process1.1. Start with aStart with agene poolgene pool
2.2. RankRank the best attributesthe best attributes
3.3. PropagatePropagatethethesurvival of the fittestsurvival of the fittest
4.4. MateMate5.5. IntroduceIntroducemutationsmutations
6.6. Cycle into step 2Cycle into step 2
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
8/17
Gene PoolGene Pool Create of GeneCreate of Gene
Pool using randomPool using randomnumbers betweennumbers between0 and 1.00 and 1.0
Each line is a newEach line is a newportfolioportfolio
Scale betweenScale between
0 and 1.0,0 and 1.0,sum = 1.0sum = 1.0
Portfolio 1 2 3 4 5
1 0.65 0.33 0.59 0.94 0.08 2 0.42 0.87 0.17 0.01 0.66
3 0.30 0.09 0.98 0.97 0.44
4 0.13 0.27 0.57 0.99 0.22
5 0.08 0.61 0.16 0.51 0.41
6 0.82 0.98 0.60 0.76 0.97
7 0.52 0.93 0.61 0.45 0.86
8 0.25 0.39 0.41 0.45 0.75
9 0.76 0.61 0.89 0.59 0.33
10 0.58 0.76 0.14 0.14 0.86
11 0.70 0.69 0.77 0.57 0.17
12 0.53 0.69 0.24 0.20 0.85
. 0.93 0.80 0.16 0.35 0.23
. 0.50 0.29 0.27 0.92 0.99
. 0.97 0.28 0.38 0.57 0.66
ASSET (RANDOM ALLOCATION)
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
9/17
Scaling the Pool into Weighting FactorsScaling the Pool into Weighting Factors
Total each row and divide by the totalTotal each row and divide by the total
2.860.660.570.380.280.97.
2.970.990.920.270.290.50.
2.470.230.350.160.800.93.
2.510.850.200.240.690.5312
2.900.170.570.770.690.7011
2.480.860.140.140.760.5810
3.180.330.590.890.610.769
2.250.750.450.410.390.258
3.370.860.450.610.930.527
4.130.970.760.600.980.826
1.770.410.510.160.610.085
2.180.220.990.570.270.134
2.780.440.970.980.090.303
2.130.660.010.170.870.422
2.590.080.940.590.330.651
Total54321Portfolio
ASSET (RANDOM ALLOCATION)
1.000.230.200.130.100.34.
1.000.330.310.090.100.17.
1.000.090.140.060.320.38.
1.000.340.080.100.270.2112
1.000.060.200.270.240.2411
1.000.350.060.060.310.2310
1.000.100.190.280.190.249
1.000.330.200.180.170.118
1.000.260.130.180.280.157
1.000.230.180.150.240.206
1.000.230.290.090.340.055
1.000.100.450.260.120.064
1.000.160.350.350.030.113
1.000.310.000.080.410.202
1.000.030.360.230.130.251
Total54321Portfolio
ASSET (RESCALED VALUES)
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
10/17
Gene Pool RescalingGene Pool Rescaling
with Whole Numberswith Whole Numbers100
Portfolio 1 2 3 4 5 Total 1 2 3 4 5
1 0.07 0.74 0.87 0.13 0.47 2.28 3 33 38 6 212 0.20 0.62 0.77 0.30 0.70 2.59 8 24 30 11 27
3 0.41 0.22 0.04 0.50 0.54 1.71 24 13 2 29 31
4 0.60 0.52 0.79 0.10 0.26 2.27 27 23 35 4 11
5 0.72 0.66 0.53 0.70 0.04 2.65 27 25 20 27 1
6 0.75 0.77 0.60 0.99 0.77 3.87 19 20 15 26 20 7 0.41 0.70 0.62 0.83 0.45 3.01 14 23 21 27 15
8 0.54 0.15 0.30 0.09 0.66 1.74 31 8 17 5 38
9 0.13 0.07 0.59 0.89 0.00 1.68 8 4 35 53 0
10 0.02 0.80 0.49 0.17 0.47 1.94 1 41 25 9 24
11 0.61 0.53 0.89 0.83 0.32 3.18 19 17 28 26 10 12 0.02 0.21 0.63 0.25 0.41 1.53 2 14 41 16 27
. 0.15 0.88 0.96 0.22 0.06 2.27 7 39 42 10 3
. 0.91 0.91 0.44 0.47 0.12 2.86 32 32 16 17 4
. 0.04 0.80 0.57 0.77 0.70 2.88 1 28 20 27 24
ASSET (RANDOM ALLOCATION) SCALE BETWEEN 0 AND 100
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
11/17
PropagationPropagation Using portfolio 1Using portfolio 1
allocations,allocations,calculate returns,calculate returns,
risk, and ratio ofrisk, and ratio of
return/riskreturn/risk
Find all ratiosFind all ratios
Sort by ratioSort by ratio
1 2 3 4 5 Daily Total
0.19 0.07 0.20 0.39 0.14 Return Return
19990104 0 0 -0.241 0 -0.018 -0.050 -0.050
19990105 0 0 0.184 0 0.120 0.054 0.004
19990106 0 0 0.084 0 0.190 0.044 0.048
19990107 0 0.008 0.182 0 0 0.036 0.084
19990108 0 0.041 0.011 0 0 0.005 0.089
19990111 0 0.142 0.166 0.198 0 0.121 0.210
19990112 0 0 0 0.040 0.023 0.019 0.229
19990113 -0.029 0.028 0 0.010 - 0.070 -0.010 0.219
19990114 0.048 0.128 0 -0.373 0.460 -0.062 0.157
19990115 0.012 0.034 0 0.100 0 0.044 0.201
19990119 0.003 0 0 0.417 0
0.165 0.36619990120 0.097 0.103 0 0.050 0 0.046 0.412
19990121 -0.179 -0.102 0 0.710 0 0.238 0.649
19990122 -0.064 -0.107 0 0.057 0 0.003 0.652
19990125 0 0.121 -0.008 0.040 - 0.018 0.020 0.672
19990126 -0.017 0.052 -0.011 -0.733 -0.150 -0.312 0.360
19990127 -0.088 -0.098 -0.145 0.057 -0.020 -0.033 0.327
19990128 0 - 0.002 - 0.065 - 0.462 - 0.208 -0.225 0.102
19990129 0 -0.078 0.159 0 0 0.026 0.127
19990201 0 0.117 0.063 0 0 0.021 0.14819990202 -0.026 0.02 -0.142 0 0 -0.032 0.116
19990203 -0.055 -0.006 0.101 0 0 0.009 0.125
19990204 0.056 0.132 -0.122 0 0 -0.004 0.121
19990205 0.067 0.045 0.056 -0.013 0 0.022 0.143
19990208 0.039 0 -0.034 -0.212 0 -0.083 0.061
19990209 -0.003 0 -0.038 0 0.122 0.010 0.070
19990210 -0.021 0 0.121 0 -0.080 0.008 0.078
19990211 -0.03 0 -0.119 0 0.220 0.003 0.081
19990212 -0.009 0 0.057 0.017 0 0.016 0.09719990216 0.145 - 0.014 0.023 -0.205 0 -0.049 0.048
19990217 -0.045 -0.046 0.036 0.420 0.103 0.176 0.224
Standard deviation = 0.1011
Rate of return = 0.224
Annua lize d standard devia tion = 0.8218
Annua lize d rate of return = 1.8181
RETURN RATIO 2.2123
RETURNS OF PORTFOLIO 1
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
12/17
How Much to Propagate?How Much to Propagate?
(Make more copies of the best)(Make more copies of the best)
Sort portfolios by rankSort portfolios by rank
Get a random number between 3.5 and 5.2Get a random number between 3.5 and 5.2 Create as many copies as the closest rank toCreate as many copies as the closest rank to
the random numberthe random number
(if random number is 4.9, make 5 copies)(if random number is 4.9, make 5 copies)
Put the copies into a new poolPut the copies into a new pool
5.2 4.5 4.1 3.8 3.6 3.5 3.5
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
13/17
MatingMating
Pick 2 portfolios at random from the poolPick 2 portfolios at random from the pool
Pick a random point from 0 to 5 assetsPick a random point from 0 to 5 assets
Switch the left allocationsSwitch the left allocations
Mate all of the portfolios in the poolMate all of the portfolios in the pool
1 2 3 4 5
A B C D E
A B 3 4 5
1 2 C D E
RANDOM POINT
SWITCH LEFT ASSETS
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
14/17
Mutating Creates New PossibilitiesMutating Creates New Possibilities
Choose a portfolio atChoose a portfolio at
randomrandom Choose an asset atChoose an asset at
randomrandom
Choose a newChoose a newallocation at randomallocation at random
Rescale portfolioRescale portfolio
Mutate 1 asset in 10%Mutate 1 asset in 10%
of all portfoliosof all portfolios
Portfolio 1 2 3 4 5
1
2
3
4
5
67
8
9
10
1112
.
.
.
ASSET
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
15/17
Why Mutate?Why Mutate? If you donIf you dont mutate, then you can only findt mutate, then you can only find
the best result from combinations in thethe best result from combinations in theoriginal pool. The bigger the pool, the moreoriginal pool. The bigger the pool, the more
combinations. This is calledcombinations. This is called prematurepremature
convergence.convergence.
Too much mutation may change all the bestToo much mutation may change all the best
combinations and you may lose the bestcombinations and you may lose the bestresults. We may getresults. We may get no convergence.no convergence.
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
16/17
Cycle Back to RankingCycle Back to Ranking Are We Done?Are We Done?
If there are noIf there are no
portfolios withportfolios withhigher ratios,higher ratios,
then we are done.then we are done.
Create pool
Calculate ratios
Are we done?
Propagate best
Mate
Mutate
yes
7/29/2019 PerryKaufmanAsignacionDeCarterasParaTraders
17/17
More About Genetic AlgorithmsMore About Genetic Algorithms A GA searches for the global maximumA GA searches for the global maximum
50 x 50 x50 x 50 x
x 50 (100 times) combinationsx 50 (100 times) combinations
It may find a local maximumIt may find a local maximum
Repeat the search 5 times for a better chanceRepeat the search 5 times for a better chance
Each search takes about 10 minutesEach search takes about 10 minutes
1 . Assets . 50
Returns
Global maximum
Local maximum
CONTOUR MAP OFPOSSIBLE RETURNS
Weights
1% to100%