Examples
Real command examples for sources, studies, and strategies.
Examples
This page focuses on the commands people will actually run first:
sourcemarketsstudyscript backtestscript runs listscript runs showscript jobs,status,logs,stop, andrestartstrategy run twapstrategy jobs,status,logs, andstoptrade longtrade shortpositions,orders, andfillscancelandclosedaemon
MMT examples below assume:
--provider mmt- millisecond timestamps at the CLI boundary
BULK source examples use --exchange bulk and omit --provider. Public BULK market data does not require credentials. Account and execution commands require an authorized BULK agent.
BULK Markets
List the embedded catalog
mlab markets --exchange bulkInspect one market
mlab markets --exchange bulk --symbol BTC/USDTGet one rule set as JSON
mlab markets --exchange bulk --symbol BTC/USDT --jsonThese commands read the snapshot embedded in the binary and require no provider credentials or network request.
BULK Sources
Public orderbook
mlab source orderbook \
--exchange bulk \
--symbol BTC/USDT \
--depth 100 \
--output terminalHistorical candles
mlab source candles \
--exchange bulk \
--symbol BTC/USDT \
--timeframe 60 \
--from 1780307559000 \
--to 1780523645000 \
--output jsonLive order flow
mlab source vd \
--exchange bulk \
--symbol BTC/USDT \
--stream \
--output jsonlMarket statistics and funding
mlab source stats --exchange bulk --period 7d --output json
mlab source funding --exchange bulk --symbol BTC/USDT --stream --output jsonlSee BULK Provider for the exact range, snapshot, and stream contract of each source.
BULK Execution
Preview a market order
mlab trade long BTC/USDT --margin 10 --dry-runDry-run output is the same normalized plan reviewed before a live order. It does not sign, submit, or start mlabd.
Preview an ALO limit order
mlab trade short BTC/USDT \
--size 0.001 \
--type limit \
--price 65000 \
--tif alo \
--leverage 3 \
--dry-runPreview native stop and take-profit protection
mlab trade long BTC/USDT \
--margin 100 \
--leverage 5 \
--sl 63000 \
--tp 69000 \
--dry-runSubmit with terminal confirmation
mlab trade long BTC/USDT --margin 100 --leverage 5Inspect account state
mlab positions
mlab orders --symbol BTC/USDT
mlab fills --symbol BTC/USDTPreview cancellation and closing
mlab cancel BTC/USDT <ORDER_ID> --dry-run
mlab close BTC/USDT --dry-runInspect the execution runtime
mlab daemon status
mlab daemon events --limit 20 --output jsonl
mlab daemon stopSee Execution for live confirmation rules, TOML configuration, validation, and runtime security.
Sources
Orderbook snapshot
mlab source orderbook \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--depth 100 \
--output terminalOrderbook 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 terminalCandles range
mlab source candles \
--provider mmt \
--exchange binancef \
--symbol BTC/USDT \
--timeframe 60 \
--from 1779880000000 \
--to 1779883600000 \
--output jsonCandles stream
mlab source candles \
--provider mmt \
--exchange binancef \
--symbol BTC/USDT \
--timeframe 60 \
--stream \
--output jsonlVD range
mlab source vd \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--timeframe 60 \
--from 1779620400000 \
--to 1779624000000 \
--bucket 1 \
--output jsonVD stream
mlab source vd \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--timeframe 60 \
--bucket 1 \
--stream \
--output jsonlOI range
mlab source oi \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--timeframe 60 \
--from 1779660000000 \
--to 1779705600000 \
--output jsonOI stream
mlab source oi \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--timeframe 60 \
--stream \
--output jsonlVolumes range
mlab source volumes \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--timeframe 60 \
--from 1779660000000 \
--to 1779705600000 \
--output jsonVolumes stream
mlab source volumes \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--timeframe 60 \
--stream \
--output jsonlScripts
Backtest a JavaScript strategy
mlab script backtest ./scripts/sma-cross.js \
--symbol BTC/USDT \
--from 1704067200000 \
--to 1704667200000 \
--source candles@bybitf@mmt:timeframe=60 \
--param fast=20 \
--param slow=50 \
--param margin=1000 \
--leverage 5 \
--output jsonBacktest a VD script
mlab script backtest ./scripts/vd-summary.js \
--symbol HYPE/USDT \
--from 1780497965372 \
--to 1780618018000 \
--source vd@hyperliquid@mmt:timeframe=3600,bucket=1 \
--param min_delta=500 \
--output jsonCompare candles across exchanges
mlab script backtest ./examples/cross-exchange-spread.js \
--symbol BTC/USDT \
--from 1704067200000 \
--to 1704667200000 \
--source candles@binancef@mmt:timeframe=60 \
--source candles@okx@mmt:timeframe=60 \
--output jsonThe script reads both histories with history.source("candles@binancef@mmt") and history.source("candles@okx@mmt") in backtests and live mode.
Backtest independent position exits
mlab script backtest ./scripts/dip-tp-positions.js \
--symbol HYPE/USDT \
--from 1780497965372 \
--to 1780618018000 \
--source candles@hyperliquid@mmt:timeframe=3600 \
--param drop_bps=20 \
--param take_profit_bps=50 \
--param margin=1000 \
--leverage 5 \
--output terminalThis script opens separate long positions on dips and closes only the position whose position_id hits its take-profit condition.
Deploy a live analysis script
mlab script run ./scripts/all-sources-live.js \
--symbol HYPE/USDT \
--source candles@hyperliquid@mmt:timeframe=5 \
--source orderbook@hyperliquid@mmt:depth=100 \
--source vd@hyperliquid@mmt:timeframe=60,bucket=1script run returns a detached job ID. It does not hold the terminal open.
Deploy a strategy with BULK execution
mlab script run ./examples/bulk-limit-protected.js \
--symbol BTC/USDT \
--source candles@bulk:timeframe=5 \
--venue bulk \
--param armed=trueThe script calls ctx.trade directly. --venue bulk is required to enable live execution; the data provider can still be MMT or BULK.
Manage live script jobs
mlab script jobs
mlab script status <JOB_ID>
mlab script logs <JOB_ID> --follow
mlab script stop <JOB_ID>
mlab script restart <JOB_ID>List script runtime reports
mlab script runs listView a script runtime report
mlab script runs show <run-id>Runtime reports are historical telemetry. Use script jobs and script status for deployed workers.
Studies
Spread
mlab study spread \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--depth 20 \
--output jsonDepth
mlab study depth \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--levels 20 \
--output jsonImbalance
mlab study imbalance \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--depth 50 \
--output jsonSlippage
mlab study slippage \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--side buy \
--notional 100000 \
--depth 100 \
--output jsonVAMP
mlab study vamp \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--depth 100 \
--dollar-depth 250000 \
--output jsonCVD
mlab study cvd \
--provider mmt \
--exchange bybitf \
--symbol BTC/USDT \
--timeframe 3600 \
--from 1779620400000 \
--to 1779624000000 \
--bucket 1 \
--output jsonTWAP Strategy
Preview the normalized schedule
mlab strategy run twap BTC/USDT \
--exchange bulk \
--side buy \
--margin 100 \
--duration 300 \
--interval 60 \
--dry-runDeploy a live TWAP job
mlab strategy run twap BTC/USDT \
--exchange bulk \
--side buy \
--margin 100 \
--duration 300 \
--interval 60The CLI asks for confirmation, submits the immutable plan to mlabd, prints the job ID, and returns.
Submit by size with structured output
mlab strategy run twap BTC/USDT \
--exchange bulk \
--side sell \
--size 0.01 \
--duration 600 \
--interval 30 \
--yes \
--output jsonMonitor and stop the job
mlab strategy jobs
mlab strategy status <JOB_ID>
mlab strategy logs <JOB_ID> --follow
mlab strategy stop <JOB_ID>The current TWAP implementation uses market child orders. Stopping prevents later children; it does not reverse fills or close the resulting position. See TWAP.