Genetic Algorithm engine for TradeStream — strategy parameter optimization using evolutionary algorithms.
Extracted from tradestreamhq/tradestream.
This repo contains the Jenetics-based GA engine that discovers optimal trading strategy parameters. It calls tradestream-backtest via gRPC as its fitness evaluator.
| Component | Technology |
|---|---|
| Language | Kotlin / Java 21 |
| GA Engine | Jenetics 7.2 |
| Pipeline | Apache Beam 2.62 on Flink |
| Build | Gradle (Kotlin DSL) |
| Messaging | Apache Kafka |
| Storage | PostgreSQL |
| Transport | gRPC / Protocol Buffers |
Defined in src/main/proto/protos/ga_service.proto.
| RPC | Description |
|---|---|
SubmitStrategySpec |
Kick off a GA optimization run for a given strategy/symbol/timeframe |
GetTopStrategies |
Retrieve top N strategies from a completed or in-progress run |
GetPerformance |
Get detailed performance metrics for a specific strategy |
Kafka (requests) tradestream-backtest
│ ▲
▼ │ gRPC: RunBacktest
┌─────────────┐ ┌────┴──────┐
│ Discovery │──────────►│ Fitness │
│ Pipeline │ │ Function │
│ (Beam) │◄──────────│ (remote) │
└──────┬──────┘ └───────────┘
│
┌────┴────┐
▼ ▼
Kafka PostgreSQL
(results) (persist)
- Discovery requests via Kafka or gRPC (
StrategyDiscoveryRequest) - GA parameters: population size, max generations, mutation/crossover rates
- Discovered strategies: Top N optimized parameter sets with fitness scores
- Run status:
SUBMITTED→RUNNING→COMPLETED
./gradlew buildRequires tradestream-backtest to be running on the configured gRPC endpoint.
./gradlew runThis repo does not contain TA4J or any strategy implementation code. All fitness evaluation is delegated to tradestream-backtest via gRPC. This separation allows:
- Independent scaling of GA compute vs. backtesting compute
- Swapping the backtesting engine without changing the GA
- Running multiple GA instances against a shared backtesting service