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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user