Evolving Portfolio Weights: A Genetic Algorithm Approach to Mean Reversion
In my previous post, I examined various weighting strategies within the S&P 500’s top 20 stocks and illustrated the phenomenon of regression toward the mean in financial markets.
In this post, I take a different approach: applying a genetic algorithm (GA) to the same problem. The question is whether an evolutionary process — driven by selection, crossover, and mutation — will reveal similar patterns of convergence and mean reversion.
Genetic Algorithm 101
A genetic algorithm is inspired by natural selection. Populations evolve over generations, with fitter individuals more likely to reproduce. Through operators such as:
Selection → choosing parents based on fitness
Crossover → combining genes from parents
Mutation → introducing random variation
…the population gradually adapts toward better solutions.
Algorithm Setup
For this portfolio problem, the gene sequence is an array of weights for the top 20 S&P 500 stocks: {w1, w2, …, w20}, and the total weight should be 100.
The GA procedure is:
Initialize a population with random weight setups.
Evaluate fitness (annual return of each portfolio). Higher fitness increases reproduction probability.
Generate offspring by selecting parents and applying crossover/mutation until the population size is restored.
Replace population with offspring and repeat until the maximum generation is reached.
Crossover Approaches
I tested two crossover methods:
Gene Blending → offspring genes are linear combinations of parent arrays.
Gene Split → arrays are split in half and recombined from each parent.
Results: Gene Blending
Fitness distribution: Returns quickly converged to a narrow range with slightly higher median scores.
Top vs. bottom portfolios: Over generations, weights became increasingly even, reflecting a tendency toward balance.
Results: Gene Splitting
Fitness distribution: Median scores rose steadily in early generations, then stabilized.
Variation: Wider distributions persisted, with more outliers than in gene blending.
Top vs. bottom portfolios: Less even than blending, but also no power law distribution like market cap, and retained strong traits across generations.
This approach produced slightly better overall performance in later generations, though the weight setups are more complex than simple equal-weight strategies.
Comparing Portfolios
One of the best-performing GA portfolios in the final generation was compared against:
Top 10 Equal-Weight
Top 11–20 Equal-Weight
Key Observations
Boom cycles (late 1990s, 2018–2020): GA portfolio performed comparably to Top 10 Equal-Weight.
Contraction cycles (2002–2008): The GA portfolio showed resilience similar to Top 11–20 Equal-Weight.
Overall performance: Outperformed both equal-weight strategies by ~1.4–1.6% annually.
Over 35 years, this small advantage compounded dramatically (with initial investment: $100K in 1990):
GA portfolio: ~$4.3 million
Equal-weight portfolios: ~$2.6–2.8 million
Conclusion
Applying a genetic algorithm to portfolio weighting reveals how evolutionary processes can balance risk and reward.
Gene blending converges quickly but favors even distributions.
Gene splitting maintains diversity and captures stronger traits, leading to better long-term performance.
The GA portfolio demonstrates both boom-cycle upside and downside resilience, echoing the dynamics of regression toward the mean while compounding small advantages into significant gains.
While complex to implement in real-world scenarios, this experiment shows that evolutionary algorithms can uncover weighting strategies that outperform traditional equal-weight approaches — and highlight the subtle interplay between concentration, resilience, and mean reversion in financial markets.
Comments
Post a Comment