Skip to content

feat: natural language to StrategyDNA seed generation#40

Merged
NeuZhou merged 1 commit intomasterfrom
feat/nl-dna-seed
Apr 13, 2026
Merged

feat: natural language to StrategyDNA seed generation#40
NeuZhou merged 1 commit intomasterfrom
feat/nl-dna-seed

Conversation

@NeuZhou
Copy link
Copy Markdown
Owner

@NeuZhou NeuZhou commented Apr 13, 2026

What

Adds a Natural Language → StrategyDNA Seed feature that lets users describe a trading strategy in plain English/Chinese and get a JSON DNA file to seed the genetic algorithm.

Why

  • Bridges the gap between human intent and GA parameter space (74 dimensions)
  • Gemini's Add crypto market support (Binance, Coinbase) #1 recommendation: build a 'Human-to-Quant' bridge via LLM
  • Rated as key to moving product readiness from D to B tier

Changes

New Files

  • *\stratevo/ai_strategy/dna_generator.py* — DNAGenerator class with async/sync generate methods, JSON extraction, validation with range clamping
  • *\ ests/test_dna_generator.py* — 39 tests (7 test classes)

Modified Files

  • *\stratevo/ai_strategy/prompt_templates.py* — DNA schema prompt with all 74 fields (types, defaults, ranges, descriptions) + 41 factor descriptions
  • *\stratevo/cli/main.py* — --output-format code|dna\ for generate-strategy, --seed-dna\ for evolve
  • *\stratevo/cli/commands/strategy.py* — Pass seed_dna_path to AutoEvolver
  • *\stratevo/evolution/auto_evolve.py* — seed_dna_path support in init/evolve
  • *\ ests/snapshots/evolve.txt* — Updated for new --seed-dna arg

Usage

\\�ash

Generate DNA seed from natural language

stratevo generate-strategy 'BTC恐惧时抄底,RSI超卖买入' --output-format dna -o btc_seed.json

Use it to seed evolution

stratevo evolve --seed-dna btc_seed.json --market crypto --generations 100
\\

Tests

  • 39 new tests covering prompts, JSON extraction, validation, generator (mocked LLM), CLI args, seed loading, edge cases
  • 211 existing tests still pass (0 regressions)

- Add DNAGenerator class (stratevo/ai_strategy/dna_generator.py) that translates
  natural language descriptions into valid StrategyDNA JSON via LLM
- Add comprehensive DNA schema prompt with all 74 fields, types, ranges, and
  descriptions for accurate LLM generation
- Add --output-format (code|dna) to generate-strategy CLI command
- Add --seed-dna to evolve CLI for starting evolution from custom DNA seed
- Support seed_dna_path in AutoEvolver for file-based DNA initialization
- 39 new tests covering prompts, JSON extraction, validation, generator,
  CLI args, seed loading, and edge cases (Chinese input, roundtrip, etc.)
- Update evolve CLI snapshot

Usage:
  stratevo generate-strategy 'momentum with tight stops' --output-format dna -o seed.json
  stratevo evolve --seed-dna seed.json --market crypto
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 68.38235% with 43 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
stratevo/cli/main.py 11.53% 23 Missing ⚠️
stratevo/evolution/auto_evolve.py 15.38% 11 Missing ⚠️
stratevo/ai_strategy/dna_generator.py 90.32% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

@NeuZhou NeuZhou merged commit 07be8dc into master Apr 13, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant