feat(v0.2.0): multi-strategy architecture#5
Merged
luokerenx4 merged 3 commits intomasterfrom Apr 23, 2026
Merged
Conversation
run.py now discovers every non-underscore-prefixed .py under user_data/strategies/ and runs Backtesting for each in sequence, printing one --- block per strategy. Per-strategy crashes produce a visible error block but do not abort the batch. Strategy surface changes: - Old single-file baseline user_data/strategies/AutoResearch.py removed (archived in versions/0.1.0/strategy.final.py for history). - New _template.py.example provides a skeleton IStrategy with the 5-field metadata docstring (Paradigm / Hypothesis / Parent / Created / Status) that the agent copies from to create real strategies. Smoke-tested: empty dir → exit 2 with clear message; 1 strategy → clean --- block + exit 0; 2 strategies → 2 blocks in order + exit 0; broken strategy alongside working ones → ERROR block for broken, full metrics for others, exit 1. Part of v0.2.0 — see plan at /Users/ame/.claude/plans/freqtrade-uv-lucky-pike.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
New rules the agent must follow: 1. Setup creates 1-3 starting strategies (not one pre-written baseline). Each MUST target a different paradigm — no 3 mean-reversion variants as a "safe start". That was the v0.1.0 anchoring failure mode. 2. Hard cap: 3 active strategies at any time. To add a 4th, first kill one. 3. Stagnation gate: 3 consecutive stable rounds forces the agent to evolve / fork / kill. Cannot sit idle longer with only 3 slots. 4. Kill via `git rm`; strategy file becomes history, not current state. 5. Every round must touch ≥ 1 strategy (not all-stable). 6. results.tsv schema is an event log now: commit | event | strategy_name | sharpe | max_dd | note. Events: create/evolve/stable/fork/kill. Preserves from v0.1.0: - NEVER STOP directive (verbatim) - Simplicity criterion spirit (but adapted to multi-strategy) - "LLM decides keep/kill, not a scalar rule" — now applied per strategy - "Goodhart watch" section expanded with v0.1.0's lessons (exit_profit_only, ROI clipping) - Strict contract: no CLI, no uv add, no editing prepare.py / run.py / config.json / _template Docs point agents to versions/0.1.0/retrospective.md for context on what v0.1.0 discovered and what it failed to explore (multi-timeframe, ATR, regime detection, etc.) — those are exactly the directions v0.2.0 should reach. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
analysis.ipynb rewrite for event-log schema: - Reads the new results.tsv columns (commit | event | strategy_name | sharpe | max_dd | note) - Handles fork strategy_name `parent→child` by canonicalizing to child - Derives active set from last-event-per-strategy (no stored state) - Per-strategy Sharpe trajectory plot (one line per strategy over its lifetime, with markers for create / evolve / fork / kill events) - Cap utilization over time (how often we sit at 3 active vs dip lower) - Peak Sharpe per strategy with alive/killed annotation - Event type distribution + note word frequency (catches paradigm anchoring if only one family dominates) README: - Replaces "THE one file the agent edits" framing with "the directory the agent owns" (up to 3 strategies, hard cap) - Adds link to versions/0.1.0/ archive explaining why we moved away from single-file iteration - Updates step 5 sanity check to reflect that fresh install has zero strategies and run.py correctly exits 2 with clear message - Expands Design notes with the new rules (stagnation, 3-cap, event log) - Project structure updated for multi-file strategies/ Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v0.2.0 structural change: move from single-file iteration (one
AutoResearch.pythe agent mutates in place) to multi-strategy parallel (up to 3 files underuser_data/strategies/, all backtested every round). Addresses the core v0.1.0 failure mode — the agent anchored on RSI mean-reversion for 99 rounds and never explored alternative paradigms.Full context in plan file + versions/0.1.0/retrospective.md.
Why
Karpathy's ML training domain has additive, orthogonal improvement directions (attention + optimizer + init all stack). Ours has substitutive directions — a strategy has one entry slot; switching paradigm throws away all tuning. Under the single-file model, paradigm exploration has high cost (discard all tuning) and low expected payoff (untuned new paradigm nearly always scores worse than tuned old paradigm). Agent rationally stays put.
Multi-strategy restores the additive property: each paradigm lives in its own file, paradigms don't compete for a single slot, agent can maintain and iterate 3 in parallel.
Changes
run.py: discovers every.pyinuser_data/strategies/(skipping_-prefixed), backtests each, prints one---block per strategy. Per-strategy crashes don't block the others.user_data/strategies/: oldAutoResearch.pyremoved. New_template.py.exampleis the skeleton agents copy from. Fresh installs start with zero real strategies — agent creates 1-3 during setup.program.md: full rewrite with new rules — hard cap 3 active strategies, 3-stable-round stagnation gate forcing evolve/fork/kill, every round must touch ≥1 strategy, paradigm diversity enforced at setup.results.tsv(in program.md): schema changed from per-round state to per-event log. Columns:commit | event | strategy_name | sharpe | max_dd | note. Events:create | evolve | stable | fork | kill. Active set is derived from event history.analysis.ipynb: adapted to new schema. Adds per-strategy Sharpe trajectory, cap utilization over time, alive-vs-killed peak Sharpe summary.README.md: reflects multi-strategy model; sanity check updated (empty install → exit 2 with clear message).Scope
Scaffold-only. Per
versions/README.mdrules, noversions/changes. After this is merged and a v0.2.0 run completes, a separate archive-only PR will addversions/0.2.0/.Smoke tests performed locally
strategies/→run.pyexits 2 with clear "no strategies found" message---block, exit 0---blocks in order, distinct metrics, exit 0status: ERRORblock, working get full metrics, exit 1Configuration,RunMode,Backtesting,StrategyResolver)Test plan for reviewer
program.mdfor internal consistency — rules should be unambiguous (can an agent reading cold follow them?)run.pyoutput format is grep-friendlyanalysis.ipynbagainst a hand-craftedresults.tsvwith all 5 event types includingfork_template.py.exampleis skipped byrun.pydiscovery (filename prefixed_)🤖 Generated with Claude Code