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:
@@ -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(", "),
|
||||
|
||||
Reference in New Issue
Block a user