Q
Quant Web Backtester
Rust engine • Next.js UI

Engineering / Notes

Architecture

Browser
  |
  |  Next.js (TypeScript) + Tailwind + minimal shadcn-style UI
  |  - TradingView Lightweight Charts (candles + overlays + markers)
  |  - Recharts (equity/drawdown/sharpe/hist/exposure)
  |
  v
Rust API (axum)
  - /api/universe
  - /api/backtests (job runner)
  - /api/backtests/{id}/results (stored JSON)
  - Rate limiting, tracing logs
  - Polygon/Massive data fetch + retries + disk cache
  |
  v
Rust Engine (crate)
  - Indicators
  - Strategy signals (no lookahead)
  - Next-bar execution
  - Costs + borrow/funding carry
  - Metrics + trades + series
  |
  v
Disk (volume)
  - cache/   (market data)
  - runs/    (configs + results + status)

Backtesting pitfalls handled

  • No lookahead: signals are based on bar-close data only.
  • Next-bar execution: orders fill at next bar open (with slippage).
  • Adjusted prices toggle (equities) with clear UI explanation.
  • Transaction costs + slippage (bps per side) always applied.
  • Short borrow and funding carry modeled (annualized, dt-aware).
  • Time alignment: UTC timestamps; pairs use strict timestamp intersection.
  • Missing bars/gaps: never forward-filled; gaps accrue carry over dt.
  • Parameter sanity guards + bounded date ranges.
  • Reproducible configs: stored with run results, copyable JSON.

Local + VPS

docker compose up --build runs web+api locally.

For VPS TLS, use docker-compose.prod.yml + Caddy. Set DOMAIN and CADDY_EMAIL in .env.