Stats Reference

Every performance stat the run reports, its exact formula, and its edge cases. The stats are computed by the kScript (legacy) engine's own statistics module…

Every performance stat the run reports, its exact formula, and its edge cases. The stats are computed by the kScript (legacy) engine's own statistics module, vendored unchanged, and delivered under strategy.output.stats in the backtest report and under the run's strategy key on a chart. Percent-scaled fields end in Pct and are already multiplied by 100.

{
  "netProfit": 123.4, "netProfitPct": 1.234, "grossProfit": 310.2, "grossLoss": 186.8, "profitFactor": 1.66,
  "totalTrades": 12, "winTrades": 7, "lossTrades": 5, "winRatePct": 58.33, "avgTrade": 10.28, "avgWin": 44.31, "avgLoss": 37.36,
  "payoffRatio": 1.19, "largestWin": 96.1, "largestLoss": 61.5, "avgBarsInTrade": 9.4,
  "maxDrawdown": 402.6, "maxDrawdownPct": 3.98, "maxRunup": 640.2, "sharpe": 0.91, "sortino": 1.4, "exposurePct": 22.1,
  "buyHoldReturnPct": 4.1, "feesPaid": 32.1, "makerFeesPaid": 0, "takerFeesPaid": 0,
  "fundingPaid": 0, "fundingEventsApplied": 0, "fundingUnavailableCount": 0, "liquidationCount": 0, "liquidationHalted": false, "bankruptcyDeficit": 0,
  "rejectedOrders": 1, "ambiguousFillCount": 0, "fineResolvedCount": 0, "fineFillCoveragePct": null, "fillResolutionByLane": {},
  "bookSlippageFillCount": 0, "bookSlippageUnavailableCount": 0, "bookSlippageAvgBps": null,
  "long": { "netProfit": 123.4, "totalTrades": 12, "winRatePct": 58.33 }, "short": { "netProfit": 0, "totalTrades": 0, "winRatePct": 0 }
}

Returns

StatDefinition
netProfitSum over closed trades of pnl - fees (a trade record's pnl is the price move, its fees the trade's total). netProfitPct is relative to initialCapital.
grossProfit / grossLossSum of winning trades' net results and the absolute sum of losing trades'.
profitFactorgrossProfit / grossLoss; null when there are no losses.
buyHoldReturnPct(lastConfirmedClose / firstTradableClose - 1) * 100 over the run's confirmed bars: what doing nothing would have returned. The backtest card's benchmark is this number.

Trades

StatDefinition
totalTrades, winTrades, lossTradesClosed trades and the split; winRatePct is winTrades / totalTrades * 100.
avgTrade, avgWin, avgLossMean net result per closed trade, per winner, per loser (avgLoss is a magnitude).
payoffRatioavgWin / avgLoss; null when there are no losers. Read it with the win rate: 40% winners at a 3.0 payoff is profitable, 70% at 0.3 is not.
largestWin, largestLossThe single best and worst closed trades. If largestWin dominates netProfit, one trade made the backtest.
avgBarsInTradeMean holding time in bars (exitBar - entryBar).
rejectedOrdersOrders the broker refused and counted: the pyramiding cap, conflicting or missing legs, a size the equity could not fund, a non-finite or unconfirmed bar (a live chart's forming bar included); on perps also insufficient margin and post-halt entries.

Risk

StatDefinition
maxDrawdownLargest peak-to-trough equity decline over the run, in money; maxDrawdownPct is relative to the peak it fell from. The per-bar drawdown series is the money distance from the running peak.
maxRunupMirror of drawdown: the largest trough-to-peak climb.
sharpemean(r) / sampleStd(r) * sqrt(barsPerYear) over per-bar equity returns on confirmed bars, barsPerYear = 31,536,000,000 / intervalMs; zero with no variance. Annualized from the run's interval, so compare across runs at the same interval.
sortinoSharpe with the downside deviation (returns below zero) in the denominator.
exposurePctBars with a nonzero position over all confirmed bars, times 100.

Costs

StatDefinition
feesPaidTotal fees across all fills, already subtracted from equity and netProfit (funding excluded). Spot: commissionPercent of each fill's notional. Perps: exactly makerFeesPaid + takerFeesPaid.
makerFeesPaid / takerFeesPaidPerps fees by fill class; both 0 on spot even with rates declared.
fundingPaidNet funding settled against open perps positions, signed from the strategy's side; 0 under funding: "off", on spot, and in this release, which attaches no funding data.
fundingEventsAppliedSettlements applied to an open position.
fundingUnavailableCountBars an open perps position had no covering funding data under funding: "data": in this release every such bar. The disclosure counter; no rate is ever invented.

Slippage is not a separate stat line: it is priced into every fill.

Perps

StatDefinition
liquidationCountTrades force-closed by the broker's liquidation stop; those trades carry exitReason: "liquidation". One liquidation can close several open trade records in the same net position.
liquidationHaltedtrue when onLiquidation: "halt" stopped the run at the first liquidation; every subsequent entry counts as rejected.
bankruptcyDeficitThe shortfall a liquidation fill left beyond the position's committed margin: how far equity would have gone below zero before the floor.

Perps runs also add committedMarginSeries and fundingPaidSeries beside the stats; both are omitted on spot.

Long and short splits

long and short carry netProfit, totalTrades and winRatePct per direction. A "market-neutral" idea whose entire profit sits in long during a bull window is a long-only idea with extra steps.

Simulation-quality stats

These describe how the result was produced, not how the strategy performed:

StatDefinition
ambiguousFillCountIntrabar ordering decisions settled by the declared fillModel rather than data; see fill simulation.
fineResolvedCount, fineFillCoveragePct, fillResolutionByLaneOrdering questions settled by walking finer bars: 0, null and {} in this release, which attaches no finer-interval data.
bookSlippageFillCount, bookSlippageUnavailableCount, bookSlippageAvgBpsThe book-estimate slippage model's counters: 0, 0 and null, because that model is refused by name in this release.

Equity accounting, precisely

Equity on every bar i is cash plus the open position marked at close[i], fees already paid, recorded on flat bars too. Per-bar returns for Sharpe and Sortino are r_i = equity_i / equity_{i-1} - 1 over confirmed bars with positive prior equity. On a full run (a backtest, a chart's first render) every bar is confirmed, the newest included: an order placed on the last bar rests pending. On a live chart the newest bar is the forming bar: it is marked, never filled, and its orders are rejected and counted, so pending-order and stat values can shift once between the first render and the first tick, and settle when the bar confirms.