Sequence/docs

Backtesting

Run your WASM algo against recorded market data using the sim engine.

bash
sequence backtest BTC-USD --start 2026-01-01 --end 2026-01-31

Usage

bash
sequence backtest <SYMBOL> --start <DATE> --end <DATE> [OPTIONS]

Required

ArgumentDescription
<SYMBOL>Trading pair (e.g., BTC-USD)
--start <DATE>Start date (YYYY-MM-DD)
--end <DATE>End date (YYYY-MM-DD)

Options

FlagDefaultDescription
--symbols <LIST>-Multiple pairs, comma-separated (overrides positional SYMBOL)
--capital <USD>100000Initial capital in USD
--venue <LIST>allLimit to specific venue(s), comma-separated
--seed <INT>42PRNG seed for deterministic replay
--skip-buildfalseUse existing .wasm (skip cargo build)
--bundle <ID>-Use a registered bundle instead of building from source

Examples

Single Symbol

bash
sequence backtest BTC-USD \
  --start 2026-02-01 \
  --end 2026-02-28 \
  --capital 50000

Multi-Symbol

bash
sequence backtest --symbols BTC-USD,ETH-USD,SOL-USD \
  --start 2026-01-01 \
  --end 2026-03-01 \
  --capital 100000

Specific Venues

bash
sequence backtest BTC-USD \
  --start 2026-02-01 \
  --end 2026-02-28 \
  --venue kraken,coinbase

From a Bundle

bash
sequence backtest BTC-USD \
  --start 2026-02-01 \
  --end 2026-02-28 \
  --bundle bun_e4f2a1

This reads bun_e4f2a1.bundle.json for the WASM reference instead of building from source.

Deterministic Replay

bash
sequence backtest BTC-USD \
  --start 2026-02-01 \
  --end 2026-02-28 \
  --seed 123

Same seed + same data = identical results. Useful for A/B testing strategy changes.


How It Works

1

Resolve WASM

From --bundle manifest, or build from source, or use existing .wasm with --skip-build.

2

Launch sim-engine

The CLI shells out to sim-engine run with your parameters. The sim engine replays recorded L2 events and trades from Parquet files.

3

Execute your algo

Your WASM algo receives book updates and produces actions exactly as it would in live trading. All time is simulated - no SystemTime::now() in the sim loop.

4

View results

Simulation output streams to stdout: fills, P&L, and summary statistics.

Note

The sim engine must be installed and in your PATH. sequence update installs it alongside the CLI. You can also build it with cargo build -p sim-engine --release.


Data Requirements

Backtests read from the sim data store:

  • Local: ./data/sim/ (default). Set SIM_STORE_PATH to override the local directory.
  • S3: Remote object store (set SIM_STORE=s3). Set SIM_S3_BUCKET for the bucket name (default: sequence-sim-data-dev).
VariableDefaultDescription
SIM_STORElocalStorage backend: local or s3
SIM_STORE_PATH./data/simLocal filesystem path for sim data
SIM_S3_BUCKETsequence-sim-data-devS3 bucket name when SIM_STORE=s3

Dashboard Backtesting

Backtests can also be launched from the Terminal dashboard. Open any deployment, navigate to the Backtest tab, and configure date range, capital, and seed. The dashboard uses the POST /v1/backtest API and displays results inline -- including equity curves, summary metrics, and decision traces.

See the Backtest API for the underlying endpoints.


Advanced Features

The sim engine includes realism models (adverse selection, self-impact, volatility-conditioned latency), calibration tools, and stress testing scenarios.

See the full Sim Engine reference for details.