Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Wickra Darwin — evolutionary strategy search at millions of backtests per second

Built on Wickra Status CI CodeQL License: MIT OR Apache-2.0 OpenSSF Scorecard Deterministic across 10 languages Docs


Wickra Darwin

Evolutionary strategy search at millions of backtests per second — mutates and crosses JSON strategy specs to brute-force alpha across the 514-indicator space.

Part of the Wickra ecosystem: Darwin evolves the same StrategySpec that wickra-backtest runs — mutation and crossover over that JSON genome, scored by the O(1)-per-tick engine, so the search evaluates candidates orders of magnitude faster than pandas-based tooling.

Wickra Darwin is one data-driven core, darwin-core: a population of StrategySpec genomes is evolved with genetic operators (mutation + crossover across the indicator search space) and each candidate is scored by wickra-backtest. Because the engine is O(1) per tick, the loop sustains a very high backtests-per-second rate — "AlphaZero for trading strategies." The core is exposed as a JSON-over-C-ABI data API (command_json) in Rust, Python, Node.js, WASM, C, C++, C#, Go, Java and R, plus a reference CLI.

Status

Early development (0.1.0, unreleased). The evolutionary core, the reference CLI, the ten-language binding surface, the golden corpus and the full CI matrix are in place; the first published release is still pending.

How it works

An EvolveSpec names a seed, a population and a generations count, mutation and crossover rates, a fitness objective (sharpe / pnl / calmar) and a SearchSpace — the indicators the genome may draw on and the RuleGrammar that wires them into entry/exit conditions. The core:

  1. seeds a SplitMix64 PRNG from seed and samples an initial population of StrategySpec genomes from the search space;
  2. scores every genome by running it through the wickra-backtest engine and reducing the equity curve to the chosen fitness value;
  3. ranks the population, keeps the elite, and breeds the next generation with crossover and mutation drawn from the same PRNG;
  4. repeats for generations rounds and returns an EvolveReport — the hall of fame (best genomes, ranked by fitness then spec_hash) plus per-generation statistics.

Determinism

The search is the golden moat: the SplitMix64 PRNG lives in the Rust core, the population is held in ordered collections, genomes are hashed from a canonical serialisation, and NaN/inf fitness collapses to NEG_INFINITY before ranking. The same EvolveSpec + candle data yields a byte-identical EvolveReport on every run, and — because each binding forwards the command string verbatim — in every language. The single-threaded and the rayon-parallel fitness paths are byte-identical by construction (each genome is scored independently).

Quickstart

# Evolve over a folder of candle CSVs and print the ranked hall of fame.
wickra-darwin --spec golden/specs/evolve_small.json --data golden/data

# Emit the full EvolveReport as JSON (hall of fame + per-generation history).
wickra-darwin --spec golden/specs/evolve_small.json --data golden/data --format json

# Override the seed without editing the spec — a different search, same machinery.
wickra-darwin --spec golden/specs/evolve_small.json --data golden/data --seed 42

Use in any language

The same handle + command_json + version surface ships for Rust, Python, Node.js, WASM, and — over a C ABI hub — C, C++, C#, Go, Java and R. Each binding passes the command string through verbatim, so the EvolveReport they return is identical.

import json
from wickra_darwin import Darwin

spec = open("golden/specs/evolve_small.json").read()
data = json.load(open("universe.json"))  # {"SYM": [{"time":..,"open":..,...}, ...]}
report = json.loads(Darwin(spec).command(json.dumps({"cmd": "evolve", "data": data})))
print(report["best"][0]["spec_hash"] if report["best"] else "no survivors")

See examples/ for the same program in all ten languages.

Documentation

Project layout

crates/darwin-core    the library: spec, search space, genome, evolve loop, fitness
crates/darwin-cli     the wickra-darwin CLI
crates/darwin-bench   criterion micro-benchmarks (backtests/second)
bindings/*            ten language surfaces (c, python, node, wasm, csharp, go, java, r)
golden/               specs + blessed reports (the cross-language corpus)
examples/             one runnable example per language
docs/                 architecture, evolution, genome, fitness, determinism, cookbook

Building from source

cargo build
cargo test

Benchmarks

The headline figure is backtests per second — the rate at which the loop scores candidate specs through the wickra-backtest engine. See BENCHMARKS.md; reproduce with cargo bench -p darwin-bench.

Requirements

  • Rust 1.86+ (MSRV). Darwin depends on the wickra-backtest engine (git).

Security

See SECURITY.md and THREAT_MODEL.md. Search runs on untrusted spec JSON — resource limits (population × generations) bound the work.

Contributing

See CONTRIBUTING.md.

Disclaimer

Wickra Darwin is a research tool, provided "as is" without warranty of any kind. Evolutionary search optimises a fitness objective over historical data — a strong in-sample fitness is not evidence of out-of-sample performance, and overfitting is the default outcome, not the exception. Nothing here is financial advice; any strategy you deploy is your responsibility, and trading carries risk of loss.

License

Dual-licensed under either of

at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.

About

Evolutionary strategy search at millions of backtests per second — mutates and crosses JSON strategy specs to brute-force alpha across the 514-indicator space.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages