Fix ledger context being overridden by prescriptive initial prompt

The 13:20:03 run showed the ledger context was counterproductive: the
initial prompt's "Start with a multi-timeframe trend-following approach"
instruction caused the model to ignore the prior summary and repeat
EMA50-based strategies that produced 0 trades across all 15 iterations.

Two fixes:
- When prior_summary is present, replace the prescriptive starting
  instruction with one that explicitly defers to the ledger: refine the
  best prior strategy or try a different approach if all prior results
  were poor. Prevents the fixed instruction from overriding the context.
- Cap ledger entries per unique strategy at 3. A strategy repeated across
  11 iterations would contribute 33 entries, drowning out other approaches
  in the prior summary. 3 entries (one per instrument) is sufficient.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 13:54:35 +02:00
parent d76d3b9061
commit b476199de8
2 changed files with 17 additions and 4 deletions

View File

@@ -499,14 +499,22 @@ pub fn initial_prompt(instruments: &[String], candle_intervals: &[String], prior
Some(s) => format!("{s}\n\n"),
None => String::new(),
};
let starting_instruction = if prior_summary.is_some() {
"Based on the prior results above: if the best strategy has promising metrics, \
refine it. If all prior results were poor (0 trades or deeply negative Sharpe), try a \
clearly different indicator family or candle interval than what was already attempted. \
Do NOT repeat approaches that consistently produced 0 trades."
} else {
"Start with a multi-timeframe trend-following approach with proper risk management \
(stop-loss, time exit, and ATR-based position sizing)."
};
format!(
r#"{prior_section}Design a trading strategy for crypto spot markets.
Available instruments: {}
Available candle intervals: {}
Start with a multi-timeframe trend-following approach with proper risk management
(stop-loss, time exit, and ATR-based position sizing). Use "usdc" as the quote asset.
{starting_instruction} Use "usdc" as the quote asset.
Respond with ONLY the strategy JSON."#,
instruments.join(", "),