MarketLab Docs

Examples

Real command examples for sources, studies, and strategies.

Examples

This page focuses on the commands people will actually run first:

  • source
  • study
  • script backtest
  • script runs list
  • script runs show
  • strategy run
  • strategy backtest

All examples below assume:

  • --provider mmt
  • millisecond timestamps at the CLI boundary
  • current provider support limited to MMT

Sources

Orderbook snapshot

mlab source orderbook \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --depth 100 \
  --output terminal

Orderbook stream

mlab source orderbook \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --depth 100 \
  --stream \
  --min-size 0.1 \
  --price-group 1 \
  --interval-ms 1000 \
  --buffer-size 20 \
  --output terminal

Candles range

mlab source candles \
  --provider mmt \
  --exchange binancef \
  --symbol BTC/USDT \
  --timeframe 60 \
  --from 1779880000000 \
  --to 1779883600000 \
  --output json

Candles stream

mlab source candles \
  --provider mmt \
  --exchange binancef \
  --symbol BTC/USDT \
  --timeframe 60 \
  --stream \
  --output jsonl

VD range

mlab source vd \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --from 1779620400000 \
  --to 1779624000000 \
  --bucket 1 \
  --output json

VD stream

mlab source vd \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --bucket 1 \
  --stream \
  --output jsonl

OI range

mlab source oi \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --from 1779660000000 \
  --to 1779705600000 \
  --output json

OI stream

mlab source oi \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --stream \
  --output jsonl

Volumes range

mlab source volumes \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --from 1779660000000 \
  --to 1779705600000 \
  --output json

Volumes stream

mlab source volumes \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --stream \
  --output jsonl

Scripts

Backtest a strategy-like script

mlab script backtest ./scripts/sma-cross.js \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --from 1704067200000 \
  --to 1704667200000 \
  --source candles:timeframe=60 \
  --param candles:fast=20 \
  --param candles:slow=50 \
  --param candles:notional=1000 \
  --leverage 5 \
  --output json

Backtest a VD script

mlab script backtest ./scripts/vd-summary.js \
  --provider mmt \
  --exchange hyperliquid \
  --symbol HYPE/USDT \
  --from 1780497965372 \
  --to 1780618018000 \
  --source vd:timeframe=3600 \
  --source vd:bucket=1 \
  --param vd:min_delta=500 \
  --output json

Backtest independent position exits

mlab script backtest ./scripts/dip-tp-positions.js \
  --provider mmt \
  --exchange hyperliquid \
  --symbol HYPE/USDT \
  --from 1780497965372 \
  --to 1780618018000 \
  --source candles:timeframe=3600 \
  --param candles:drop_bps=20 \
  --param candles:take_profit_bps=50 \
  --param candles:notional=1000 \
  --leverage 5 \
  --output terminal

This script opens separate long positions on dips and closes only the position whose position_id hits its take-profit condition.

Run a live multi-source script

mlab script run ./scripts/all-sources-live.js \
  --provider mmt \
  --exchange hyperliquid \
  --symbol HYPE/USDT \
  --source candles:timeframe=60 \
  --source orderbook:depth=100 \
  --source vd:timeframe=60 \
  --source vd:bucket=1 \
  --output jsonl

List script runtime reports

mlab script runs list

View a script runtime report

mlab script runs show <run-id>

Studies

Spread

mlab study spread \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --depth 20 \
  --output json

Depth

mlab study depth \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --levels 20 \
  --output json

Imbalance

mlab study imbalance \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --depth 50 \
  --output json

Slippage

mlab study slippage \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --side buy \
  --notional 100000 \
  --depth 100 \
  --output json

VAMP

mlab study vamp \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --depth 100 \
  --dollar-depth 250000 \
  --output json

CVD

mlab study cvd \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 3600 \
  --from 1779620400000 \
  --to 1779624000000 \
  --bucket 1 \
  --output json

Strategy Run

Live SMA crossover

mlab strategy run sma-crossover \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --output terminal

Live SMA crossover with warmup anchor

mlab strategy run sma-crossover \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --from 1779887295785 \
  --output jsonl

Strategy Backtest

Historical SMA crossover

mlab strategy backtest sma-crossover \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --from 1779660000000 \
  --to 1779705600000 \
  --fast 20 \
  --slow 50 \
  --confirm-bars 1 \
  --output terminal

Historical SMA crossover JSON

mlab strategy backtest sma-crossover \
  --provider mmt \
  --exchange bybitf \
  --symbol BTC/USDT \
  --timeframe 60 \
  --from 1779660000000 \
  --to 1779705600000 \
  --fast 20 \
  --slow 50 \
  --output json

On this page