diff --git a/dashboard/server.py b/dashboard/server.py index 78b21ee..212a4e4 100644 --- a/dashboard/server.py +++ b/dashboard/server.py @@ -440,13 +440,41 @@ app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static") @app.get("/api/quant-report/{name}") async def get_quant_report(name: str): - """Compute full QF-Lib quant report from a backtest file.""" - backtest_path = os.path.join(BACKTEST_DIR, name) - if not os.path.exists(backtest_path): - # Try historical - hist_path = os.path.join(HISTORICAL_DIR, name) - if os.path.exists(hist_path): - backtest_path = hist_path + """Compute full QF-Lib quant report from a backtest file. + Accepts either an exact filename or a strategy-name prefix. + """ + # Build candidate paths + candidates = [] + exact_path = os.path.join(BACKTEST_DIR, name) + hist_exact = os.path.join(HISTORICAL_DIR, name) + candidates.extend([exact_path, hist_exact]) + + # Try exact match first + for path in candidates: + if os.path.exists(path): + backtest_path = path + break + else: + # Fuzzy match: look for files containing the name + for d in [BACKTEST_DIR, HISTORICAL_DIR]: + if not os.path.exists(d): continue + for f in os.listdir(d): + # Match: name is a substring of filename (case insensitive) + name_clean = name.lower().replace(" ", "_").replace(".json", "") + f_clean = f.lower() + if name_clean in f_clean or f_clean.startswith(name_clean): + candidates.append(os.path.join(d, f)) + if not candidates: + # Try partial match on strategy name + for d in [BACKTEST_DIR, HISTORICAL_DIR]: + if not os.path.exists(d): continue + for f in os.listdir(d): + parts = f.lower().replace(".json", "").split("_") + name_parts = name.lower().replace(" ", "_").split("_") + if all(p in parts for p in name_parts): + candidates.append(os.path.join(d, f)) + if candidates: + backtest_path = candidates[0] else: return JSONResponse({"error": f"Backtest '{name}' not found"}, status_code=404) try: diff --git a/dashboard/static/index.html b/dashboard/static/index.html index b6672b2..cf75143 100644 --- a/dashboard/static/index.html +++ b/dashboard/static/index.html @@ -1 +1 @@ -FTDT Quant Lab

FTDT Quant Lab

Live Testnet · Equity $—

OFFLINE
\ No newline at end of file +FTDT Quant Lab

FTDT Quant Lab

Live Testnet · Equity $—

OFFLINE
\ No newline at end of file