verida.trade CT Lab · verida.trade

Backtest

Run a strategy over an OHLCV series with Rhai entry/exit logic, get Sharpe, Sortino, drawdown, win-rate, profit-factor, PnL and trade count.

The backtest takes a price series (OHLCV), a strategy in Rhai (inline or file), optional indicators, initial capital and parameters. Returns performance metrics: Sharpe, Sortino, max drawdown, win-rate, profit-factor, total PnL and number of trades. Persists results for comparison across sessions.

Strategy (Rhai)

The strategy is a Rhai script that reads price (close[0]), indicators (ind["name"][0]), current position, and returns a decision: long(), short(), flat() or decision(...).

// example: moving average crossover
if ind["ema_short"][0] > ind["ema_long"][0] {
    long()
} else if ind["ema_short"][0] < ind["ema_long"][0] {
    short()
} else {
    flat()
}

Experiment comparator

Define a base experiment (control) and N variants, each swapping one factor: strategy, indicators, fee_pct or parameters. Variants run side by side with everything else held fixed.

Search and persistence

All backtests are persisted with spec and metrics. Search supports filters (field, operator, value) and sorting — basis for comparing experiments across sessions: filter by Sharpe greater than 1.0 and drawdown less than 20%, for example.

  • Structure measurement — measure whether the price path has exploitable structure.
  • Survival test — the doctrine’s pair test: does your manager survive on either side?