Backtest Analysis
Use an LLM to evaluate backtest results — get a performance score (1-10), strengths, weaknesses, risk assessment, and actionable improvement suggestions.
Quick Usage
import vibetrading.strategy
import vibetrading.backtest
results = vibetrading.backtest.run(strategy_code, interval="1h", data=data)
report = vibetrading.strategy.analyze(
results,
strategy_code=strategy_code,
model="gpt-4o",
)
print(f"Score: {report.score}/10")
print(report.summary)BacktestAnalysisResult
The analysis returns a BacktestAnalysisResult with the following fields:
score
int
Overall score (1-10)
summary
str
2-3 sentence assessment
strengths
list[str]
What the strategy does well
weaknesses
list[str]
Problems to address
risk_assessment
str
Risk evaluation
suggestions
list[str]
Actionable improvement recommendations
detailed_analysis
str
Multi-paragraph deep analysis
raw_metrics
dict
The metrics dict that was analyzed
Scoring Guidelines
9-10
Exceptional
Sharpe > 2.0, drawdown < 10%, strong win rate
7-8
Good
Positive risk-adjusted returns, manageable drawdowns
5-6
Mediocre
Marginal returns or concerning risk metrics
3-4
Poor
Negative returns or extreme drawdowns
1-2
Failing
Liquidation, massive losses, or non-functional
Reading the Report
Feeding Analysis Back to the Generator
The analysis result includes format_for_llm() — a method that converts the report into structured feedback suitable for a follow-up generation call:
Or use vibetrading.strategy.generate() and vibetrading.strategy.analyze() in a loop to iterate manually.
Detail Levels
Control how much data is sent to the LLM:
Using BacktestAnalyzer Directly
For repeated analysis or custom configuration:
Last updated
