fix: dashboard errors — Math.abs, API routing, fetchHistorical guard

Fixes three bugs in dashboard:

1. vbt.html: bare abs(dd) → Math.abs(dd) — fixes ReferenceError
2. server.py: Add /cv/ routing for Next.js quant dashboard
   - Mount _next static assets at /cv/_next (not /cv/ which eats API routes)
   - Add /cv/api/* routes for backtests/historical, detail, recalc, risk
   - Add /cv/ws WebSocket endpoints for live/paper metrics
   - Add /cv/ catchall for Next.js HTML pages
3. dashboard-next/src/lib/api.ts: add res.ok guard to fetchHistorical()
   — prevents SyntaxError when API returns HTML error pages
4. sim/maker.py: guard observe() against zero mid_price
This commit is contained in:
ramseshk
2026-08-07 15:19:18 +08:00
parent e58c5951b7
commit 870df57051
52 changed files with 188 additions and 215 deletions
+3
View File
@@ -59,6 +59,8 @@ class AvellanedaStoikovMaker:
def observe(self, mid_price: float):
"""Feed a new mid price observation for volatility estimation."""
if mid_price <= 0:
return
self._prices.append(mid_price)
if len(self._prices) > self._cfg.volatility_window:
self._prices = self._prices[-self._cfg.volatility_window:]
@@ -67,6 +69,7 @@ class AvellanedaStoikovMaker:
returns = [
math.log(self._prices[i] / self._prices[i - 1])
for i in range(1, len(self._prices))
if self._prices[i - 1] > 0
]
if returns:
mean = sum(returns) / len(returns)