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:
BizzleBot
2026-03-20 23:20:42 +00:00
parent 0ddb4ab01b
commit e385765fda
5 changed files with 26 additions and 13 deletions
+9 -4
View File
@@ -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,
}