From 392bde44a081da5d3448aeacab8108324ef4b9ce Mon Sep 17 00:00:00 2001 From: ramseshk Date: Thu, 6 Aug 2026 07:44:07 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20backtest=20detail=20API=20=E2=80=94=20che?= =?UTF-8?q?ck=20historical/=20subdirectory=20first?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: /api/backtest/{name} only looked in backtests/results/, but all historical backtests are saved in backtests/results/historical/. Fix: check HISTORICAL_DIR first, then fall back to BACKTEST_DIR. This fixes SPX backtest detail showing zero prices/fees. --- dashboard/server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dashboard/server.py b/dashboard/server.py index 933929b..c53df94 100644 --- a/dashboard/server.py +++ b/dashboard/server.py @@ -236,8 +236,11 @@ async def list_backtests(): @app.get("/api/backtest/{name}") async def get_backtest(name: str): - """Get full backtest result data.""" - fpath = os.path.join(BACKTEST_DIR, f"{name}.json") + """Get full backtest result data — checks historical dir first.""" + # Try historical subdirectory first (where dashboard saves backtests) + fpath = os.path.join(HISTORICAL_DIR, f"{name}.json") + if not os.path.exists(fpath): + fpath = os.path.join(BACKTEST_DIR, f"{name}.json") if os.path.exists(fpath): with open(fpath) as f: return JSONResponse(json.load(f))