← Back to Blog

Genome (Chromosome) Algorithm by Santa Fe Institute

Peter Bieda

Author

Most traders are obsessed with linear regression or simple moving averages. I spent a long time manually tuning parameters until I realized the market is too non-stationary for fixed rules. If your strategy doesn't evolve, it dies.

I started digging into the Santa Fe Institute's research on "Genetic Algorithms for Trading" (GA). Instead of writing a strategy, I started writing Genomes.

Why Genetic Algorithms?

In a traditional setup, you have a rigid rule: If A and B, then Buy. In my GA framework, the rules themselves are the population. They compete. They mutate. They adapt.

  • Fixed Rules: Overfit silently and fail when regime shifts.
  • Genetic Algorithms: Built specifically for regime changes.

The Strategy Architecture

I broke my implementation down into four core "Species" that handle different market conditions.

1. The Trend Population

This group evolves to find the "perfect" lag. It doesn't just look at a 20-day SMA; it evolves the window length based on current volatility. If the market is choppy, the "Genome" shrinks its lookback window automatically to stay sensitive.

2. Mean-Reversion Regime

I use crossover logic here. When a population of mean-reversion rules starts losing "fitness" (profitability), the GA naturally rotates liquidity into the trend population. This beats most hedge-fund models because it doesn't wait for a human to realize the market has changed.

Blog image

3. Fitness as Survival

I stopped using Sharpe Ratio for fitness. It's too easy to game. Instead, I use Drawdown-to-Recovery metrics. In my code, if a rule can't recover from a 2% dip within X ticks, its genome is purged.

Key results across all models:

  • Genetic Algorithms (GA) learn optimal behavior without knowing the model
  • GA converges even when:
    • Least Squares diverges
    • Markets are unstable or regime-shifting
  • Agents learn both the environment and the objective function
  • GA naturally handles:
    • Non-stationarity
    • Multiple equilibria
    • Regime shifts
    • Noisy feedback loops

👉 This is exactly what real markets look like.

What We Should Build (Trading Interpretation)

Instead of:

  • predicting prices directly
  • fitting one fixed model

We evolve populations of trading rules and let profits select survivors.

Genome (Chromosome)

Each chromosome = one complete trading strategy

Example encoding:

[ indicator_params | position_rules | risk_rules ]
RSI_period = 14
RSI_buy < 30
RSI_sell > 70
MA_fast = 20
MA_slow = 100
StopLoss = 1.5%
TakeProfit = 4%
PositionSize = 2%

Binary, integer, or float encoding all work.

Fitness Function (Very Important)

Inspired directly by the paper’s profit-as-fitness principle:

fitness = (
    total_return
    - 0.5 * max_drawdown
    + sharpe_ratio
    - transaction_costs
)

Optional additions:

  • penalize overfitting
  • penalize excessive trades
  • reward stability across regimes

Selection Rule (From Paper)

Just like firms copying profitable firms:

Higher profit → higher reproduction probability

Use:

  • tournament selection
  • roulette wheel (paper-style)
  • rank-based selection

Genetic Operators

Exactly as in the paper:

OperatorPurposeReproductionCopy successful strategiesCrossoverCombine profitable sub-rulesMutationPrevent local optima & dead strategies

Critical Improvement from the Paper (Key Edge)

Arifovic introduces a fitness test before replacement:

Offspring only enters population if it performs better than parent

🔥 This is huge for trading.

Trading Translation:

  • Test offspring strategy on recent market window
  • Only allow it into population if:
fitness_offspring > fitness_parent

This:

  • stabilizes convergence
  • prevents performance collapse
  • adapts smoothly to regime shifts

ALGORITHM 1: GA-Evolved Indicator Trader (Best Starter)

Market Type

  • Stocks
  • ETFs
  • Crypto
  • Medium → high volatility

Strategy

GA evolves:

  • RSI thresholds
  • MA combinations
  • volatility filters
  • stop-loss / take-profit

Why It Works

  • GA learns which indicators matter
  • No assumption indicators are “true”
  • Rules die if they stop working
population = init_population()

for generation in range(N):
    results = backtest_population(population, data)
    
    parents = select(population, results)
    offspring = crossover(parents)
    offspring = mutate(offspring)
    
    offspring_results = backtest_population(offspring, recent_data)
    
    population = elitist_replace(
        population,
        offspring,
        results,
        offspring_results
    )

ALGORITHM 2: GA Market-Making / Mean-Reversion Learner

Inspired by competitive firms predicting price

Market Type

  • Range-bound
  • Sideways
  • Low volatility
  • SPY, QQQ, FX pairs

Chromosome Encodes

  • Fair value estimator
  • Entry deviation threshold
  • Exit rule
  • Inventory limit

Fitness:

profit - inventory_penalty - tail_risk

GA learns:

  • how aggressive to fade moves
  • when NOT to trade

ALGORITHM 3: Regime-Switching GA (Paper’s Biggest Hidden Gift)

Inspired by:

  • multiple equilibria
  • decentralized learning
  • stability under regime changes

Structure

  • Multiple GA populations
    • Trend regime
    • Mean-reversion regime
    • Volatility breakout regime

Each population competes.

Meta-GA selects which population trades now.

🔥 This beats most hedge-fund models.

ALGORITHM 4: Options Strategy Evolution (Advanced)

Genome

  • delta target
  • DTE
  • strike distance
  • spread width
  • volatility filter

Fitness:

expected_return
- gamma_risk
- vega_risk
- max_loss_penalty

GA naturally learns:

  • when selling premium works
  • when it dies (vol spikes)

Why GA Beats Neural Nets Here

Neural NetsGenetic AlgorithmsNeeds labeled dataUses profit directlyOverfits silentlyKills bad rules fastBlack boxInterpretable strategiesFixed architectureEvolves structureStruggles with regime shiftsBuilt for them