DEV Community

Nexus Intelligence Research
Nexus Intelligence Research

Posted on

Evolutionary Trading: Discovering Unknown Strategies with Genetic Algorithms

Evolutionary Trading: Discovering Unknown Strategies with Genetic Algorithms

Most trading systems start from human knowledge — known indicators, known rules, known patterns. But markets evolve, and what worked yesterday often fails tomorrow.

What if we let strategies evolve naturally instead of coding them by hand?

The Genetic Algorithm Approach

I built an evolutionary trader that uses genetic algorithms to discover profitable trading strategies from scratch:

@dataclass
class IndicatorGene:
    type: str  # rsi, ema, macd, bollinger, atr, stoch, adx, obv, vwap, cci...
    params: Dict[str, float]

@dataclass
class Genome:
    indicators: List[IndicatorGene]
    entry_rules: List[Condition]
    exit_rules: List[Condition]
    position_sizing: str  # fixed, kelly, volatility_scaled...
    risk_params: Dict[str, float]
    mutation_rate: float  # self-adapting
Enter fullscreen mode Exit fullscreen mode

Each agent has a genome — a unique combination of indicators, entry/exit rules, position sizing, and risk parameters.

Evolution Mechanics

  • Selection: Tournament selection (k=3) — best of 3 random agents survives
  • Crossover: Uniform crossover of genome segments
  • Mutation: Gaussian perturbation of parameters + structural mutations
  • Speciation: Protect new strategies from being killed too early
  • Elitism: Top 10% survive unchanged

Multi-Family Evolution

Instead of a single population, I run 5 family types in parallel:

  1. Specialist — focuses on 1-2 coins, deep expertise
  2. Generalist — trades across multiple coins
  3. Expansionist — explores new indicators aggressively
  4. Meta — learns from all other families
  5. Contrarian — diverges from consensus

Families compete head-to-head. The best strategies emerge from this competition.

Real-Time Data Integration

The system fetches real-time candles from 12 sources (cross-verified):

  • Bybit, Binance, OKX futures
  • Fear & Greed Index
  • Funding rates (900 symbols)
  • BTC dominance
  • Hyperliquid funding (234 assets)

This ensures strategies are tested on live market conditions, not just historical data.

Early Results (Generation 1)

specialist[SOL,HYPE]:  fitness=0.1228  WR=63.1%  profit=0.67%
specialist[BTC,ETH]:   fitness=0.0091  WR=53.6%  profit=0.85%
generalist[4 coins]:   fitness=0.0172  WR=46.3%  profit=0.20%
Enter fullscreen mode Exit fullscreen mode

The HYPE/SOL specialist already shows a 63.1% win rate after just 1 generation. With 5 generations and 50 genomes per family, the system discovers patterns humans would never think of.

Why This Works

Traditional approaches:

  • Start from zero
  • Learn known rules
  • Limited to human knowledge
  • Overfit to historical data

Evolutionary approach:

  • Starts random
  • Evolves through survival
  • Discovers unknown patterns
  • Adapts to current market conditions

The key insight: the Professor evaluates ONLY the outcome (profit, drawdown, Sharpe ratio) — never the HOW. This allows strategies to emerge that violate conventional wisdom but still profit.

CPU-Only Operation

The entire system runs on CPU — no GPU required. This is important for 24/7 operation on standard VPS hardware:

  • Population size: 50 genomes per family
  • 5 generations per cycle
  • ~10 seconds per generation on CPU
  • Continual learning loop: every 5 minutes

Next Steps

  • Increase population size to 200+ for more diversity
  • Add more indicator types (Ichimoku, Supertrend, Fibonacci)
  • Implement crossover between families (hybrid vigor)
  • Deploy on multiple timeframes (1m, 5m, 15m, 1h, 4h, 1d)

The goal is not to find the "perfect" strategy — it's to build a system that continuously adapts to changing market conditions.


This article is part of the Nexus Intelligence series on autonomous trading systems. The code is available on GitHub.

Top comments (0)