feat: interactive score history chart with time range selector + BTC price overlay
- Time range buttons: 30D, 90D, 6M, 1Y, 2Y, 4Y, ALL - BTC price overlay on right y-axis (orange dashed line) - Accumulation zone backgrounds (green/yellow/red shading) - Threshold lines at 65, 50, 35 - Tooltip shows score + zone label + BTC price - Uses backtest daily_scores for full history (not just score_history.jsonl) - Smart downsampling: daily for last 2yr, weekly before that - Chart height increased to 320px
This commit is contained in:
@@ -416,11 +416,17 @@ def run_backtest():
|
||||
}
|
||||
|
||||
# --- Build time series for charting ---
|
||||
# Downsample to weekly for chart efficiency
|
||||
# Smart downsampling: daily for last 2 years, weekly before that
|
||||
chart_data = []
|
||||
cutoff_2yr = daily_scores[-1]["date"][:4] # rough 2yr cutoff
|
||||
try:
|
||||
from datetime import datetime as dt, timedelta
|
||||
cutoff_date = (dt.strptime(daily_scores[-1]["date"], "%Y-%m-%d") - timedelta(days=730)).strftime("%Y-%m-%d")
|
||||
except:
|
||||
cutoff_date = "2024-01-01"
|
||||
for i, d in enumerate(daily_scores):
|
||||
# Include every 7th day + last day
|
||||
if i % 7 == 0 or i == len(daily_scores) - 1:
|
||||
is_recent = d["date"] >= cutoff_date
|
||||
if is_recent or i % 7 == 0 or i == len(daily_scores) - 1:
|
||||
chart_data.append({
|
||||
"date": d["date"],
|
||||
"score": d["score"],
|
||||
|
||||
Reference in New Issue
Block a user