Fix backtest detail API — check historical/ subdirectory first
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.
This commit is contained in:
+5
-2
@@ -236,8 +236,11 @@ async def list_backtests():
|
|||||||
|
|
||||||
@app.get("/api/backtest/{name}")
|
@app.get("/api/backtest/{name}")
|
||||||
async def get_backtest(name: str):
|
async def get_backtest(name: str):
|
||||||
"""Get full backtest result data."""
|
"""Get full backtest result data — checks historical dir first."""
|
||||||
fpath = os.path.join(BACKTEST_DIR, f"{name}.json")
|
# 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):
|
if os.path.exists(fpath):
|
||||||
with open(fpath) as f:
|
with open(fpath) as f:
|
||||||
return JSONResponse(json.load(f))
|
return JSONResponse(json.load(f))
|
||||||
|
|||||||
Reference in New Issue
Block a user