Skip to content

feat(v0.2.0): multi-strategy architecture#5

Merged
luokerenx4 merged 3 commits intomasterfrom
feat/multi-strategy
Apr 23, 2026
Merged

feat(v0.2.0): multi-strategy architecture#5
luokerenx4 merged 3 commits intomasterfrom
feat/multi-strategy

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

Summary

v0.2.0 structural change: move from single-file iteration (one AutoResearch.py the agent mutates in place) to multi-strategy parallel (up to 3 files under user_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 .py in user_data/strategies/ (skipping _-prefixed), backtests each, prints one --- block per strategy. Per-strategy crashes don't block the others.
  • user_data/strategies/: old AutoResearch.py removed. New _template.py.example is 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.md rules, no versions/ changes. After this is merged and a v0.2.0 run completes, a separate archive-only PR will add versions/0.2.0/.

Smoke tests performed locally

  • Empty strategies/run.py exits 2 with clear "no strategies found" message
  • 1 strategy → single --- block, exit 0
  • 2 strategies → 2 --- blocks in order, distinct metrics, exit 0
  • 1 broken (NameError) + 2 working → broken gets status: ERROR block, working get full metrics, exit 1
  • All FreqTrade Python-API imports still resolve (Configuration, RunMode, Backtesting, StrategyResolver)

Test plan for reviewer

  • Read program.md for internal consistency — rules should be unambiguous (can an agent reading cold follow them?)
  • Verify run.py output format is grep-friendly
  • Sanity-check analysis.ipynb against a hand-crafted results.tsv with all 5 event types including fork
  • Confirm _template.py.example is skipped by run.py discovery (filename prefixed _)

🤖 Generated with Claude Code

luokerenx4 and others added 3 commits April 23, 2026 10:08
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>
@luokerenx4 luokerenx4 merged commit 40acd7b into master Apr 23, 2026
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