Backtest Lab

Portfolio Mode

With 2+ symbols entered, Configure's Market & data group grows a Portfolio mode switch: one shared-capital backtest across all symbols instead of independent per-symbol runs.

Portfolio types (PortfolioTick, the portfolio ctx) are not yet in the generated reference; the Editor types them loosely.

  • Your strategy exports onTick(tick, ctx) instead of onBar — fired once per distinct timestamp with tick.symbols listing which symbols have a bar there. Every ctx call takes a symbol:

    ctx.bar('AAPL');
    ctx.position('MSFT');
    ctx.buy({ symbol: 'AAPL', qty });
    ctx.indicator('rsi', { period: 14 }, { symbol: 'AAPL' });
  • Shared buying power — all positions draw on one cash pool; total notional is capped by equity × leverage. Symbols are processed in your symbols-array order each tick (deterministic).

  • Per-symbol cap — Configure's "max % of equity per symbol" field (0 = off) keeps one symbol from eating the whole book. Cap rejections show as buying-power rejections.

  • Results — one PORTFOLIO run: portfolio equity vs. an equal-weight buy-and-hold benchmark, a per-symbol breakdown table (trades, net P&L, win rate, avg win/loss, and commission per symbol, with per-symbol chart navigation), and a symbol column in the trades table.

  • Portfolio walk-forward works; windows are counted on the portfolio's merged tick axis, run once rather than per symbol.

  • Not supported in portfolio mode: holdout, cloud runs (not available in any mode yet), cross-symbol OCO.