Commit Graph

7 Commits

Author SHA1 Message Date
ramseshk 870df57051 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
2026-08-07 15:19:18 +08:00
ramseshk b13ce68fef fix: inverted condition in loadResults — new API response format was falling into wrong branch 2026-08-07 14:17:03 +08:00
ramseshk 6889e06a86 feat: VBT dashboard overhaul — pagination, caching, LTTB downsampling, deep links, export, more metrics
- Merge vbt_server.py into server.py (eliminate duplicated VBT API)
- Add server-side pagination (offset/limit) with metadata (total, has_more)
- Add server-side ?asset= filtering to results endpoint
- Add JSON file caching with 5s TTL to avoid re-parsing on every request
- Add LTTB (Largest-Triangle-Three-Buckets) downsampling for equity curves
- Add pre-computed drawdown curve to result detail response
- Add /api/vbt/result/{filename}/csv endpoint for trade export
- Add Calmar ratio and expectancy to results metadata
- Rebuild vbt.html frontend with:
  - URL hash deep-linking (#filename) for bookmarkable views
  - JSON and CSV export buttons in detail panel
  - More metrics: Calmar, Sortino, Expectancy, End Equity (10 total)
  - Running backtest progress indicator with elapsed seconds
  - Pagination controls (prev/next) with page info
  - Filter/sort changes auto-apply (no manual refresh needed)
  - Better error states with retry buttons
  - Run strategy selector independent of filter
2026-08-07 14:14:40 +08:00
ramseshk 887a33f278 feat: trade log table, strategy params panel, B+W color scheme
Dashboard:
- Trade log table: all trades with time, side, size, entry/exit price, PnL, duration
  in scrollable panel below charts
- Strategy params panel: displays all coefficients (z_entry, gamma, obi_entry,
  grid_levels, etc.) for the selected strategy
- Color scheme: professional black/white
  • positive: #03A9F4 (light blue)
  • negative: #FF5252 (red)
  • neutral: #777 (gray)
  • backgrounds: #0a0a0a / #111 / #181818
  • borders: #222 / #333

VBT runner:
- _extract_metrics now captures trades from pf.trades.records_readable
  (Avg Entry Price, Avg Exit Price, PnL, Return, Duration, Direction)
- _strategy_params() returns key coefficients per strategy type
- _empty_result includes empty trades/params

New vbt_server.py: minimal standalone dashboard (no live trading machinery,
no memory guard, no broadcast loop) — avoids crashing issues
2026-08-07 12:53:52 +08:00
ramseshk 121c67ae5f feat: VBT dashboard — asset badges, interval/bar selectors, sort/filter
Dashboard (vbt.html):
- Interval selector: 1m, 5m, 15m, 1h, 4h, 1d (all Hyperliquid intervals)
- Candle limit selector: 100-5000 bars (6 levels)
- Asset selector: auto/BTC/ETH/SOL for run
- Strategy filter dropdown
- Sort dropdown: Latest, Sharpe, Return%, Min DD, Trades
- Asset badge on every result item in sidebar
- Asset interval filter for results list
- Improved layout: compact 3-row control panel

API (server.py):
- /api/vbt/results: new sort param (sharpe/return/dd/trades/date)
  new interval filter, asset field with _infer_asset()
- /api/vbt/run: new coin param, interval already supported
  coin suffix in saved filenames
- _infer_asset(): maps strategy names to BTC/ETH/BTC-ETH/SOL

Verified: sort=sharpe shows A-S S=+11.37, interval=1h filters
correctly, 7 dashboard controls rendered, asset badges on all items
2026-08-07 12:41:08 +08:00
ramseshk 737b24895c fix: VBT dashboard — proper metrics display + redesigned UI
- Fixed total_return_pct, profit_factor, n_bars showing 0 in detail view
  by using ?? operator instead of || 0 and fixing renderDetail logic
- Run Backtest now renders result directly from API response
  (no re-fetch race condition)
- Redesigned UI: monospace trading terminal aesthetic
  - Darker palette (#090d14 background, #0d1321 cards)
  - Indigo histogram, proper grid layout
  - Subtle borders (1px #1a2332), better spacing
  - Status indicator with pulse animation
  - Sidebar shows Sharpe, Return%, Profit Factor per result
  - 8 metric cards: Return, Sharpe, DD, Win Rate, PF, Trades,
    End Equity, Sortino
  - Smaller, cleaner fonts, monospace throughout
- Bumped memory guard to 2GB to prevent dashboard getting killed
2026-08-07 12:31:24 +08:00
ramseshk 6934bfdaa0 feat: VectorBT results dashboard with Plotly charts
Dashboard (dashboard/):
- New /api/vbt/results — list VBT backtest results with full metrics
- New /api/vbt/result/{file} — load result + equity curve (auto-decimated >500pts)
- New /api/vbt/run — run backtests on-demand from the UI
- New /api/vbt/sweep — parameter sweep as heatmap data
- New /api/vbt/strategies — list available strategy keys
- New /vbt — interactive HTML dashboard (Plotly.js):
  - Equity curve chart with area fill
  - Drawdown waterfall chart
  - Returns distribution histogram
  - Metric cards: Sharpe, Sortino, max DD, win rate, profit factor
  - Strategy filter sidebar
  - One-click backtest runner
- Fix BACKTEST_DIR auto-detection for local/dev paths

API verified: all 5 endpoints tested against live data
2026-08-06 17:43:47 +08:00