add: 30d/90d/180d/365d forward returns in all backtest views
- Bracket table now shows Avg 30d, 90d, 180d, and 1yr columns - Signal events show all 4 timeframes - Current context shows all 4 average returns - Comparable examples show all available timeframes - Updated backtest screenshot
This commit is contained in:
@@ -361,11 +361,13 @@ def run_backtest():
|
||||
if abs(d["score"] - current_score) <= margin and d["forward_returns"]:
|
||||
comparable.append(d)
|
||||
|
||||
avg_1yr = None
|
||||
avg_returns = {}
|
||||
if comparable:
|
||||
yr_returns = [d["forward_returns"]["365d"] for d in comparable if "365d" in d["forward_returns"]]
|
||||
if yr_returns:
|
||||
avg_1yr = round(sum(yr_returns) / len(yr_returns), 2)
|
||||
for period in ["30d", "90d", "180d", "365d"]:
|
||||
vals = [d["forward_returns"][period] for d in comparable if period in d["forward_returns"]]
|
||||
if vals:
|
||||
avg_returns[period] = round(sum(vals) / len(vals), 2)
|
||||
avg_1yr = avg_returns.get("365d")
|
||||
|
||||
# Best comparable examples (most recent 5)
|
||||
examples = []
|
||||
@@ -383,6 +385,9 @@ def run_backtest():
|
||||
"percentile": percentile,
|
||||
"comparable_days": len(comparable),
|
||||
"avg_1yr_return": avg_1yr,
|
||||
"avg_30d_return": avg_returns.get("30d"),
|
||||
"avg_90d_return": avg_returns.get("90d"),
|
||||
"avg_180d_return": avg_returns.get("180d"),
|
||||
"examples": examples,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user